Skip to main content

POST /orders/new

Create a limit / triggered order that will execute on-chain once its price condition is met.

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

Authorization

This route is public but requires a signature in the request body. No x-api-key header is accepted.

Include the 65-byte compressed signature (hex, no 0x) in the signature field of the JSON payload.

Request body

All fields are strings unless noted.

FieldTypeRequiredDescription
ownerStacks addressPrincipal that owns (& can cancel) the order.
inputTokencontract IDToken to spend (must be a subnet token).
outputTokencontract IDToken you want to receive.
amountInintegerAmount of inputToken in micro-units.
targetPricedecimalDesired price (output per input); compared using direction.
direction"gt" | "lt"gt = fill when price ≥ targetPrice; lt = price ≤ targetPrice.
conditionTokencontract IDToken whose price is monitored.
recipientStacks addressAddress that will receive the swap proceeds.
signaturehex(130)✅*65-byte compressed secp256k1 signature of the message bundle.
uuidUUID v4Unique identifier to prevent replay.
baseAssetcontract ID or "USD"NoDenominator for price feeds; defaults to subnet sUSDT.
validFromISO-8601NoEarliest timestamp at which the order may fill.
validToISO-8601NoExpiration time; after this the order is auto-cancelled.

Example

curl -X POST https://swap.charisma.rocks/api/v1/orders/new \
-H "Content-Type: application/json" \
-d '{
"owner": "SP3FBR2…ZY6",
"inputToken": "SP2ZNGJ85ENDY6QRHQ5P2D4FXKGZWCKTB2T0Z55KS.charisma-token-subnet-v1",
"outputToken": ".stx",
"amountIn": "1000000",
"targetPrice": "0.30",
"direction": "gt",
"conditionToken": ".stx",
"recipient": "SP3FBR2…ZY6",
"uuid": "669e8e74-6b2b-477e-9e4d-cd1399a0ef20",
"signature": "2b7c…9e"
}'

Successful response

{
"status": "success",
"data": {
"uuid": "669e8e74-6b2b-477e-9e4d-cd1399a0ef20",
"status": "open",
"createdAt": "2024-05-22T14:31:45.123Z"
}
}

Validation errors (400)

  • amountIn must be integer numeric string
  • targetPrice must be positive
  • signature verification failed