Create a new API endpoint entity with HTTP method, parameters, responses, owners, tags, and metadata within an API collection using the Collate REST API.
POST
/
v1
/
apiEndpoints
POST /v1/apiEndpoints
Copy
from metadata.sdk import configurefrom metadata.sdk.entities import APIEndpointsfrom metadata.generated.schema.api.data.createAPIEndpoint import CreateAPIEndpointRequestconfigure( host="https://your-company.getcollate.io/api", jwt_token="your-jwt-token")request = CreateAPIEndpointRequest( name="addPet", displayName="Add Pet", apiCollection="sample_api_service.pet", description="Add a new pet to the store", endpointURL="https://petstore3.swagger.io/#/pet/addPet", requestMethod="POST", requestSchema={ "schemaType": "JSON", "schemaFields": [ {"name": "id", "dataType": "INT", "description": "ID of pet"} ] })endpoint = APIEndpoints.create(request)print(f"Created: {endpoint.fullyQualifiedName}")
Use PUT /v1/apiEndpoints instead of POST to perform an upsert. If an API endpoint with the same fullyQualifiedName already exists, it will be updated; otherwise, a new API endpoint is created. The request body is the same as POST.
Copy
curl -X PUT "{base_url}/api/v1/apiEndpoints" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ ... same body as POST ... }'
PUT will not return a 409 conflict error if the entity already exists — it will update the existing entity instead.