ordered_for. Add the capabilities your workflow needs after the first order works. Quickstart provides that first complete request.
The core loop
Once order creation and reads work, subscribe to webhooks for the changes your system needs. A webhook tells you what changed. The resource tells you what is true now. This distinction matters when events arrive late, arrive more than once, or arrive in a different order.Store the right identifiers
After order creation, store these values together:id: Use the Bahn order ID in every resource path.customer_reference: Match the order to your own record. It can benulland is not required to be unique.revision: Protect order updates and cancellations from stale writes.allowed_actions: Check whether your workflow can update or cancel the order.editable_fields: Check which fields an update can change at the current transport stage.
Add the capabilities your workflow needs
Make reads event-driven
Read the order when your workflow needs its current status, timing, or available actions. Use webhooks to refresh stored records after relevant changes. If you show a live map, poll the tracking resource every 30 to 60 seconds while it is visible. The event payload containsdata.resource_url. Tracking, file, and inspection events point to their own resources. Order events point to the order. Use data.related_resource_urls when one change affects more than one resource.
Keep writes deliberate
Create one idempotency key for each logical write that requires it. Reuse it for retries of the same operation and request data. Before an update or cancellation, read the latest order. Checkallowed_actions and, for updates, editable_fields, then send the current revision inside double quotation marks in If-Match. If Bahn returns revision_conflict, read the order again and make a new decision. Change or cancel an order gives the complete procedure.
Ordering for other businesses
If your platform arranges transport for its business users, follow Platform ordering. This track addsordered_for, eligibility checks, and business context in storage and webhook routing.
Continue with Create and find orders, Order status, or Webhooks for the event-processing flow.