ratty-blush
ratty-blush4d ago

API POST structured-output /create endpoint returns 500 internal errors

I have tried many many different body, each time the api would return { "statusCode": 500, "message": "Internal server error. Contact support@vapi.ai for help." }
2 Replies
ratty-blush
ratty-blushOP4d ago
I have even created one via the VAPI UI (id 653dd2c7-6b25-4252-a3ad-ec5aab4f20d1) then copied the schema to try to create it via the API : still the same answer. Other endpoints (e.g. GET) work so it's not an authentication issue. ✅ GET {{baseUrl}}/structured-output/653dd2c7-6b25-4252-a3ad-ec5aab4f20d1 ❌ POST {{baseUrl}}/structured-output { "name": "test", "schema": { "type": "object", "required": [ "leadType" ], "properties": { "lastName": { "description": "Last name of the new contact", "type": "string" }, "leadType": { "type": "string", "enum": [ "Contact", "Search", "Owner", "Valuation" ] }, "firstName": { "description": "First name of the new contact", "type": "string" } } }, "assistantIds": ["2f7fbacf-a412-4366-8213-47f6ed3fa81a"] }
Kyle
Kyle2d ago
Hi Jeebs, Thanks for sharing the details — I dug into this on our side, and I found the root cause of the 500 error you're seeing. The issue is that the type field is required when creating a structured output, but it's currently hidden from the public API docs, so it's not obvious that it needs to be included. The only valid value is:
"type": "ai"
"type": "ai"
Here’s a corrected version of your request body:
{
"name": "test",
"type": "ai",
"schema": {
"type": "object",
"required": ["leadType"],
"properties": {
"lastName": {
"description": "Last name of the new contact",
"type": "string"
},
"leadType": {
"type": "string",
"enum": ["Contact", "Search", "Owner", "Valuation"]
},
"firstName": {
"description": "First name of the new contact",
"type": "string"
}
}
},
"assistantIds": ["2f7fbacf-a412-4366-8213-47f6ed3fa81a"]
}
{
"name": "test",
"type": "ai",
"schema": {
"type": "object",
"required": ["leadType"],
"properties": {
"lastName": {
"description": "Last name of the new contact",
"type": "string"
},
"leadType": {
"type": "string",
"enum": ["Contact", "Search", "Owner", "Valuation"]
},
"firstName": {
"description": "First name of the new contact",
"type": "string"
}
}
},
"assistantIds": ["2f7fbacf-a412-4366-8213-47f6ed3fa81a"]
}
And the equivalent curl example:
curl -X POST "https://api.vapi.ai/structured-output" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "test",
"type": "ai",
"schema": {
"type": "object",
"required": ["leadType"],
"properties": {
"lastName": {
"description": "Last name of the new contact",
"type": "string"
},
"leadType": {
"type": "string",
"enum": ["Contact", "Search", "Owner", "Valuation"]
},
"firstName": {
"description": "First name of the new contact",
"type": "string"
}
}
},
"assistantIds": ["2f7fbacf-a412-4366-8213-47f6ed3fa81a"]
}'
curl -X POST "https://api.vapi.ai/structured-output" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "test",
"type": "ai",
"schema": {
"type": "object",
"required": ["leadType"],
"properties": {
"lastName": {
"description": "Last name of the new contact",
"type": "string"
},
"leadType": {
"type": "string",
"enum": ["Contact", "Search", "Owner", "Valuation"]
},
"firstName": {
"description": "First name of the new contact",
"type": "string"
}
}
},
"assistantIds": ["2f7fbacf-a412-4366-8213-47f6ed3fa81a"]
}'
Once "type": "ai" is added, the endpoint should work correctly.

Did you find this page helpful?