Before you start
- A key with
markets:write. Every route on this page needs it, the reads included:markets:readdoes not open a conversation’s transcript.markets:writeis never granted by default. Ask ZeroID to add it to your key. See Authentication. - The user. A user key acts for its own user. A partner key names the user’s account in the
Kash-Accountheader on every call, and a user key that sendsKash-Accountis refused with400 ACCOUNT_HEADER_NOT_ALLOWED. See For partners. - Conversation ids. Send them in lower case, as the API returns them. The API matches the lower-case form only, so an upper-case copy of a real id answers
404 MARKET_CONVERSATION_NOT_FOUND. The SDK lower-cases them for you.
How a conversation runs
1
Start a conversation
POST /v1/market-conversations returns 201 with the conversation’s id. Nothing reaches the assistant until the first message.2
Send the user's message
POST /v1/market-conversations/{conversationId}/messages queues the message and returns 202 with the message’s id. The assistant’s reply arrives in the transcript.3
Wait for the reply
Read the state until the assistant is
idle. See Read the state.4
Read what is new
Read the transcript from the
after position you kept last time, and keep the new after for the next read.Start a conversation
The body is empty or{}.
409 ACCOUNT_NOT_ACTIVE).
Send a message
Any other field is refused with
400 VALIDATION_FAILED.
id: it tells you when your message has been answered. A message sent while an earlier one is still being answered is queued behind it.
Read the state
Your message has been answered when
status is idle and latestMessage is your message and not failed. Then read the transcript after the position you hold: the reply is the assistant turn written after your message. A message the assistant has answered can still read pending, so go by status rather than waiting for published. If the reply is not in the transcript yet, read again a moment later. Two other cases:
latestMessage.statusisfailed. No reply will come. Send the message again with a newIdempotency-Key.latestMessage.idis not your message’sid. A later message has been sent to the same conversation, for example by another process of yours. Read the transcript rather than waiting for your own message.
Read the transcript
after to read from the start. limit is 1 to 100, default 50.
pagination.after works differently from the cursor on other lists:
- It is always the position after the last turn you have seen. Pass it as
afterto read only what follows. - On a page with no turns it repeats the
afteryou sent, even whenhasMoreisfalse. Keep it: it is where your next read starts. - It is
nullonly when you sent noafterand the page has no turns: before the conversation has any turn, or while the assistant is writing one.nullmeans read from the start, so omitafternext time. - A reply the assistant rewrites after you read it comes back after your position with a higher
revision. Keep one entry perturnNumber, the one with the highestrevision. - An
afterthat is malformed or from another list is refused with400 VALIDATION_FAILED.
List conversations
id and createdAt. Cursor-paginated like other lists (limit 1 to 100, default 20): see Pagination.
Who can see a conversation
A conversation belongs to the kind of key that started it:- a user key sees the conversations user keys started for its user;
- a partner key sees those its organisation started for the
Kash-Accountuser.
404 MARKET_CONVERSATION_NOT_FOUND, with the same body in every case. A new key of the same user or organisation sees the same conversations: rotating a key does not lose them.
Retries and idempotency
Send anIdempotency-Key on both POST routes, one per start and one per message:
- A retry with the same key and body returns the stored answer instead of running again: the
201conversation, the202message, or the422 MARKET_CONTENT_REFUSEDrefusal. The response carries the headerIdempotent-Replay: true. On these two routes_meta.idempotentis alwaysfalse, so read the header to tell a replay. - Without a key, a retry may start a second conversation or send the message twice.
- The same key with a different body is refused with
409 IDEMPOTENCY_KEY_CONFLICT. - A retry that waits more than 2 seconds for the first request to finish answers
409 IDEMPOTENCY_REQUEST_IN_PROGRESSwithRetry-After: 1. Retry with the same key. - Any other error stores nothing. A retry with the same key after it is judged afresh.
- A
503 DEPENDENCY_UNAVAILABLEwhosedetailsays the request may still take effect: retry with the same key. If the write happened, the retry returns it; if not, it runs once.
Limits
- Creation requests per minute. Starts and messages together are limited to 20 a minute per user, across every key acting for that user. For a partner key the user is the account in
Kash-Account. This is on top of your key’s own request rate. Past it the request is refused with429 RATE_LIMIT_EXCEEDEDand aRetry-Afterheader. A replay counts against it too. - Daily limits. Starting conversations and sending messages are each limited per user and per key each day, counted from 00:00 UTC. At a limit the request is refused with
429 MARKET_CREATION_DAILY_LIMIT_REACHEDand nothing is written.Retry-Afteris the number of seconds until 00:00 UTC. A user’s messages count whether they were sent through the API or in the Kash app. A user’s daily limits are shared between their own key and the partner acting for them. The limits depend on your key’s tier; they are set by Kash and are not published. A replay is never refused and never counted again. - Daily AI drafting budget. When today’s budget for your key, or for market creation through the API, is used up, a message is not refused: it is accepted with
202, and the assistant’s reply in the transcript says so. It reads “This API key has used today’s AI drafting budget. It resets at 00:00 UTC.” or “Market creation through the API has used today’s AI drafting budget. It resets at 00:00 UTC.”
Content rules
A message that breaks Kash’s market content rules is refused with422 MARKET_CONTENT_REFUSED. Nothing is sent and nothing counts against your daily limits. The body’s reason names the rule and detail explains it in words you can show the user:
detail and ask them to rephrase. Do not retry automatically: the same text is refused again. See MARKET_CONTENT_REFUSED for every reason.
For partners
SendKash-Account: <accountId> on every market conversation call, reads included:
- A partner key without the header is refused with
400 ACCOUNT_HEADER_REQUIRED. - A conversation is visible only with the same
Kash-Accountthat started it. - A suspended account can still read its conversations, but cannot start one or send a message (
409 ACCOUNT_NOT_ACTIVE). - The per-minute creation limit counts each account on its own. The daily limits count each account, and your key across all its accounts. A user’s daily limits are shared between their own key and the partner acting for them.
With the SDK
@kashdao/sdk wraps these routes as kash.marketConversations, from version 0.5.0. The SDK keys both writes, so its own retries never start a second conversation or send a message twice. waitForReply polls the state for you and returns the new turns:
What the API does not do yet
The API stops at the draft. It holds the conversation and reports when the assistant has a draft ready, but it does not yet:- submit the draft as a market request, or read or change a market request;
- generate or read the cover image, or quote the market creation fee;
- send webhooks about a conversation, so read the state to follow it.
Errors
Next
TypeScript SDK
kash.marketConversations and waitForReply.Rate limits
The creation limit and the daily limits.