Skip to main content
You can change booking details or cancel an order until the first driver or carrier booking. Pickup codes and contacts stay editable later, until the relevant handover completes. Read editable_fields on the order to see which fields you can change. Contact Bahn for changes outside these permissions.

Send a safe write

A change and a cancellation use the same procedure:
1

Read the current order

Call GET /v2/orders/{order_id}. Use this response, not a copy that you stored earlier.
2

Check the action

For changes, check that every supplied field is in editable_fields. For cancellation, check that allowed_actions contains cancel. Otherwise, show cancellation_unavailable_reason and stop.
3

Send the current revision

Put the order revision inside double quotation marks in the If-Match header.
4

Send a new idempotency key

Create a new Idempotency-Key for this decision. Store the key, the If-Match value, and the body before you send the request.
5

Retry with the same values

After a timeout or a 5xx response, send the same key, If-Match value, and body again.
6

Read again after a conflict

After 412 revision_conflict, read the order again and decide again. Use a new key for the new decision.
The If-Match value looks like this:
A value without quotation marks, a weak value such as W/"...", or * returns 400 validation_error. An idempotency key has 8 to 255 characters. Keys are shared by all V2 writes for your account, so a cancellation must not use the key of an earlier change. A retry of a completed write does not do the write again. It returns 200 with the current order, which can differ from the first response. A live ETA change does not change the order revision. A driver booking, an unbooking, and a change of driver do change it.

Change an order

Send PATCH /v2/orders/{order_id} with a JSON Merge Patch body and the content type application/merge-patch+json. Cancellation and primary delivery close all updates. A pending trade-in return does not reopen the primary vehicle’s contact fields. allowed_actions contains update when at least one field can change. An assigned order can return:
Use the same PATCH endpoint to add a release code after assignment:
Send null to clear the release code. A contact patch changes only its supplied name, phone, or email. Omitted contact fields stay unchanged. Required private-stop contact details cannot be cleared. Code/contact-only changes preserve the price and timing and work on pickup day without booking lead-time validation. If any supplied field is locked, the API rejects the entire request with 409 order_not_updateable. The errors array names each locked field with path and code: "field_not_editable". No part of that request is saved. Read the order again and submit only permitted changes with a new idempotency key. When you clear the pickup windows, keep available_from so that pickup still has a start time. When you send items, include the VIN or registration number and every vehicle fact that you want to keep, including height_mm and tires. The CMR recipient cannot change after creation. The winter-tire terms of an order stay as booked until you send items again. Then Bahn prices the new tire answer at the time of the change. Changes to booking details must follow the same rules as a new order. Pickup and delivery times gives the time rules. A change to the route, vehicle, or service can calculate a new price. This body replaces the requested delivery windows and keeps every other value:
This example reads the order and changes its order-level note. Set BAHN_ORDER_ID to the order that you intend to change.

Cancel an order

Cancellation stops open production work. Confirm the customer’s intent before you send a production cancellation.
Send DELETE /v2/orders/{order_id} with the current revision in If-Match and an idempotency key. The request has no body. This example reads the order and cancels it only when the action is available. Set BAHN_ORDER_ID to the intended test order.
These shell examples use curl, jq, and uuidgen. Keep the key when you retry the same request. A successful cancellation has these results:
  • The order status becomes cancelled. The order stays available for reads.
  • allowed_actions contains only get_files, and get_inspection_report when the order uses the full inspection service.
  • Location tracking ends.
  • Bahn sends com.bahn.order.cancelled.v1.
  • Bahn withdraws the open transport work for the order. If Bahn offered that work together with other orders, Bahn arranges transport for those orders separately. The cancellation response does not wait for this.

Handle a rejected write

  • 400 validation_error: A header or the body is not valid. For example, If-Match is not inside double quotation marks. Correct the request.
  • 403 permission_denied: The credential does not have the orders:write scope. Use a credential with that scope.
  • 409 order_not_cancellable: Cancellation is not available, and detail contains the reason. Read the order and show cancellation_unavailable_reason. Do not retry.
  • 409 order_not_updateable: One or more supplied fields are locked. Read errors for the field paths and editable_fields on the current order. Submit permitted fields as a new decision with a new key.
  • 409 idempotency_conflict: The key belongs to a different request, or the first request with this key is still in progress. Compare with your stored request. If the first request is still in progress, wait and retry the same request.
  • 412 revision_conflict: The order changed after you read it. Read the order again, and decide again with a new key.
  • 422 business_rule_violation: The changed values break a transport rule, and detail explains which one. Correct the values. Only a change returns this code.
Bahn checks field permissions before the revision. A locked field returns 409 even when the revision is out of date. Cancellation checks its action before the revision. A driver can book the order while your request is in progress. A cancellation then returns 409 order_not_cancellable. A change can return 412 revision_conflict. Read the order again and check editable_fields. Pickup codes and contacts can remain editable. Read Errors, retries, and conflicts for authentication, size, and server errors.