Skip to content
Docs
On this page Routes 1/8
Internal — not published

The backend is a JSON REST API. A route checks its input and calls one service; the service runs the queries, scoped to the caller’s workspace, and raises a domain error when something is wrong.

A request through the backend Step 1 of 6

The app calls /api/…. In development the Vite server, and in production the reverse proxy, removes /api before the request reaches the backend, which has no prefix of its own.

Routes

  • Each area has its own path, and nested resources sit under their parent: /customers/:id/contacts, /campaigns/:campaignId/runs.
  • Ids are opaque strings and are not format-checked. An id from another workspace gets the same 404 as one that does not exist.
  • A POST answers 201 by default. Actions that create nothing answer 200, 204 when there is no body, or 202 when the work is queued.
  • Webhooks and tracking links do their own checks; see Channels.

Validation

  • A field the route does not declare is removed before the route sees it, and no error is raised.
  • A request that fails validation gets 400 with the code validation and the messages in details.
  • Route parameters are not checked. An unexpected value reaches the database query.
  • A JSON body may be at most 100 KB.
  • Two inputs are checked by their service, because their shape depends on another field: a template’s content, by template type, and an audience rule, when it is first used.

Pagination

List routes share one set of query parameters:

ParameterDefaultMeaning
page1Page number. Ignored when cursor is set.
limit10Rows per page, kept between 1 and 100
cursorNoneThe nextCursor of the previous page
searchNoneRepeatable field:value. Several fields are combined with OR, each a case-insensitive contains.
sortRoute defaultRepeatable -field (descending) or field (ascending)

Repeat a key for several values: ?search=name:ann&search=jobTitle:cto&sort=-createdAt. The bracket form sort[]= is ignored. Each route lists the fields it lets callers search and sort on, and drops any other. A search field can reach into a relation, such as the company name of a person or the name of one of their tags.

A page of results
{
  "data": [ ... ],
  "pagination": {
    "total": 128,
    "limit": 10,
    "nextPage": 2,
    "nextCursor": "eyJjcmVhdGVkQXQiOnsiX190IjoiRGF0ZSIsInYiOiIuLi4ifSwiaWQiOiIuLi4ifQ.n0aB..."
  }
}

The backend fetches one row more than the limit to know whether a next page exists. nextPage is set only when paging by number. nextCursor holds the last row’s values for every sort field plus its id as a tie-breaker, signed by the server so a client cannot forge one. Dates inside a cursor keep their type, so comparisons stay right across time zones. total is counted with the cursor’s condition, so when paging by cursor it is the number of rows left from that point.

A cursor that fails its signature check answers 500 internal_error, because the check raises an unexpected error instead of a domain error.

Some routes page differently:

RoutePaging
GET /inboxIts own unsigned cursor of last activity time and person; a bad one gives 400
GET /inbox/:threadKeyThe cursor is the id of the oldest message on the previous page
GET /templatesMerges the workspace’s templates with the shipped ones and pages the list in memory
GET /deals/kanban100 deals per stage, no paging
Members, workspaces, invites, the audiences for the Reports filterPlain lists

Errors

Error body
{
  "http_status": 404,
  "code": "customer_not_found",
  "message": "Customer 'ck2x...' not found"
}
CausecodeExtra
A domain errorIts own code, such as invalid_credentials or pool_emptyNone
Failed validationvalidationdetails, the validator messages
Any other HTTP error (an unknown route, a file over the limit)http_errorNone
Anything elseinternal_error, status 500The message is generic; the stack goes to the log

Codes are snake_case and stable. The app branches on the code and shows the message, preferring the first entry in details. A new error is declared once in its module, with a status, a code and a message.

The channel webhooks are outside this error handling. They answer 200 { ok: true }, or 401 { ok: false } when their signature check fails.

File uploads

Uploads are multipart/form-data. A file is held in memory until the route stores it.

UploadFilesSize per fileTypes
Knowledge documents10 by default25 MB by defaultAny; unsupported types fail while the document is read
CSV import10 by default25 MB by defaultCSV
Email image15 MB, fixedJPEG, PNG, GIF, WebP, SVG

A file over the limit gets 413. A message sent from the Inbox attaches Knowledge documents by id, at most 3.

Responses

  • Records come back as JSON with camelCase fields and related records nested. Secrets are masked first.
  • Dates are ISO 8601 strings. Deal amounts are decimals and arrive as strings.
  • Downloads (the people export, an import’s error file, a Knowledge file) set a file name for the browser.
  • The live Inbox stream is server-sent events; see Backend.

Rate limits and API docs

There is no general rate limit, sign-in included. The Ask agent and lead research started by hand limit themselves. A few list routes describe their paging parameters with OpenAPI annotations, and no OpenAPI document is served.

How the app calls the API

The app uses one HTTP client for the API:

  1. Its base address is set when the app is built, and is /api in the example settings.
  2. Each request carries the access token from the browser’s local storage.
  3. On a 401 it runs one shared refresh, stores the new pair and retries the request once. A failed refresh clears both tokens and sends the browser to sign-in.
  4. Sign-in and sign-up use a separate plain client, because a wrong password is also a 401 and must not start the refresh path.

Each feature of the app keeps its own API calls and query hooks, and some reshape the response there; the finished state of a Knowledge document, for example, is renamed to Ready. The app side is on Frontend.

Docs
EN VI