Documentation
REST API v1
The REST API gives scripts and integrations the same scoped access as the connector. It accepts only API tokens; OAuth tokens work only on the MCP endpoint.
Basics
- Base URL:
https://app.leitvik.com/api/v1 - Header:
Authorization: Bearer qre_…. Requests and responses are JSON. - Rate limit: the token's own limit per minute (60 by default, 1 to 600), shared with the connector. Over it the answer is
429withRetry-After. - Lists default to 50 items and cap at 100, with
limitandoffset; a largerlimitis400with reasoninvalid_pagination. Responses includehasMoreandtotal. ?domain=on companies and leads finds the exact domain (normalised, withoutwww.), the reliable way to check for duplicates before adding a lead.- The OpenAPI 3.1 description is public at
/api/v1/openapi.json. An unknown path is404with reasonunknown_routeand links to these docs. - Dates use the workspace timezone.
First request
curl -s "https://app.leitvik.com/api/v1/context" \
-H "authorization: Bearer $LEITVIK_TOKEN"Idempotent writes
Record writes accept a requestId (UUID) in the body or an Idempotency-Key header. For 24 hours a repeat with the same key and content returns the first result without writing again; the same key with different content is 409. Task, opportunity and capture writes require their own requestId.
Versions
Tasks and opportunities carry a version. Send the current one with every change; a stale version is 409, so read again and decide again.
Endpoints
| Method | Path | Scope |
|---|---|---|
GET | /api/v1/context | Any scope |
GET | /api/v1/companies?q=&domain=&limit=&offset= | companies:read |
GET | /api/v1/companies/{id} | companies:read |
POST | /api/v1/companies | companies:create |
PUT | /api/v1/companies | companies:write |
GET | /api/v1/companies/{id}/brief | companies:readleads:readtouches:readsignals:read |
GET | /api/v1/contacts?companyId= | contacts:read |
PUT | /api/v1/contacts | contacts:write |
GET | /api/v1/leads?q=&domain=&status= | leads:read |
GET | /api/v1/leads/{id} | leads:read |
PATCH | /api/v1/leads/{id} | leads:write |
GET | /api/v1/touches?companyId= | touches:read |
POST | /api/v1/touches | touches:write |
GET | /api/v1/signals?companyId= | signals:read |
POST | /api/v1/signals | signals:write |
GET | /api/v1/dossiers?companyId= | dossiers:read |
PUT | /api/v1/dossiers | dossiers:write |
GET | /api/v1/today?limit=&offset= | leads:read |
GET | /api/v1/tasks?status=&due=&owner=&companyId= | tasks:read |
GET | /api/v1/tasks/{id} | tasks:read |
POST | /api/v1/tasks | tasks:write |
PATCH | /api/v1/tasks/{id} | tasks:write |
POST | /api/v1/captures | captures:write |
POST | /api/v1/captures/{id}/apply | captures:write |
POST | /api/v1/captures/{id}/undo | captures:write |
POST | /api/v1/captures/{id}/discard | captures:write |
GET | /api/v1/activities | activities:read |
GET | /api/v1/outbound/review-queue | outbound:read |
POST | /api/v1/outbound/review-verdicts | outbound:review |
POST | /api/v1/outbound/owner-approvals | outbound:owner_approve |
GET | /api/v1/outbound/send-status | outbound:breaker_read |
POST | /api/v1/outbound/breaker-reset | outbound:breaker_reset |
PATCH | /api/v1/outbound/workspace-config | outbound:write |
POST | /api/v1/outbound/workspace-config/signature-template/approve | outbound:template_approve |
GET | /api/v1/outbound/messages/{id}/preview | outbound:read |
GET | /api/v1/outbound/messages/{id} | outbound:read |
POST | /api/v1/outbound/messages | outbound:write |
PATCH | /api/v1/outbound/messages/{id} | outbound:write |
POST | /api/v1/outbound/messages/{id}/outcomes | outbound:write |
POST | /api/v1/outbound/messages/{id}/transitions | outbound:write |
Errors
Error bodies are { "error": code }, often with a stable reason and a message that says how to recover. They never include stack traces, SQL or your input.
| Status | Code | Meaning |
|---|---|---|
| 400 | validation | Invalid input. |
| 401 | unauthorized | Missing, expired or revoked token, or missing scope. |
| 403 | forbidden | The token cannot do it. |
| 404 | not_found | Not in this workspace. |
| 409 | conflict | Stale version, invalid transition, or reused key with different content. |
| 413 | too_large | Body over the limit. |
| 429 | rate_limited | Too many requests; wait Retry-After seconds. |