# Using the API

Source: https://developers.krans.ai/docs/using-the-api

## Requests and responses

- JSON in and out, UTF-8. Field names are `snake_case`. Ids are UUIDs. Times are RFC 3339 in UTC (`2026-10-14T09:30:00Z`). Booleans are `true`/`false`, numbers are never strings; date-only parameters are `YYYY-MM-DD`.

- A successful response is the object itself, with no wrapper. Venture-scoped responses start with `_venture: { id, was_specified }`; conversation-scoped ones add `_conversation: { id }`.

- **Ventures.** List and search endpoints take `venture_id`. It is required when your key covers more than one venture (`venture_required`). Endpoints that address one record (`/contacts/{id}`) use that record's venture.

- **Records in other workspaces read as `not_found`**, never as forbidden, so ids cannot be probed.

- **Merged records redirect.** Reading a merged contact or account returns the survivor and adds `merged_from_contact_id` / `merged_from_account_id`.

- **Deletes are soft.** Deleted records disappear from every endpoint; a workspace admin can restore them.

- **Partial updates.** `PATCH` changes only the fields you send. It never deletes; deleting has its own `DELETE` endpoint.

- **Sync and batch reads.** The main lists (conversations, contacts, accounts, threads, signals) take `updated_since`, `sort_by` (`created_at` or `updated_at`), `sort_direction` and `ids` (up to 100). To mirror data, store the newest `updated_at` you saw and ask for `updated_since` next time instead of re-reading everything.

- **Search queries** are at most 500 characters; other text fields have their own limits, listed in the reference. Every response carries an `X-Request-Id` header; quote it to support.

- **Retries.** `GET`, `PUT`, `PATCH` and `DELETE` are safe to retry. `POST` is not idempotent in v1: after a timeout, read the record before sending again.

## Pagination

Lists are cursor-paginated. Send `limit` and leave `cursor` out for the first page. The default and maximum are per endpoint and listed in the reference: most lists default to 20 or 25 and go up to 100; contacts and accounts go up to 500. Each page returns `next_cursor`; pass it as `cursor` until it is `null`. Cursors are opaque and do not expire. A cursor is a position in the list, so records added or deleted while you page can shift what comes next; to mirror data, use `updated_since` (see [Requests and responses](#conventions)).

Responses also carry `total`, `limit`, `offset` and `has_more`. `offset` works too; a `cursor` overrides it. Sub-lists inside a record (a contact's calls, an account's threads) are capped and come with their real total, e.g. `calls` plus `total_calls`.

## Errors

Errors use the HTTP status and a stable `code`. Branch on `code`, show `message`.

```
HTTP/1.1 403 Forbidden
{
  "error": {
    "code": "insufficient_scope",
    "message": "This endpoint needs contacts:write.",
    "details": { "required": "contacts:write" },
    "request_id": "req_7f3a9c"
  }
}
```

| Code | Status | Meaning |
| --- | --- | --- |
| `validation_failed` | 422 | A parameter or body field is missing or invalid. details[] names each field. |
| `venture_required` | 422 | The key covers several ventures and venture_id was not sent. |
| `unauthorized` | 401 | Missing, malformed, expired or revoked key. |
| `insufficient_scope` | 403 | The key lacks the scope or flag the endpoint needs. details.required names it. |
| `forbidden` | 403 | You are not a member of this venture any more, or the record belongs to another venture. |
| `workspace_read_only` | 403 | The workspace is read-only or deactivated, so writes are refused. |
| `context_not_enabled` | 403 | The venture does not have /context enabled. |
| `stage_editing_disabled` | 403 | Stage editing is not enabled for this workspace. |
| `not_found` | 404 | No such record in your ventures. Records in other workspaces also read as not found. |
| `no_claim` | 400 | The participant slot has no suggestion to approve. |
| `conflict` | 409 | The change clashes with the current state, e.g. the same file was already uploaded or a merge target is gone. |
| `email_taken` | 409 | Another live contact in the venture has this email. |
| `domain_taken` | 409 | Another account in the venture has this domain. |
| `method_not_allowed` | 405 | The path exists but not with this method. details.allowed lists the ones it takes. |
| `rate_limited` | 429 | Over the key's rate limit. Wait Retry-After seconds. |
| `internal` | 500 | Something failed on our side. The message never contains internals; send request_id to support. |
| `unavailable` | 503 | Access could not be checked right now. Retry after Retry-After seconds. |

## Rate limits

Limits are per key (for MCP, per person), not per workspace, so one busy integration cannot slow down another. Every request counts once, reads and writes alike. There is no daily cap.

| What | Limit |
| --- | --- |

| All endpoints | 200 requests per 2-second window |

| Search and review reads: searching conversations, contacts and accounts, `GET /review/items/{item_id}` and account evidence | 20 per 2 seconds, and they count toward the total too |

| `POST /uploads` | 30 per minute |

Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (seconds until the window resets). Over the limit you get `429 rate_limited` with `Retry-After`. Need more than this for a backfill? Use the largest `limit` and `updated_since` first; they cut calls far more than a higher limit would.

## Transcripts and quotes

Verbatim call text is behind the `transcripts` flag. Without it, `GET /conversations/{id}/transcript` fails with `insufficient_scope`, and every other endpoint removes quote fields (`quote`, `quote_text`, excerpts from calls, budget quotes) and adds a `quotes_note` when it removed something. Summaries, learnings and metadata are unaffected.

## Versioning

The version is in the path (`/v1`). Within v1 we only add: new endpoints, new optional parameters, new response fields and new error codes. Handle unknown fields and codes gracefully. Removals and renames go into v2. v1 then keeps running next to it for at least 12 months, and we announce the date it stops.
