Cancel OTC Deal
Cancel an active OTC (Over-The-Counter) deal that was previously created.
Endpoint
POST /v2/users/otcs/users/{user_id}/tokens/{token_id}/cancel
Headers
| Header | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | string | Yes | The unique identifier of the user who owns the deal |
| token_id | string | Yes | The unique identifier of the token |
Request Body
{
"deal_id": 12
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| deal_id | integer | Yes | The unique identifier of the deal to cancel |
Response
Returns a transaction ID for async processing. The cancellation is processed asynchronously.
Success Response (200 OK)
{
"transaction_id": "6913872755654191dede37da"
}
Response Fields
| Field | Type | Description |
|---|---|---|
transaction_id | string | Transaction ID for polling - use to check cancellation status |
Example
Request
curl -X POST "\{\{baseUrl\}\}/v2/users/otcs/users/680c02896d91ca0145cfeb81/tokens/68ae06cfcccf4e8fc19362d1/cancel" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer \{\{token\}\}" \
-d '{
"deal_id": 12
}'
Response
{
"transaction_id": "6913872755654191dede37da"
}
Note: Poll the transaction status endpoint to track cancellation completion.
Error Responses
400 Bad Request
{
"error": "Invalid parameters",
"details": "Deal ID is required"
}
401 Unauthorized
{
"error": "Authentication required"
}
403 Forbidden
{
"error": "Access denied",
"details": "You can only cancel your own deals"
}
404 Not Found
{
"error": "Deal not found",
"details": "The specified deal does not exist"
}
409 Conflict
{
"error": "Deal cannot be cancelled",
"details": "Deal is already completed or expired"
}
500 Internal Server Error
{
"error": "Internal server error"
}
Important Notes
- Ownership Verification: Only the creator of the deal can cancel it
- Deal Status: Only active deals can be cancelled
- Token Return: Any locked tokens are returned to the user's available balance
- Partial Execution: If the deal was partially executed, only the remaining quantity is cancelled
- Counterparty Notification: Any interested counterparties are notified of the cancellation
- Irreversible Action: Once cancelled, the deal cannot be reactivated
- No Penalties: There are typically no penalties for cancelling OTC deals
- Audit Trail: All cancellations are logged for audit and compliance purposes