Skip to main content
SONZAI
Api

Custom States

List custom states

GET
/agents/{agentId}/custom-states
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Query Parameters

scope?string

Filter by scope (global, user)

user_id?string

Filter by user ID

instance_id?string

Filter by instance ID

key?string

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

POST
/agents/{agentId}/custom-states
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

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

GET
/agents/{agentId}/custom-states/by-key
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Query Parameters

key*string

State key to look up

scope?string

Scope (global or user, defaults to global)

user_id?string

User ID for user-scoped states

instance_id?string

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

DELETE
/agents/{agentId}/custom-states/by-key
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Query Parameters

key*string

State key to delete

scope?string

Scope (global or user, defaults to global)

user_id?string

User ID for user-scoped states

instance_id?string

Instance ID

Response Body

application/problem+json

curl -X DELETE "https://loading/api/v1/agents/string/custom-states/by-key?key=string"
Empty
{
  "$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

PUT
/agents/{agentId}/custom-states/by-key
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

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

DELETE
/agents/{agentId}/custom-states/{stateId}
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

stateId*string

Custom state UUID

Response Body

application/problem+json

curl -X DELETE "https://loading/api/v1/agents/string/custom-states/string"
Empty
{
  "$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

PUT
/agents/{agentId}/custom-states/{stateId}
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

stateId*string

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"
}