Custom States
List custom states
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Query Parameters
Filter by scope (global, user)
Filter by user ID
Filter by instance ID
Filter by key name
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/agents/string/custom-states"{
"$schema": "/api/v1/schemas/ListCustomStatesOutputBody.json",
"states": [
{
"$schema": "/api/v1/schemas/CustomState.json",
"agent_id": "string",
"content_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"instance_id": "string",
"key": "string",
"scope": "string",
"state_id": "string",
"updated_at": "2019-08-24T14:15:22Z",
"user_id": "string",
"value": null
}
]
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Create a custom state
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://loading/api/v1/agents/string/custom-states" \ -H "Content-Type: application/json" \ -d '{ "key": "string", "value": null }'{
"$schema": "/api/v1/schemas/CustomState.json",
"agent_id": "string",
"content_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"instance_id": "string",
"key": "string",
"scope": "string",
"state_id": "string",
"updated_at": "2019-08-24T14:15:22Z",
"user_id": "string",
"value": null
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Get a custom state by key
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Query Parameters
State key to look up
Scope (global or user, defaults to global)
User ID for user-scoped states
Instance ID
Response Body
application/json
application/problem+json
curl -X GET "https://loading/api/v1/agents/string/custom-states/by-key?key=string"{
"$schema": "/api/v1/schemas/CustomState.json",
"agent_id": "string",
"content_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"instance_id": "string",
"key": "string",
"scope": "string",
"state_id": "string",
"updated_at": "2019-08-24T14:15:22Z",
"user_id": "string",
"value": null
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Delete a custom state by key
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Query Parameters
State key to delete
Scope (global or user, defaults to global)
User ID for user-scoped states
Instance ID
Response Body
application/problem+json
curl -X DELETE "https://loading/api/v1/agents/string/custom-states/by-key?key=string"{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Upsert a custom state by key
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X PUT "https://loading/api/v1/agents/string/custom-states/by-key" \ -H "Content-Type: application/json" \ -d '{ "key": "string", "value": null }'{
"$schema": "/api/v1/schemas/CustomState.json",
"agent_id": "string",
"content_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"instance_id": "string",
"key": "string",
"scope": "string",
"state_id": "string",
"updated_at": "2019-08-24T14:15:22Z",
"user_id": "string",
"value": null
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Delete a custom state
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Custom state UUID
Response Body
application/problem+json
curl -X DELETE "https://loading/api/v1/agents/string/custom-states/string"{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Update a custom state
API key issued to a Sonzai project. Format: Bearer sk_....
In: header
Path Parameters
Agent UUID or URL-encoded agent name
Custom state UUID
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X PUT "https://loading/api/v1/agents/string/custom-states/string" \ -H "Content-Type: application/json" \ -d '{ "value": null }'{
"$schema": "/api/v1/schemas/CustomState.json",
"agent_id": "string",
"content_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"instance_id": "string",
"key": "string",
"scope": "string",
"state_id": "string",
"updated_at": "2019-08-24T14:15:22Z",
"user_id": "string",
"value": null
}{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "string",
"message": "string",
"value": null
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}