# Get the voucher PDF links of a booking

> Returns the links of the voucher PDFs of a booking of your agency: one with the price and one without it, to hand to the traveler.

Endpoint: `GET /hotels/get_voucher`

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

`GET /api/v1/hotels/get_voucher`

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

The links are permanent public URLs without a signature: anyone who has one can open the voucher, so do not post it where it should not be read. The voucher is made after the booking is `confirmed`, usually at the same moment and sometimes up to 10 seconds later: until then the call answers `404` with the code `pdf_not_found`; try again in 2 seconds. The links stay available after a cancellation. The same links are in `voucherUrl` and `voucherUrlNoPrice` of the booking detail.

## Request

### Query parameters

- `booking_id` (string, required): The id of the booking: the `bookingId` of `book_hotel`.
- `partner_order_id` (string, deprecated, optional): Legacy name: use `booking_id`. The booking id, in its older spelling. Use `booking_id`.
- `partnerOrderId` (string, deprecated, optional): Legacy name: use `booking_id`. The booking id, in its older spelling. Use `booking_id`.
- `bookingId` (string, deprecated, optional): Legacy name: use `booking_id`. The booking id, in its older spelling. Use `booking_id`.

### Example request

```bash
curl 'https://api.fx-port.com/api/v1/hotels/get_voucher?booking_id=HMVXX4ZQ3' \
  -H "Authorization: Bearer fxp_test_YOUR_KEY"
```

## Response

### 200: The voucher links.

- `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 voucher exists.
- `data` (object): The voucher links of a booking.
  - `bookingId` (string, deprecated): Legacy name: use `booking_id`. The id of the booking.
  - `booking_id` (string): The id of the booking. The snake_case twin of `bookingId`, with the same value: use this name.
  - `voucherUrl` (string, deprecated): Legacy name: use `voucher_url`. The voucher PDF, with the price. A permanent public link: anyone who has it can open it.
  - `voucher_url` (string): The voucher PDF, with the price. A permanent public link: anyone who has it can open it. The snake_case twin of `voucherUrl`, with the same value: use this name.
  - `voucherUrlWithPrice` (string, deprecated): Legacy name: use `voucher_url_with_price`. The same link as `voucherUrl`.
  - `voucher_url_with_price` (string): The same link as `voucherUrl`. The snake_case twin of `voucherUrlWithPrice`, with the same value: use this name.
  - `voucherUrlNoPrice` (string, nullable, deprecated): Legacy name: use `voucher_url_no_price`. The voucher PDF without the price, to hand to the traveler. `null` when it was not made.
  - `voucher_url_no_price` (string, nullable): The voucher PDF without the price, to hand to the traveler. `null` when it was not made. The snake_case twin of `voucherUrlNoPrice`, with the same value: use this name.
  - `status` (string): The status of the booking. A voucher stays available after a cancellation. One of `pending`, `confirmed`, `failed`, `refunded`, `partial_refund`, `cancelled`.

```json
{
  "environment": "sandbox",
  "success": true,
  "data": {
    "bookingId": "HMVXX4ZQ3",
    "voucherUrl": "https://files.example.com/hotel-bookings/HMVXX4ZQ3-Jane-Smith.pdf",
    "voucherUrlWithPrice": "https://files.example.com/hotel-bookings/HMVXX4ZQ3-Jane-Smith.pdf",
    "voucherUrlNoPrice": "https://files.example.com/hotel-bookings/HMVXX4ZQ3-Jane-Smith-no-price.pdf",
    "status": "confirmed"
  }
}
```

## Errors

| Status | Code | Example message |
| --- | --- | --- |
| 403 | `forbidden` | This booking does not belong to your agency. Only the agency that made the booking can retrieve its voucher. |
| 404 | `booking_not_found` | Booking not found |
| 404 | `pdf_not_found` | The voucher is not available yet: it is made shortly after the booking is confirmed. Retry in a few seconds. |
| 422 | `validation_error` | Field required |
| 503 | `service_overloaded` | The service is temporarily overloaded; retry after the time given in the Retry-After header. |

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

## Related guides

- [Get the hotel voucher](https://fx-port.com/docs/hotels/voucher.md)
