Create a Function - Cognigy Documentation
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Create a Function
Request
POST /v2.0/functions
curl --request POST \
--url https://api-trial.cognigy.ai/new/v2.0/functions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '\
{\
"name": "<string>",\
"code": "<string>",\
"isDisabled": true,\
"projectId": "<string>"\
}\
'
cURL Example
curl --request POST \
--url https://api-trial.cognigy.ai/new/v2.0/functions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '{\
"name": "<string>",\
"code": "<string>",\
"isDisabled": true,\
"projectId": "<string>"\
}'
Python Example
import requests
url = "https://api-trial.cognigy.ai/new/v2.0/functions"
payload = {\
"name": "<string>",\
"code": "<string>",\
"isDisabled": True,\
"projectId": "<string>"\
}
headers = {\
"X-API-Key": "<api-key>",\
"Content-Type": "application/json"\
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Response
Success (201)
{
"name": "<string>",
"code": "<string>",
"isDisabled": true,
"_id": "<string>",
"createdAt": 1694518620,
"lastChanged": 1694518620,
"createdBy": "<string>",
"lastChangedBy": "<string>"
}
Error Responses
{
"type": "Bad Request",
"title": "Bad Request Error",
"status": 400,
"detail": "Validation failed. Missing payload.",
"instance": "/v2.0/flows/5ce7c2d833ea1e04d7e6c432",
"code": 1000,
"traceId": "api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f",
"details": {}
}
{
"type": "Unauthorized",
"title": "Unauthorized Error",
"status": 401,
"detail": "<string>",
"instance": "/v2.0/flows/5ce7c2d833ea1e04d7e6c432",
"code": 401,
"traceId": "api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f",
"details": {}
}
Authorizations
- APIKeyHeader:
X-API-Key- string, required
Headers
Accept - enumAccept header specifies the media type that the client expects in the response. Available options: application/json, application/hal+json, application/xml, text/xml, text/csv. The default value is application/json.
Body
- name: string
- code: string
- isDisabled: boolean
- projectId: string (unique identifier for the Project, Required string length:
24, Pattern:^[a-z0-9]{24}$)
Response Metadata
Returns Function metadata object with information about creation and modification dates and user details.