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 supports two authentication methods:

  1. Signature only (original method): Include the 65-byte compressed signature (hex, no 0x) in the signature field of the JSON payload.

  2. API key + signature (for automated systems): Include both:

    • X-API-Key header with an API key that has create permission
    • Valid signature in the signature field (always required for security)

The signature is always required regardless of authentication method to ensure transaction integrity.

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 (Signature only)

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": "3045022100e8f2a8c4b1d7e6f9a2b5c8d1e4f7a0b3c6d9e2f5a8b1c4d7e0f3a6b9c2d5e8f1b4d7e0f3a6b9c2d5e8f1b4d7e0f3a6b9c2d5e8f1b4d7e0f3a6b9c2d5e"
}'

Example (API key + signature)

curl -X POST https://swap.charisma.rocks/api/v1/orders/new \
-H "Content-Type: application/json" \
-H "X-API-Key: ck_live_abc123def456..." \
-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": "3045022100e8f2a8c4b1d7e6f9a2b5c8d1e4f7a0b3c6d9e2f5a8b1c4d7e0f3a6b9c2d5e8f1b4d7e0f3a6b9c2d5e8f1b4d7e0f3a6b9c2d5e8f1b4d7e0f3a6b9c2d5e"
}'

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