Paths and names
Every path is underhttps://sonar.turtle.xyz/v1/organization/{organizationId}, and these pages write paths relative to it.
The API keeps a few names of its own:
Reading
- Lists answer
{"<entities>": [...], "nextCursor": "…"}:GET /contactsanswers{"contacts": [...]}. A single read answers{"<entity>": {...}}, with its relations as sibling keys, and returns at least what its listing returns. - Paging.
limitis 1 to 100, default 25. PassnextCursorback ascursor; nonextCursormeans the last page. Every ordering ends on the ID, so a tie at a page boundary never skips or repeats a row. A few small catalogs are not paged, such as pipelines, rules, entity cards and templates. - Sorting. Listings share
sortnames where they mean the same thing:created(newest first, the usual default),recent(latest activity first) andstale(longest silence first). Some add their own, such asrevenueon/engagements, and/eventssorts byingestedoroccurred. A listing refuses a sort it does not take. - Filters. Repeat a parameter to OR its values (
?stage=a&stage=b, at most 100 values). Different parameters AND together. Instants are RFC 3339 and days areYYYY-MM-DD. No listing requires a filter. - Unknown parameters are refused. A query parameter the endpoint does not take answers
400and names it, so a misspelled filter never reads as no filter. searchkeeps the rows holding every word of it, in any order, case-insensitive.updatedAfterreturns only the rows changed after that instant. It is how you sync organizations, contacts, threads, deals, tasks, documents, wallets and reports.count=truealso answerstotal: how many rows match, across every page.drafts=trueattaches the open proposals on each row, aspresentandfuture, on the reads that take it.- References. A related record comes as a small ref beside its ID:
counterpartyIdnext tocounterparty: {id, name}. An ID with no ref beside it means the record is gone or has no name, not an error. - Derived fields say Derived in their description, and are read-only.
Following events
Events never change, so/events takes no updatedAfter. To follow new events as they arrive, read the listing as a poll:
- Start with
GET /events?poll=true&since=<instant>. A poll reads oldest first. - Pass each page’s
nextCursorback ascursoron the next call. - An empty page means you are caught up: keep the cursor you sent, and poll again later.
Writing
Who a write is recorded as
A write is recorded as whoever the key acts for:- A personal key writes as you. The write applies at once, and
rationaleandevidenceare optional, as in the dashboard. - A personal key with
"source": "ai"writes as your agent, with you as its user. - An organization key writes as an agent.
Rationale and evidence
An agent write carries arationale (one or two sentences) and evidence, the events it rests on:
- At least one citation supports the write with a verbatim quote from the event it cites, or is a teammate’s message, cited as
{messageId, quotes}instead ofeventId. stanceissupports(the default) orretracts, which takes back an event an earlier write cited and needs no quote.- An agent’s write to a deal may cite in support only events a thread already holds, so thread them first.
- A DELETE has no body: it takes
?rationale=&evidence=, with the same array as URL-encoded JSON.
The response
Every write answers{applied, entityId, mutation?, draft?}:
applied: true: the write landed, andmutationis its row in the log.applied: falsewith adraft: it is held for a person. The draft is the row the log will hold if it is approved.applied: falsewith no draft: nothing needed to change, andentityIdis the existing record.
Held writes and drafts
- An agent’s held writes. Any delete, merge or split, and a board or card change that rewrites records, waits for a person. The exception is deleting a record an agent created that nobody has touched since, which never applies to a deal. Every other agent write applies, and your workspace can hold or free others with permission policies.
- Your own writes are never held by those permissions.
- Holding a write yourself. Send
"draft": true(?draft=trueon a DELETE) to hold any write: an agent’s waits for a person to approve it, and your own waits for you to confirm it. Sending the same proposal again returns the same draft. - Deciding.
POST /mutations/{id}/approvemakes a draft, optionally withamend(your own values for some of its fields) and areason.POST /mutations/{id}/rejectdeclines it.POST /reports/{id}/decidedecides a report’s drafts together. Deciding takes an owner or admin (see Authentication). - Undo.
POST /mutations/{id}/reverttakes an applied write back as a new write, andGETon the same path shows what it would do first. An agent’s undo is itself a draft.
Updating, merging and retrying
- Patching. A PUT changes only the keys you send. Custom
fieldsmerge key by key: a key you leave out keeps its value, a key you send replaces it (a list is replaced whole), andnull,""or[]clears it. - Custom fields take only the keys the record’s card declares. A deal’s card is its board’s (
GET /pipelines/{id}); every other kind’s is inGET /entity-cards. An unknown or derived key is refused by name. - Merging.
POST /{entities}/{id}/mergewith{"absorbedId": "<uuid>"}moves everything on the absorbed record onto{id}, and deletes the absorbed one. Organizations, contacts, deals and threads merge. - Idempotent writes. A PUT means “make it so”, and deleting a link that is already gone changes nothing. A write that changes nothing answers
applied: falseand logs nothing. A deleted record keeps its history but leaves reads, so deleting it again is a404. - Retrying a create. Most creates resolve to an existing record when there is one: organizations by name, contacts by address, documents by counterparty and name, wallets by address, and open tasks by deal and description. A deal or a thread is new on every create, so check before you retry one.
Errors
An endpoint answers an error as JSON, with the status text and a message saying why:code (an application error code) and context. A request refused before it reaches an endpoint (no usable key, a key that may not reach the organization, a path the API does not have) gets a plain-text body instead.
Each endpoint’s page in the API reference lists the statuses it can return.
Limits
- Page size is 1 to 100, default 25.
- A repeatable filter takes at most 100 values, and some take fewer (the reference gives each one’s limit). Past that it is refused with
400, never cut short. - Long texts, such as descriptions, have a size budget. A write reports it back in
budgets, and it is never enforced. - Inbound webhooks take 100 deliveries a day each, with a body of at most 64 KB. See Inbound webhooks.
Versioning and deprecation
v1 is stable. Within v1, changes are additive only:- new operations, and new optional query parameters or request fields;
- new response fields;
- new values in a response enum.
/v2.
An operation is retired in steps. First it is marked deprecated in the spec, and every answer it gives carries three headers:
Watch for the
Deprecation header: it is the notice.
The spec at https://sonar.turtle.xyz/v1/openapi.json is the contract: the API serves exactly the operations it lists. The Sonar dashboard also reads two views that v1 does not carry, its overview’s activity cards and its pipeline history, because they are shaped after a screen and change with it.
