deliveryOrderCancel
Required scope: edit_delivery_orders
Cancels a delivery order. The delivery order must not have already reached a terminal state (COMPLETED) or be past the cancellable point in the fulfillment lifecycle. A CANCELED fulfillment event is appended to fulfillmentData.events.
Mutation
graphql
mutation DeliveryOrderCancel($id: String!) {
deliveryOrderCancel(id: $id) {
id
type
state
message
}
}Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | String! | Yes | UUID of the delivery order to cancel |
Return Type
The mutation returns a MutationResult object:
| Field | Type | Description |
|---|---|---|
id | ID! | UUID of the affected delivery order |
type | String! | Always "delivery_order" |
state | String! | Result state: "success" or "error" |
message | String | Human-readable message describing the outcome |
Example
Variables
json
{
"id": "do_abc123"
}Response
json
{
"data": {
"deliveryOrderCancel": {
"id": "do_abc123",
"type": "delivery_order",
"state": "success",
"message": "Delivery order cancelled successfully."
}
}
}Code Examples
bash
curl -X POST https://api-v3.happycolis.com/graphql \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation DeliveryOrderCancel($id: String!) { deliveryOrderCancel(id: $id) { id type state message } }",
"variables": {
"id": "do_abc123"
}
}'js
async function deliveryOrderCancel(accessToken, id) {
const response = await fetch('https://api-v3.happycolis.com/graphql', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
mutation DeliveryOrderCancel($id: String!) {
deliveryOrderCancel(id: $id) {
id
type
state
message
}
}
`,
variables: { id },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.deliveryOrderCancel;
}
// Usage
const result = await deliveryOrderCancel(accessToken, 'do_abc123');python
import requests
def delivery_order_cancel(access_token, delivery_order_id):
response = requests.post(
'https://api-v3.happycolis.com/graphql',
headers={
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
},
json={
'query': '''
mutation DeliveryOrderCancel($id: String!) {
deliveryOrderCancel(id: $id) {
id
type
state
message
}
}
''',
'variables': {'id': delivery_order_id},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['deliveryOrderCancel']
# Usage
result = delivery_order_cancel(access_token, 'do_abc123')php
function deliveryOrderCancel(string $accessToken, string $id): array
{
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api-v3.happycolis.com/graphql', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json',
],
'json' => [
'query' => '
mutation DeliveryOrderCancel($id: String!) {
deliveryOrderCancel(id: $id) {
id
type
state
message
}
}
',
'variables' => ['id' => $id],
],
]);
$result = json_decode($response->getBody()->getContents(), true);
if (isset($result['errors'])) {
throw new \Exception($result['errors'][0]['message']);
}
return $result['data']['deliveryOrderCancel'];
}
// Usage
$result = deliveryOrderCancel($accessToken, 'do_abc123');go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func deliveryOrderCancel(accessToken string, id string) (map[string]interface{}, error) {
query := `
mutation DeliveryOrderCancel($id: String!) {
deliveryOrderCancel(id: $id) {
id
type
state
message
}
}
`
body, _ := json.Marshal(map[string]interface{}{
"query": query,
"variables": map[string]interface{}{"id": id},
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
if errs, ok := result["errors"]; ok {
return nil, fmt.Errorf("graphql error: %v", errs)
}
data := result["data"].(map[string]interface{})
return data["deliveryOrderCancel"].(map[string]interface{}), nil
}