Create function

Create a new function for an assistant.

Request

POST https://superinterface.ai/api/cloud/assistants/{assistantId}/functions

Authentication

Include your private API key in the request headers:
Authorization: Bearer YOUR_PRIVATE_API_KEY

Path Parameters

ParameterTypeDescription
assistantIdstringThe ID of the assistant

Request Body

ParameterTypeRequiredDescription
openapiSpecstringYesOpenAPI specification in JSON format
handlerobjectYesFunction handler configuration
handler shape depends on type. See the Handler type for all options. For a REQUEST handler:
ParameterTypeRequiredDescription
typeHandlerTypeYesMust be REQUEST
requestHandlerobjectYes{ url: string, method: string, headers: string, body: string }

Example request

curl -X POST "https://superinterface.ai/api/cloud/assistants/00cfe680-fee5-49b9-b386-6a7097eb8497/functions" \ -H "Authorization: Bearer YOUR_PRIVATE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "openapiSpec": "{\"openapi\":\"3.1.0\"}", "handler": { "type": "REQUEST", "requestHandler": { "url": "https://example.com", "method": "GET", "headers": "{}", "body": "{}" } } }'

Response

ParameterTypeDescription
functionFunctionNew function

Example response

{ "function": { "id": "00cfe680-fee5-49b9-b386-6a7097eb8497", "openapiSpec": "{\"openapi\":\"3.1.0\"}", "handler": { "type": "REQUEST", "requestHandler": { "url": "https://example.com", "method": "GET", "headers": "{}", "body": "{}" } }, "createdAt": "2024-01-15T10:30:00Z", "updatedAt": "2024-01-15T10:30:00Z" } }

Errors

The endpoint may return the following errors:

401 Unauthorized

This error occurs if the API key is invalid or missing.
{ "error": "Unauthorized", "message": "Invalid or missing API key" }