Skip to content
API v2 · Deprecated

Cancel an order

Deprecated
POST
/v2/orders/{orderId}/cancel
curl --request POST \
--url https://api.hyperstream.dev/v2/orders/0x35dc8d390877c71baacadb4001eea0055804cfc306f599fbfc97c1d69d64d30a/cancel \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <X-API-Key>' \
--data '{ "payload": { "nonce": "90193471235580291647163018827702615384561129844105227391950712038818471125043", "rootIntentId": "0x01cb37f4c5f512f757df0452b51e3fe8daefda8dfdd7e6d298d841ac54f7d18b" }, "signature": "0x60ce0a47bc64e07a5437de5fd4e6008bce46756d4d7c971710283924888b2a137a91ed09461b5848bb2b7341f5c258da3f97853e73662275f047e0c3c20882211b" }'

Relays an EOA depositor’s signed cancel. Valid once the order is published. The filled part is paid out and the rest refunded when the hub settles.

A 200 is an acceptance, not settlement: keep polling the order. A cancel that races a fill is safe; whichever lands first settles the order. Sign a fresh nonce on every attempt.

Only an ECDSA signature recovering to the depositor is accepted; ERC-1271 is not supported. A contract wallet’s owner signature does not match the depositing contract. Wait for automatic settlement at expiry or contact Khalani for help cancelling early. An order whose quote returned earlyCancelDisabled: true cannot be cancelled before its deadline: this route answers 409. All newly built orders with a token on a non-EVM chain have early cancellation disabled. A Solana-source order whose stored policy permits cancellation requires its EVM depositor’s authorization; the wallet funding the Solana deposit address does not gain cancellation rights.

orderId
required
string
/^0x[0-9a-fA-F]{64}$/

The orderId from /v2/build. Case-insensitive.

Example

0x35dc8d390877c71baacadb4001eea0055804cfc306f599fbfc97c1d69d64d30a
Media typeapplication/json

A depositor-signed cancel, relayed by your backend.

object
payload
required
object
nonce
required

A fresh random uint256 per cancel attempt, decimal. Not the build nonce; a reused value is rejected.

string
/^\d+$/
rootIntentId
required

The order’s traces.rootIntentId.

string
/^0x[0-9a-fA-F]{64}$/
signature
required

The depositor’s EIP-712 OrderDelegateV2Cancel signature over payload.

string
/^0x[0-9a-fA-F]+$/

Example

{
"payload": {
"nonce": "90193471235580291647163018827702615384561129844105227391950712038818471125043",
"rootIntentId": "0x01cb37f4c5f512f757df0452b51e3fe8daefda8dfdd7e6d298d841ac54f7d18b"
},
"signature": "0x60ce0a47bc64e07a5437de5fd4e6008bce46756d4d7c971710283924888b2a137a91ed09461b5848bb2b7341f5c258da3f97853e73662275f047e0c3c20882211b"
}

Accepted.

Media typeapplication/json

The cancel was accepted, not yet settled. Poll the order until delivered or delivery_failed, with a local timeout.

object
medusaSubmissionId
required

Identifier of the accepted cancel submission.

string

Example

{
"medusaSubmissionId": "0xd51bb36fd7ad3c3e0b2c7a7f29f04de6a6e2d2a1f5b1f0e9d9f0f9a6a1f5c7e3"
}

Invalid body, rootIntentId is not this order’s, or the signature does not recover to the depositor. A fresh nonce does not fix the signature.

Media typeapplication/json
Any of:

The request failed schema validation. Carries message, not error.

object
message
required
string
Allowed value: Validation failed
name
required
string
Allowed value: ValidationException
details
required
Array<object>
object
field
required
string
message
required
string
code
required
string

Example

{
"error": "Payload rootIntentId does not match the order's published root intent"
}

The X-API-Key header is missing.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "X-API-Key required"
}

The key is unknown or past its rotation window. A 403 is always about your account: do not retry.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "Unknown or inactive integrator"
}

No such order, or it belongs to another integrator.

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "Order not found"
}

Not published yet, so there is nothing to cancel, or the order cannot be cancelled before its deadline (its quote returned earlyCancelDisabled: true).

Media typeapplication/json

An error raised by the route itself.

object
error
required
string
detail
object
minSrcAmount

Smallest deposit that would quote, in source base units.

string
/^\d+$/
maxSrcAmount

Largest deposit that would quote, in source base units.

string
/^\d+$/
missing

The deployment setting this direction needs.

string

Example

{
"error": "Order has not been published yet — wait for the deposit to clear or use stuck-deposit recovery."
}

Rate limited per IP. No Retry-After; back off and retry.

Media typeapplication/json

Rate limited. No Retry-After; back off and retry.

object
errorCode
required
string
Allowed value: RATE_LIMITED
message
required
string

Example

{
"errorCode": "RATE_LIMITED",
"message": "Too many requests, please retry later"
}

Cancellation outcome is unknown: a transport failure or timeout may happen after submission. Check the order status and, if still open, retry with a fresh nonce. Returns the unchanged { message, name } envelope.

Media typeapplication/json

Maintenance, a malformed JSON body, or an unhandled failure. Carries message, not error.

object
message
required
string
name
required

MaintenanceException (503), BadRequestException (malformed JSON) or InternalErrorException (500).

string

Example

{
"message": "Internal Error",
"name": "InternalErrorException"
}

Upstream failure. Returns a fixed error message and detail.reason; upstream diagnostic text is not returned. chain_unavailable: retry later. already_withdrawn: settled; keep tracking delivery. nonce_used: this cancel’s outcome is unknown. The nonce may have been used by a lost-response retry of this cancel or another order’s cancel. Check order status and, if still open, retry with a fresh nonce. upstream_storage: retryable; retry later with a fresh nonce while still open. order_not_found_upstream: the upstream contradicts the API’s published record; contact support. operator_rejected: server fault; contact support. rejected: another rejection; check status and contact support if it persists.

Media typeapplication/json
object
error
required
string
detail
required
object
reason
required

Cancellation failure class. Use this value to decide what to do; upstream diagnostic text is not returned.

string
Allowed values: chain_unavailable already_withdrawn nonce_used upstream_storage order_not_found_upstream operator_rejected rejected

Example

{
"error": "Cancellation outcome is unknown. Check the order status and, if still open, retry with a fresh nonce.",
"detail": {
"reason": "nonce_used"
}
}