orderCancel
Requests cancellation of an order.
- DRAFT orders: cancelled immediately and synchronously. The order transitions to
COMPLETED(cancelled terminal state). - OPENED orders: cancellation is requested asynchronously. If warehouse allocations exist, the fulfillment service must confirm the cancellation. The order will remain
OPENEDuntil confirmation is received.
Required scope: edit_orders
Mutation
graphql
mutation OrderCancel($id: String!) {
orderCancel(id: $id) {
id
type
state
message
}
}Return type: DispatchableRequest
| Field | Description |
|---|---|
id | Unique identifier of this cancellation request |
type | Request type — CANCEL for this mutation |
state | Processing state of the request |
message | Human-readable status message |
Cancellation behaviour by order state
| Order State | Behaviour |
|---|---|
DRAFT | Immediately cancelled. Terminal. |
OPENED — no warehouse allocation yet | Cancelled asynchronously; typically fast. |
OPENED — warehouse has started production | Cancellation request sent to fulfillment service. May be rejected if picking has started. |
COMPLETED | Cannot be cancelled — already in terminal state. |
If cancellation is rejected by the fulfillment service, the order remains
OPENED. You will receive adelivery_order/cancellation_rejectedwebhook event.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | String | ✅ | Internal UUID of the order to cancel |
Example Variables
json
{
"id": "550e8400-e29b-41d4-a716-446655440000"
}Example Response
json
{
"data": {
"orderCancel": {
"id": "req-uuid-cancel-001",
"type": "CANCEL",
"state": "PENDING",
"message": "Cancellation request submitted"
}
}
}Code Examples
bash
curl -X POST https://api-v3.happycolis.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"query": "mutation OrderCancel($id: String!) { orderCancel(id: $id) { id type state message } }",
"variables": {
"id": "550e8400-e29b-41d4-a716-446655440000"
}
}'js
const mutation = `
mutation OrderCancel($id: String!) {
orderCancel(id: $id) {
id
type
state
message
}
}
`;
const response = await fetch('https://api-v3.happycolis.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
},
body: JSON.stringify({
query: mutation,
variables: { id: '550e8400-e29b-41d4-a716-446655440000' },
}),
});
const { data } = await response.json();
console.log(data.orderCancel);python
import os
import requests
mutation = """
mutation OrderCancel($id: String!) {
orderCancel(id: $id) {
id
type
state
message
}
}
"""
response = requests.post(
'https://api-v3.happycolis.com/graphql',
headers={'Authorization': f'Bearer {os.environ["ACCESS_TOKEN"]}'},
json={
'query': mutation,
'variables': {'id': '550e8400-e29b-41d4-a716-446655440000'},
},
)
data = response.json()['data']
print(data['orderCancel'])php
<?php
$mutation = <<<'GQL'
mutation OrderCancel($id: String!) {
orderCancel(id: $id) {
id
type
state
message
}
}
GQL;
$ch = curl_init('https://api-v3.happycolis.com/graphql');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'query' => $mutation,
'variables' => ['id' => '550e8400-e29b-41d4-a716-446655440000'],
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . getenv('ACCESS_TOKEN'),
],
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($result['data']['orderCancel']);go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
mutation := `
mutation OrderCancel($id: String!) {
orderCancel(id: $id) {
id
type
state
message
}
}`
body, _ := json.Marshal(map[string]any{
"query": mutation,
"variables": map[string]any{"id": "550e8400-e29b-41d4-a716-446655440000"},
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("ACCESS_TOKEN"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]any
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["data"])
}