API POST structured-output /create endpoint return...
# support
j
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." }
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"] }
c
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:
Copy code
json
"type": "ai"
Here’s a corrected version of your request body:
Copy code
json
{
  "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:
Copy code
bash
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.