Create a decision corpus of a question set
POST /v1/agents/{agent_id}/decision-corpora
| Property | Value |
|---|---|
| Operation | create_decision_corpus |
| Group | Decision corpora |
| Scope | agents:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited decision_corpus.create (mutation) |
| Released in | 1.58.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates an empty corpus of one question set of the Agent draft's decision at version 1 (1.58.0); a set the draft does not declare is decision_question_set_unknown.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the agents:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/agents/agt_.../decision-corpora" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "question_set": "routing", "name": "<name>" }'const response = await fetch(`${process.env.VOCAL_API}/v1/agents/agt_.../decision-corpora`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"question_set": "routing",
"name": "<name>"
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/agents/agt_.../decision-corpora",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"question_set": "routing",
"name": "<name>",
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | AgentId | yes | The id of an Agent: agt_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log. |
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: DecisionCorpusCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
description | string | no | |
name | string | yes | |
question_set | QuestionSetKey | yes | A question set of the Agent draft's decision (decision_question_set_unknown). |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | DecisionCorpus | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is DecisionCorpus.
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | AgentId | yes | |
archived_at | Timestamp or null | yes | |
case_count | integer | yes | |
created_at | Timestamp | yes | |
description | string or null | yes | |
id | DecisionCorpusId | yes | |
name | string | yes | |
object | "decision_corpus" | yes | |
question_set | QuestionSetKey | yes | |
revision | integer | yes | The ETag; required in If-Match. |
updated_at | Timestamp | yes | |
version | integer | yes | Rises by one with each case added or deleted; a run records the version it read. |