application/problem+json. The OAuth token endpoint uses standard OAuth error responses.
Branch on the stable code, not the human-readable message. Include the request_id when you contact Bahn support.
Read a problem response
errors array can identify more than one invalid field. Do not parse the human message to select a program action.
Choose a recovery action
- Network timeout: Retry the same logical write with the same key and request data.
401from a resource request: Get a fresh token and retry once. Stop if it still fails.429: RespectRetry-Afterwhen present, otherwise use backoff.500to599: Retry with exponential backoff and jitter. Preserve write keys and request data.- OAuth
invalid_client: Stop and check the credential and environment. - OAuth
invalid_request: Check the content type, grant, and requested scopes. permission_denied: Check granted scopes and access to the resource.resource_not_found: Check the ID, environment, and account. An inaccessible order can also return this code.validation_error: Correct the named fields.request_too_largeorfile_too_large: Reduce the body or file. Do not retry it unchanged.revision_conflict(412): Read the order, then decide from its new revision and actions.idempotency_conflict(409): Check the original operation, request data, and whether its first attempt is still in progress.order_not_updateable: Read the field paths inerrorsand the current order’seditable_fields. No part of the rejected update is saved.order_not_cancellable: Read the order, stop cancellation, and showcancellation_unavailable_reason. See Change or cancel an order.business_rule_violation: Readdetailto explain why Bahn cannot serve the request as written.ordered_for_not_allowed: Use an ordering-channel credential if the order belongs to another business. Omit the field only for an own-account order.ordered_for_customer_not_found: Check the business ID and country code, then contact support.scenario_not_allowed: Check the test order’s state and the scenario preconditions.
401. Other permanent 4xx errors need a corrected request, permission, or account setup.
Request limits
Limits apply to your customer account across all its credentials. Production and sandbox have separate allowances, with the same limits. An ordering channel shares its allowance across all represented businesses.
Each row has a separate allowance. Estimates and price checks cannot consume each other’s allowance or the read and write allowances.
The burst allowance refills continuously at the sustained rate. It does not reset each second.
After idle time, you can send 5 price checks together, then sustain 2 per second.
Daily allowances reset at 00:00 UTC.
Requests consume allowance when admitted, including retries and requests that later fail validation.
A rejected
429 request consumes no allowance and does not run the operation.
Invalid tokens and missing scopes do not consume a customer’s allowance.
Responses include these headers after the API checks the request allowance:
X-RateLimit-Bucket:estimates,prices,reads, orwrites.RateLimit-Limit: burst capacity for that group.RateLimit-Remaining: requests currently available, also bounded by the daily allowance.RateLimit-Reset: seconds until the burst is full, or until the exhausted daily allowance resets.X-RateLimit-Daily-LimitandX-RateLimit-Daily-Remaining: the estimate or price-check daily allowance.
429, wait at least the integer number of seconds in Retry-After, then retry with jitter.
Keep the same idempotency key for a write retry. Do not create new credentials to retry.
If the shared limiter is unavailable, V2 returns 503 with code: rate_limit_unavailable and Retry-After.
Reuse each OAuth access token until near expiry. The token endpoint has its own limit of 60 requests per minute per source IP per server.
Contact Bahn before sending traffic above these limits.
Use idempotency keys
Order creation, updates, cancellation, file-upload creation, and sandbox advancement requireIdempotency-Key. Price estimates, price checks, and represented-business checks do not require it. File deletion is idempotent without the header.
Use a unique key of 8 to 255 characters for each logical write. Keys are shared across write operations for the authenticated customer account, so a cancellation must not reuse an order-creation key.
Store the key with the method, resource path, and request data. After a timeout, retry that request rather than starting another write. For an update or cancellation, preserve the original If-Match too.
A retry of a completed order write returns the current order state. It does not repeat the write. Do not assume that the response is an identical historical snapshot.
After idempotency_conflict, check your stored request before changing anything. A new key is appropriate for a new logical write. It is not a way to recover an unknown result from a timed-out creation.
Use order revisions
Order updates and cancellation requireIf-Match. Put the current order revision inside double quotation marks:
revision_conflict, read the order again. Decide whether the original change is still appropriate, check allowed_actions, and use a new key for the newly decided write. Do not automatically overwrite another person’s change.
A live ETA update does not change the order revision.
Store request IDs
You can sendX-Request-ID. The response also includes a request ID.
Store the request ID with each write result. Send it to support@bahnexpress.com when you report a problem.