Skip to content

Structured outputs ​

7 endpoint-uri. Fiecare cale de mai jos este relativă la URL-ul de bază al API-ului și include deja prefixul /api/v1 — vezi convențiile pentru autentificare, paginare, erori și idempotență.

Endpoint
GET/structured-outputsLists the organization's structured output definitions, optionally filtered to one target surface
POST/structured-outputsCreates a draft structured output definition after validating its JSON Schema
GET/structured-outputs/{structuredOutput}Returns one structured output definition with its schema and extraction prompt
PUT/structured-outputs/{structuredOutput}Updates a structured output definition, re-validating the schema when one is supplied
DELETE/structured-outputs/{structuredOutput}Deletes a structured output definition and detaches it from every assistant that used it
POST/structured-outputs/{structuredOutput}/publishFreezes the definition's schema into a new immutable version and returns its id and number
GET/structured-outputs/templatesReturns the built-in starter definitions, each ready to POST back as a new structured output

Endpoint-uri ​

Lists the organization's structured output definitions, optionally filtered to one target surface ​

GET/structured-outputs
  • Necesită assistant.read.
  • Query params: target (call|chat|both), limit (default 25, capped at 100).

Parametri de interogare

NumeTipObligatoriuNote
limitinteger—default 25
bash
curl -X GET "$CALLAGENT_API_URL/structured-outputs?limit=25" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs?limit=25`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs?limit=25');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.get(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs?limit=25",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200Paginated set of StructuredOutputResource

Erori

StatusCând apare
403The key lacks assistant.read

Exemplu de răspuns, generat din schemă:

json
{
  "data": [
    {
      "id": "01JQ0000000000000000000000",
      "object": "string",
      "name": "Support Line",
      "key": "string",
      "description": "string",
      "template": "string",
      "target": "string",
      "schema": {},
      "prompt": "string",
      "model": {},
      "status": "string",
      "is_published": true,
      "version": 1,
      "current_version_id": "01JQ0000000000000000000000",
      "enabled": true,
      "metadata": {},
      "created_at": "2026-01-01T12:00:00+00:00",
      "updated_at": "2026-01-01T12:00:00+00:00"
    }
  ],
  "links": {
    "first": "string",
    "last": "string",
    "prev": "string",
    "next": "string"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "links": [
      {}
    ],
    "path": "string",
    "per_page": 25,
    "to": 1,
    "total": 1
  }
}

Creates a draft structured output definition after validating its JSON Schema ​

POST/structured-outputs
  • Necesită assistant.write.
  • key is derived from name when omitted and is made unique, so the stored key may differ from what you sent.

Corpul cererii

CâmpTipObligatoriuNote
namestringdamax 255 chars
keystring | null—max 96 chars
descriptionstring | null—max 2000 chars
templatesummary · sentiment · success · follow_up · lead_qualification · customer_fields … | null—
targetcall · chat · both · null | null—
schemastring[]damin 1 items
promptstring | null—max 20000 chars
modelstring[] | null—
enabledboolean | null—
metadatastring[] | null—
bash
curl -X POST "$CALLAGENT_API_URL/structured-outputs" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
       "name": "Support Line",
       "schema": [
         "string"
       ],
       "template": "summary",
       "target": "call",
       "enabled": true
     }'
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Support Line",
    "schema": [
      "string"
    ],
    "template": "summary",
    "target": "call",
    "enabled": true
  }),
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
    'name' => 'Support Line',
    'schema' => [
        'string',
    ],
    'template' => 'summary',
    'target' => 'call',
    'enabled' => true,
]),
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.post(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    json={
      "name": "Support Line",
      "schema": [
        "string"
      ],
      "template": "summary",
      "target": "call",
      "enabled": True
    },
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
201StructuredOutputResource

Erori

StatusCând apare
403The key lacks assistant.write
422Validation failed, including per-node JSON Schema errors on schema

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "id": "01JQ0000000000000000000000",
    "object": "string",
    "name": "Support Line",
    "key": "string",
    "description": "string",
    "template": "string",
    "target": "string",
    "schema": {},
    "prompt": "string",
    "model": {},
    "status": "string",
    "is_published": true,
    "version": 1,
    "current_version_id": "01JQ0000000000000000000000",
    "enabled": true,
    "metadata": {},
    "created_at": "2026-01-01T12:00:00+00:00",
    "updated_at": "2026-01-01T12:00:00+00:00"
  }
}

Returns one structured output definition with its schema and extraction prompt ​

GET/structured-outputs/{structuredOutput}
  • Necesită assistant.read.

Parametri de cale

NumeTipObligatoriuNote
structuredOutputstringdaThe structured output ID
bash
curl -X GET "$CALLAGENT_API_URL/structured-outputs/01JQ0000000000000000000000" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs/01JQ0000000000000000000000`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs/01JQ0000000000000000000000');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.get(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs/01JQ0000000000000000000000",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200StructuredOutputResource

Erori

StatusCând apare
403The key lacks assistant.read
404No such definition in this organization

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "id": "01JQ0000000000000000000000",
    "object": "string",
    "name": "Support Line",
    "key": "string",
    "description": "string",
    "template": "string",
    "target": "string",
    "schema": {},
    "prompt": "string",
    "model": {},
    "status": "string",
    "is_published": true,
    "version": 1,
    "current_version_id": "01JQ0000000000000000000000",
    "enabled": true,
    "metadata": {},
    "created_at": "2026-01-01T12:00:00+00:00",
    "updated_at": "2026-01-01T12:00:00+00:00"
  }
}

Updates a structured output definition, re-validating the schema when one is supplied ​

PUT/structured-outputs/{structuredOutput}
  • Necesită assistant.write.
  • PATCH este acceptat pe aceeași cale, cu același corp.
  • Changing key re-runs uniqueness, so the stored key may be suffixed.

Parametri de cale

NumeTipObligatoriuNote
structuredOutputstringdaThe structured output ID

Corpul cererii

CâmpTipObligatoriuNote
namestring—max 255 chars
keystring | null—max 96 chars
descriptionstring | null—max 2000 chars
templatesummary · sentiment · success · follow_up · lead_qualification · customer_fields … | null—
targetcall · chat · both · null | null—
schemastring[]—
promptstring | null—max 20000 chars
modelstring[] | null—
enabledboolean | null—
metadatastring[] | null—
bash
curl -X PUT "$CALLAGENT_API_URL/structured-outputs/01JQ0000000000000000000000" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
       "name": "Support Line",
       "template": "summary",
       "target": "call",
       "enabled": true
     }'
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs/01JQ0000000000000000000000`, {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Support Line",
    "template": "summary",
    "target": "call",
    "enabled": true
  }),
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs/01JQ0000000000000000000000');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
    'name' => 'Support Line',
    'template' => 'summary',
    'target' => 'call',
    'enabled' => true,
]),
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.put(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs/01JQ0000000000000000000000",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    json={
      "name": "Support Line",
      "template": "summary",
      "target": "call",
      "enabled": True
    },
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200StructuredOutputResource

Erori

StatusCând apare
403The key lacks assistant.write
404No such definition in this organization
422Validation failed, including JSON Schema errors on schema

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "id": "01JQ0000000000000000000000",
    "object": "string",
    "name": "Support Line",
    "key": "string",
    "description": "string",
    "template": "string",
    "target": "string",
    "schema": {},
    "prompt": "string",
    "model": {},
    "status": "string",
    "is_published": true,
    "version": 1,
    "current_version_id": "01JQ0000000000000000000000",
    "enabled": true,
    "metadata": {},
    "created_at": "2026-01-01T12:00:00+00:00",
    "updated_at": "2026-01-01T12:00:00+00:00"
  }
}

Deletes a structured output definition and detaches it from every assistant that used it ​

DELETE/structured-outputs/{structuredOutput}
  • Necesită assistant.write.
  • Acest răspuns nu este împachetat în data.
  • Body is a bare {"deleted": true, "id": "..."}. Side effect: assistants using this definition are silently detached.

Parametri de cale

NumeTipObligatoriuNote
structuredOutputstringdaThe structured output ID
bash
curl -X DELETE "$CALLAGENT_API_URL/structured-outputs/01JQ0000000000000000000000" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs/01JQ0000000000000000000000`, {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs/01JQ0000000000000000000000');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.delete(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs/01JQ0000000000000000000000",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200Bare JSON object, not data-wrapped

Erori

StatusCând apare
403The key lacks assistant.write
404No such definition in this organization

Exemplu de răspuns, generat din schemă:

json
{
  "deleted": true,
  "id": null
}

Freezes the definition's schema into a new immutable version and returns its id and number ​

POST/structured-outputs/{structuredOutput}/publish
  • Necesită assistant.write.
  • Returns only {version_id, version}, not a full version resource. Optional body field change_summary.

Parametri de cale

NumeTipObligatoriuNote
structuredOutputstringdaThe structured output ID
bash
curl -X POST "$CALLAGENT_API_URL/structured-outputs/01JQ0000000000000000000000/publish" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs/01JQ0000000000000000000000/publish`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs/01JQ0000000000000000000000/publish');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.post(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs/01JQ0000000000000000000000/publish",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
201data-wrapped object

Erori

StatusCând apare
403The key lacks assistant.write
404No such definition in this organization
422The schema fails validation

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "version_id": null,
    "version": 1
  }
}

Returns the built-in starter definitions, each ready to POST back as a new structured output ​

GET/structured-outputs/templates
  • Handler-ul nu impune niciun scope — orice cheie validă îl poate apela.
  • The only route in this group with no policy check at all — any authenticated key of any scope can read it.
bash
curl -X GET "$CALLAGENT_API_URL/structured-outputs/templates" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/structured-outputs/templates`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/structured-outputs/templates');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.get(
    f"{os.environ['CALLAGENT_API_URL']}/structured-outputs/templates",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200data-wrapped object

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "summary": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "sentiment": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "success": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "follow_up": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "lead_qualification": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "customer_fields": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "appointment": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "order_data": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    },
    "compliance": {
      "name": "Support Line",
      "description": "string",
      "target": "string",
      "prompt": "string",
      "schema": {}
    }
  }
}

Scrisă după cod. Ce nu este încă implementat este marcat ca atare, niciodată descris ca funcțional.