LeveredDocs
API Reference

Models

Endpoints for listing, training and deleting bandit models.

All endpoints are under /api/v2/models. All requests require an Authorization: Bearer <token> header.

List models

GET /api/v2/models

Auth: Required

Returns the organization's models, excluding archived ones. Accepts the same limit (1-100, default 10), order_by and include_archived query parameters as List optimizations.

Response:

{
  "models": [
    {
      "id": "4754cae0-9a5d-4691-91af-6d15ccc1f82e",
      "status": "trained",
      "training_data_config": {
        "design_factors": [...],
        "context_factors": [...],
        "reward": { "name": "signup", "type": "bool" },
        "attribution": { "type": "last_touch", "conversion_window_hours": 24 }
      },
      "created_at": "2026-01-15T10:30:00Z",
      "updated_at": "2026-03-28T12:00:00Z"
    }
  ],
  "meta": {
    "request_id": "req_abc123",
    "organization_id": "org_xyz"
  }
}

Train model

POST /api/v2/models/:id/train

Auth: Required

Starts a training run in the background and returns 202 at once. The run pulls the latest observation data from your warehouse, updates the model's posterior and publishes it for posterior queries. The model's status is training until the run finishes, then trained or failed (see List models). If a run is already in progress, it returns 202 with message, training_started_at and training_elapsed_seconds, and no second run starts. Returns 409 if the optimization has ended.

Path parameters:

ParameterTypeDescription
idstring (UUID)Model ID

Response (202):

202 Accepted:

{
  "model_id": "4754cae0-9a5d-4691-91af-6d15ccc1f82e",
  "status": "training",
  "message": "Training started",
  "meta": {
    "request_id": "req_abc123",
    "organization_id": "org_xyz"
  }
}

Delete model

DELETE /api/v2/models/:id

Auth: Required

Archives the model. List models then hides it unless include_archived is set. The parent optimization is kept and stays linked to the model.

Path parameters:

ParameterTypeDescription
idstring (UUID)Model ID

Response:

{
  "id": "4754cae0-9a5d-4691-91af-6d15ccc1f82e",
  "status": "archived",
  "meta": {
    "request_id": "req_abc123",
    "organization_id": "org_xyz"
  }
}