POST/v1/trains/book/:gdsprovider/prebook

创建火车预订

根据一个或多个选定的火车报价创建临时预订。

分享

根据一个或多个选定的火车报价创建临时预订。

认证和请求头

请求头说明
AuthorizationBearer <secret_key>。密钥只能保存在服务器端,不能写入客户端日志。
X-Travelandz-Id<public_key>:<profile_code>,持久化的 profile code 格式为 dp_<12 位字母数字>。
Content-Type带 JSON body 的请求使用 application/json。

请求

path 中的 gdsprovider 当前为 0。body 需要非空字符串数组 offerIds。

请求参数结构

gdsprovider
enum
0
是
Currently 0

请求体结构

offerIds
array是
offerIds[]
string[]是

成功响应

返回 booking,包含 bookingId、expiresAt、条款、总价、旅客和额外费用。

响应体结构

booking
object是
bookinggdsprovider
number是
bookingbookingId
string是
bookingexpiresAt
string
格式: ISO 8601
是
bookingtermsAndConditions
array是
bookingtermsAndConditions[]
string[]是
bookingtotalPrice
object是
bookingtotalPriceamount
number是
bookingtotalPricecurrency
string是
bookingpassengers
array是
bookingpassengers[]id
string是
bookingpassengers[]type
enum
youthadultsenior
是
bookingextraFees
array是
bookingextraFees[]amount
number否
bookingextraFees[]currency
string否

错误

  • 400 表示验证失败或存在未知字段。
  • 401 或 403 表示 API 凭证无效。
  • 供应方失败时返回 500 internal_communication_error 或 unknown_error。
  • 报价无法预订或已过期时返回 booking_not_found。

使用说明

保存 bookingId,并在 expiresAt 前完成订单。

cURL 示例

bash
bash
curl --request POST \
  --url "https://api.sandbox.travelandz.com/v1/trains/book/0/prebook" \
  --header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  --header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
  --header "Content-Type: application/json" \
  --data '{"offerIds":["offer_123"]}'