For AI agents: the documentation index is at /llms.txt, and this page is available as Markdown at /api/gateway/prepare-cancel-order.md.

Cancel a limit or TP/SL order (CeFi or DeFi)

Organization tokenNo token

POST
/orders/{id}/cancel

Venue-polymorphic cancel. The payloads field is the signal:

  • CeFi orders are canceled immediately and return 202 Accepted with no payloads. Poll GET /orders/{id}/status for the terminal state.
  • DeFi (Hyperliquid) resting orders return 200 OK with unsigned payloads. Sign each locally and post the signatures to POST /orders/{id}/cancel/execute.

Only cancellable orders (CeFi pending/active limit orders, DeFi active limit or TP/SL trigger orders) can be canceled. An order that is no longer open (complete, canceled or failed) returns 422 with code order_not_open; refetch it for its final status. Other orders return 400. An order with strategy_managed set is cancelled by its strategy, not here, and returns 422.

Authorization

bearerAuth
headerAuthorizationBearer <JWT>

An access token from POST /v1/auth/api-key/token. An organization token lasts one hour and has no refresh token; a personal token can be refreshed.

Path Parameters

id*string

Order ID

Header Parameters

TM-On-Behalf-Of?string

Act as one of your organization's users. The value is the user_id returned when the user was created; the request then reads and writes that user's account. Requires an organization token and a user your organization created: 400 for a personal token, a repeated header or a non-UUID, 403 for a user outside your organization. Not accepted on organization-scoped routes.

Formatuuid

Response Body

Resting DeFi order; unsigned cancel payloads to sign and execute

application/json
  1. response

Response from the cancel endpoint. A resting DeFi order returns unsigned payloads the client must sign and submit to the cancel-execute endpoint. A CeFi order is canceled immediately and returns 202 with no payloads.

payloads?array<>

Unsigned cancel payloads the client signs and returns via the cancel-execute endpoint. Present for resting DeFi orders, absent for CeFi orders.

Example Request
curl -X POST 'https://api.truemarkets.co/v1/gateway/orders/string/cancel' \  -H 'TM-On-Behalf-Of: 3f6d2c0e-8a41-4c2b-9f1e-2b7d5c0a9e11'
Example Response
{  "payloads": [    {      "digest": "string",      "payload": "string"    }  ]}