# Get the ticket PDF of a booking

> Get the download links of the ticket PDF of a booking (the hold voucher for a hold).

Endpoint: `POST /flights/get_ticket`

Source: https://fx-port.com/docs/api/get-ticket

`POST /api/v1/flights/get_ticket`

Requires an API key with **Read** permission; a **Read+Write** key works too.

The PDF is generated after the booking: call again until `ticket_ready` is `true`.

`ticket_ready` is `true` as soon as the booking has a PDF link, whatever its status: it does not mean that an e-ticket exists, ask `get_ticket_number` for that. `get_booking` returns the same links as `booking.pdf_url` and `booking.pdf_url_no_price` together with the rest of the booking.

**The links are public.** Anybody who has a `pdf_url` can open the PDF with no key and no login; it holds the traveler's name, the itinerary and the fare. Do not log them, do not send them to third parties, and prefer to download the PDF on your server and serve it yourself.

## Request

### Body

Required, JSON.

- `booking_id` (string, optional): The PNR, the supplier order id or the FX-Port booking UUID. Prefer the UUID or the order id: PNRs are not unique.
- `order_id` (string, optional): Another name of `booking_id`.
- `pnr` (string, optional): Another name of `booking_id`.
- `include_api_response` (boolean, optional): `get_booking` only: `true` adds `booking.apiResponse`. Default `false`.
- `agency_id` (string, optional): Not needed: the agency of a call is always the one of your API key. The field is accepted so that older clients keep working, and it is ignored.
- `bookingId` (string, deprecated, optional): Legacy name: use `booking_id`. The previous spelling of `booking_id`: The PNR, the supplier order id or the FX-Port booking UUID.
- `orderId` (string, deprecated, optional): Legacy name: use `booking_id`. The previous spelling of `booking_id`: The PNR, the supplier order id or the FX-Port booking UUID.
- `includeApiResponse` (boolean, deprecated, optional): Legacy name: use `include_api_response`. The previous spelling of `include_api_response`: `get_booking` only: `true` adds `booking.apiResponse`.
- `agencyId` (string, deprecated, optional): Legacy name: use `agency_id`. The previous spelling of `agency_id`: Not needed: the agency of a call is always the one of your API key.

### Example request

```bash
curl https://api.fx-port.com/api/v1/flights/get_ticket \
  -H "Authorization: Bearer fxp_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "booking_id": "Y7PAEU"
}'
```

## Response

### 200: The links, or `ticket_ready: false` with a message while the PDF is being generated.

- `environment` (string): The environment of the key that made the call: `sandbox` for fxp_test_ keys, `live` for fxp_live_ keys. Present in every JSON body. One of `sandbox`, `live`.
- `request_id` (string): The id of the request, also in the `X-Request-Id` header.
- `warnings` (array of object): Present only when the request used a previous spelling of a field or something the endpoint ignored.
  - `code` (string): What the warning is about. One of `deprecated_field`, `ignored_field`, `coerced_value`, `deprecated_value`, `deprecated_endpoint`.
  - `field` (string): The request field the warning is about.
  - `replacement` (string): The name to use instead, for `deprecated_*` warnings.
  - `message` (string): A sentence that says what happened and what to do.
  - `documentation_url` (string): Where the naming rules are explained.
- `success` (boolean): `true` when the booking was found.
- `requestId` (string, deprecated): Legacy name: use `request_id`. The id of this request, 8 characters, for support.
- `ticket_ready` (boolean): `true` as soon as the booking has a PDF link, whatever its status. It does not mean that an e-ticket exists: ask `get_ticket_number`.
- `booking_id` (string): Echoes the value you sent: the PNR, the order id or the UUID.
- `message` (string): Only when `ticket_ready` is `false`.
- `download_url` (string, deprecated): Legacy name: use `pdf_url`. The PDF with the fare receipt. A public link.
- `pdf_url` (string): The PDF with the fare receipt. A public link. The snake_case twin of `download_url`, with the same value: use this name.
- `download_url_with_price` (string): The same address as `download_url`.
- `download_url_no_price` (string, nullable, deprecated): Legacy name: use `pdf_url_no_price`. A second PDF of the same ticket without prices. A public link.
- `pdf_url_no_price` (string, nullable): A second PDF of the same ticket without prices. A public link. The snake_case twin of `download_url_no_price`, with the same value: use this name.

```json
{
  "environment": "sandbox",
  "success": true,
  "requestId": "71fdaeb7",
  "ticket_ready": true,
  "booking_id": "Y7PAEU",
  "download_url": "https://s3.example.com/flight-bookings/Y7PAEU-JAMES-SMITH.pdf",
  "download_url_with_price": "https://s3.example.com/flight-bookings/Y7PAEU-JAMES-SMITH.pdf",
  "download_url_no_price": "https://s3.example.com/flight-bookings/Y7PAEU-JAMES-SMITH-no-price.pdf"
}
```

## Errors

| Status | Code | Example message |
| --- | --- | --- |
| 400 | `bad_request` | booking_id is required |
| 400 | `invalid_booking_id` | `booking_id` is not a valid identifier (letters, digits and - _ . : = ~ only, up to 128 characters). |
| 404 | `booking_not_found` | No booking found for 'ZZZZZZ' |

See [Errors](https://fx-port.com/docs/errors.md) for every code and how to react.

## Related guides

- [Get the ticket PDF](https://fx-port.com/docs/flights/get-ticket.md)
- [Get a booking](https://fx-port.com/docs/flights/get-booking.md)
