Skip to main content
SONZAI
Api

Habits

List habits for an agent

GET
/agents/{agentId}/habits
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

user_id?string

Optional user ID to scope habits

instance_id?string

Optional instance ID for scoping

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/agents/string/habits"
{
  "$schema": "/api/v1/schemas/HabitsResponse.json",
  "habits": [
    {
      "$schema": "/api/v1/schemas/Habit.json",
      "agent_id": "string",
      "category": "string",
      "created_at": "2019-08-24T14:15:22Z",
      "daily_reinforced": 0.1,
      "description": "string",
      "display_name": "string",
      "formed": true,
      "formed_at": "2019-08-24T14:15:22Z",
      "id": "string",
      "last_reinforced_at": "2019-08-24T14:15:22Z",
      "name": "string",
      "observation_count": 0,
      "strength": 0.1,
      "updated_at": "2019-08-24T14:15:22Z",
      "user_id": "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"
}

Create a habit for an agent

POST
/agents/{agentId}/habits
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

instance_id?string

Optional instance ID for 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/habits" \  -H "Content-Type: application/json" \  -d '{    "name": "string"  }'
{
  "$schema": "/api/v1/schemas/Habit.json",
  "agent_id": "string",
  "category": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "daily_reinforced": 0.1,
  "description": "string",
  "display_name": "string",
  "formed": true,
  "formed_at": "2019-08-24T14:15:22Z",
  "id": "string",
  "last_reinforced_at": "2019-08-24T14:15:22Z",
  "name": "string",
  "observation_count": 0,
  "strength": 0.1,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "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 habit

DELETE
/agents/{agentId}/habits/{habitName}
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

habitName*string

Habit name

Query Parameters

user_id?string

Optional user ID for per-user habits

instance_id?string

Optional instance ID for scoping

Response Body

application/problem+json

curl -X DELETE "https://loading/api/v1/agents/string/habits/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 habit

PUT
/agents/{agentId}/habits/{habitName}
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

habitName*string

Habit name

Query Parameters

instance_id?string

Optional instance ID for 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/habits/string" \  -H "Content-Type: application/json" \  -d '{}'
{
  "$schema": "/api/v1/schemas/Habit.json",
  "agent_id": "string",
  "category": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "daily_reinforced": 0.1,
  "description": "string",
  "display_name": "string",
  "formed": true,
  "formed_at": "2019-08-24T14:15:22Z",
  "id": "string",
  "last_reinforced_at": "2019-08-24T14:15:22Z",
  "name": "string",
  "observation_count": 0,
  "strength": 0.1,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "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"
}