Errors and retries
Interpret failures and retry without duplicating mutations.
Use HTTP status, the returned error body, and the operation's state model together. REST, streaming, and MCP use different envelopes; do not assume every error has the same JSON shape. The TypeScript SDK exposes ordinary HTTP failures as MotifSDKError with statusCode and response when available.
400
Invalid shape, unsupported combination, timestamp, or domain input
Correct the input; keep the body for diagnosis without logging secrets
401
Missing, invalid, expired, or rejected credentials; key verification may also reject exhausted limits
Check key/environment and returned message
403
Inactive organization, insufficient scope, role, origin, or resource access
Correct authorization; do not retry unchanged
404
Missing or inaccessible resource
Check identifier type, organization, and existence
409
Conflicting revision or state
Read current state and reconcile
429
Request throttling where returned
Honor retry guidance and back off
5xx, timeout, network loss
Server/transport failure; commit outcome can be unknown
Reconcile state, then retry according to the operation
SSE RUN_ERROR
Turn failed after the stream opened
Mark failure even if the initial HTTP status was 200
MCP tool error
Consent, validation, access, or execution failure
Inspect the structured MCP result; refresh discovery if access changed
Exact codes can vary by validation layer. A returned message is diagnostic information, not a stable machine-readable enum unless the specific contract defines it.
Retry by operation
For native snapshots, reuse the same revision and identical payload after an uncertain result. A changed payload at the same revision is a conflict; a real update needs a higher revision. Send the full desired account state each time.
For prices, keep a stable effective timestamp and revision for a retry. A correction at that timestamp requires a higher revision. For broker events, keep the same source and event id when resending identical content.
Creating users, issuing credentials, rotating webhook secrets, appending research-context trades, and generating a new chat turn do not share snapshot idempotency. Read or reconcile existing state before repeating them. Credential issuance may rotate access even if the response was lost.
Reads can generally use bounded exponential backoff with jitter after transient failures. Cache research with its authored time and freshness state. A null research result or pending calculation is a valid state, not an invitation to create a tight polling loop.
Operational diagnosis
Record your operation, external account reference, revision/event ID, timestamp, environment, HTTP status, and any returned correlation identifier. Never log API keys, tokens, signing secrets, or unrestricted private documents. Use the integration checklist to test retry and reconciliation behavior before rollout.
Last updated