Skip to main content
SONZAI
Api

Inventory

Query user inventory

GET
/agents/{agentId}/users/{userId}/inventory
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

userId*string

User ID

Query Parameters

instance_id?string

Optional instance ID for user scoping

mode?string

Query mode: list, value, or aggregate

Default"list"
item_type?string

Filter by item type

query?string

Free-text search filter

project_id?string

KB project scope for value/aggregate modes

aggregations?string

Comma-separated aggregation expressions (for aggregate mode)

group_by?string

Group-by field for aggregations

limit?integer

Max items per page (default 1000, max 5000)

Default1000
Formatint64
offset?integer

Pagination offset

Default0
Formatint64
cursor?string

Base64-encoded pagination cursor

filters?string

JSON-encoded metadata filters

sort_by?string

Sort by metadata field

sort_order?string

Sort order: asc or desc

Default"asc"

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/agents/string/users/string/inventory"
{
  "$schema": "/api/v1/schemas/InventoryReadResponse.json",
  "groups": [
    {
      "group": "string",
      "values": {
        "property1": null,
        "property2": null
      }
    }
  ],
  "items": [
    {
      "fact_id": "string",
      "gain_loss": 0.1,
      "inventory_item_id": "string",
      "item_label": "string",
      "kb_node_id": "string",
      "market_properties": {
        "property1": null,
        "property2": null
      },
      "user_properties": {
        "property1": null,
        "property2": null
      }
    }
  ],
  "next_cursor": "string",
  "total_items": 0,
  "totals": {
    "property1": null,
    "property2": 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"
}

Add, update, or remove an inventory item

POST
/agents/{agentId}/users/{userId}/inventory
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

userId*string

User ID

Query Parameters

instance_id?string

Optional instance ID for user scoping

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/users/string/inventory" \  -H "Content-Type: application/json" \  -d '{    "action": "string",    "item_type": "string"  }'
{
  "$schema": "/api/v1/schemas/InventoryWriteResponse.json",
  "candidates": [
    {
      "kb_node_id": "string",
      "label": "string",
      "properties": {
        "property1": null,
        "property2": null
      }
    }
  ],
  "error": "string",
  "fact_id": "string",
  "inventory_item_id": "string",
  "kb_resolution": {
    "kb_label": "string",
    "kb_node_id": "string",
    "kb_properties": {
      "property1": null,
      "property2": null
    },
    "resolved": true
  },
  "status": "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"
}

Batch import inventory items

POST
/agents/{agentId}/users/{userId}/inventory/batch
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

userId*string

User ID

Query Parameters

instance_id?string

Optional instance ID for user scoping

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/users/string/inventory/batch" \  -H "Content-Type: application/json" \  -d '{    "items": [      {        "item_type": "string"      }    ]  }'
{
  "$schema": "/api/v1/schemas/BatchInventoryResponse.json",
  "added": 0,
  "error": "string",
  "failed": 0,
  "status": "string",
  "total": 0
}
{
  "$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 an inventory item (dedicated add endpoint)

POST
/agents/{agentId}/users/{userId}/inventory/items
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

userId*string

User ID

Query Parameters

instance_id?string

Optional instance ID for user scoping

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/users/string/inventory/items" \  -H "Content-Type: application/json" \  -d '{    "item_type": "string"  }'
{
  "$schema": "/api/v1/schemas/InventoryWriteResponse.json",
  "candidates": [
    {
      "kb_node_id": "string",
      "label": "string",
      "properties": {
        "property1": null,
        "property2": null
      }
    }
  ],
  "error": "string",
  "fact_id": "string",
  "inventory_item_id": "string",
  "kb_resolution": {
    "kb_label": "string",
    "kb_node_id": "string",
    "kb_properties": {
      "property1": null,
      "property2": null
    },
    "resolved": true
  },
  "status": "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"
}

Delete a specific inventory fact

DELETE
/agents/{agentId}/users/{userId}/inventory/{factId}
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

userId*string

User ID

factId*string

Inventory fact UUID

Query Parameters

instance_id?string

Optional instance ID for user scoping

Response Body

application/json

application/problem+json

curl -X DELETE "https://loading/api/v1/agents/string/users/string/inventory/string"
{
  "$schema": "/api/v1/schemas/DirectUpdateResponse.json",
  "error": "string",
  "fact_id": "string",
  "inventory_item_id": "string",
  "status": "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 specific inventory fact

PUT
/agents/{agentId}/users/{userId}/inventory/{factId}
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

userId*string

User ID

factId*string

Inventory fact UUID

Query Parameters

instance_id?string

Optional instance ID for user scoping

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/users/string/inventory/string" \  -H "Content-Type: application/json" \  -d '{    "properties": {      "property1": null,      "property2": null    }  }'
{
  "$schema": "/api/v1/schemas/DirectUpdateResponse.json",
  "error": "string",
  "fact_id": "string",
  "inventory_item_id": "string",
  "status": "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"
}