Skip to main content

Overview

An HTTP API for quoting swaps on Charisma and placing signed swap orders that Charisma runs for you.

Base URL: https://swap.charisma.rocks/api/v1

Requests and responses are JSON. Tokens are contract IDs, and STX is .stx. Order amounts are integer strings in the token's smallest unit. Only /quote sends CORS headers, so call every other endpoint from a server.

Authentication​

ModeUsed byHow
None/quote, /orders reads, /subnet-tokens, /balancesNothing to send.
Order signaturePOST /orders/newA SIP-018 signature in the body's signature field. See Create an order.
Signed messageCancel, execute, API-key managementThe wallet signs a message with stx_signMessage. Send the result in the x-signature and x-public-key headers.
API keyCancel, executeSend the x-api-key: ck_live_… header. See API keys.

Endpoints​

MethodPathAuthPurpose
GET/quoteNoneFind the best route and output for a swap
POST/orders/newOrder signatureCreate an order
GET/ordersNoneList orders
GET/orders/{uuid}NoneGet one order
PATCH/orders/{uuid}/cancelSigned message or API keyCancel an order
POST/orders/{uuid}/executeSigned message or API keyRun an order now
GET, POST/api-keysSigned messageList or create API keys
GET, DELETE/api-keys/{keyId}Signed messageGet a key's stats, or revoke it
GET/subnet-tokensNoneList subnet tokens. pairings maps each mainnet token to its subnet token.
GET/balances/{address}NoneGet an address's STX, token and subnet balances. Add ?includeZero=true to include zero balances.

Errors​

EndpointError body
/quote{ "success": false, "error": "…" }
/orders/*{ "error": "…" }. An invalid /orders/new body also returns "details": ["field: message"].
Auth failures and /api-keys{ "error": "…", "timestamp": "…" }. Some also include details.

The status code says what kind of failure it was: 400 bad input, 401 auth failed, 403 someone else's key, 404 not found, 409 uuid already used, 429 rate limited, 500 server error.

Order lifecycle​

StatusMeaningFields that get set
openWaiting to runcreatedAt
broadcastedThe swap transaction has been senttxid, broadcastedAt
confirmedThe swap succeeded on-chainblockHeight, blockTime, confirmedAt
failedThe transaction aborted on-chainfailedAt, failureReason (for example abort_by_post_condition)
cancelledThe order will never runcancelledAt
  • Executor. It checks every open order once a minute. Price-triggered orders run when their condition is met, and "*" orders run on the next pass. Manual orders wait for /execute.
  • Settlement. A second job, also running every minute, moves broadcasted orders to confirmed or failed. If the transaction is dropped, or has not landed 24 hours after broadcastedAt, the order becomes cancelled. Orders sent before broadcastedAt existed only have the 90-day limit.
  • Automatic cancellation. An order is cancelled when its validTo passes, when it is 90 days old, when its inputToken turns out not to be a subnet token, or when a sibling exit runs (see one-cancels-other).