Update Order
Update an existing order. Only orders with status pending can be updated.
Endpoint
PATCH /v1/orders/{order_id}
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id | string | Yes | The order ID |
Headers
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Request Body
All fields are optional. Only include fields you want to update.
| Field | Type | Description |
|---|---|---|
sender | object | Updated sender information |
recipient | object | Updated recipient information |
package | object | Updated package information |
service_type | string | Updated service type |
notes | string | Updated special instructions |
Example Request
curl -X PATCH ${API_URL}/v1/orders/order_1a2b3c4d5e6f \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"recipient": {
"phone": "+1111111111",
"address": "789 New Address"
},
"notes": "Updated delivery instructions"
}'
PHP Example
<?php
$access_token = 'YOUR_ACCESS_TOKEN';
$order_id = 'order_1a2b3c4d5e6f';
$updates = [
'recipient' => [
'phone' => '+1111111111',
'address' => '789 New Address'
],
'notes' => 'Updated delivery instructions'
];
$ch = curl_init("${API_URL}/v1/orders/{$order_id}");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($updates));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $access_token,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$order = json_decode($response, true);
print_r($order);
?>
Response
Success Response (200 OK)
Returns the updated order object.
{
"id": "order_1a2b3c4d5e6f",
"tracking_number": "FUF123456789",
"status": "pending",
"recipient": {
"name": "Jane Smith",
"phone": "+1111111111",
"email": "jane@example.com",
"address": "789 New Address",
"city": "Los Angeles",
"postal_code": "90001",
"country": "US"
},
"notes": "Updated delivery instructions",
"updated_at": "2024-01-15T11:45:00Z"
}
Error Response (400 Bad Request)
{
"error": {
"code": "invalid_status",
"message": "Cannot update order with status 'in_transit'"
}
}
Error Response (404 Not Found)
{
"error": {
"code": "order_not_found",
"message": "Order not found"
}
}
Limitations
- Only orders with status
pendingcan be updated - Cannot change the order ID or tracking number
- Some fields may be locked after pickup