Use personnel ticket rights in the sales process
Overview
This guide explains how to implement personnel ticket rights in your client, enabling the purchase of personnel tickets.
To use personnel tickets in the sales flow:
- The customer must have a private profile in Entur Customers
- The customer must be connected to ticket rights through their profile (See guide: Connect customer profiles with personnel ticket rights)
Summary flow
- Get existing ticket rights
- Let user select ticket rights
- Search for discounted offers
- Reserve offers
- Complete the purchase
1. Get existing ticket rights
To fetch the ticket rights for a customer number, use
Notes
-
Every employee has two ticket rights:
- One for private travel
- One for work travel
-
Family members and pensioners have one personnel ticket right for private travel
-
Each ticket right includes
passengerCategoryand the holder's birthdate incontractOwnerBirthDate. See step 2 for how to use them. -
contractUUIDandproductIdfrom the ticket right are used when you reserve offers in step 4.
2. Let user select ticket rights
The sales client should:
- Filter out ticket rights that are not valid on the travel date (check the contract validity period)
- Display relevant ticket rights to the user
- Let the user choose which rights to use
Selecting traveller info for the offer request
passengerCategory only covers known categories that matter for tax reporting. We do not know whether a traveller is
a child or an adult, due to differing age limits between operators, and that the date of travel affects the age. Therefore,
ADULT is the passengerCategory for both adults and children.
passengerCategory | Send in offer request |
|---|---|
SENIOR_CITIZEN | userType: SENIOR |
STUDENT | userType: STUDENT |
ADULT | age, calculated from contractOwnerBirthDate and the travel date |
When ADULT is returned on the ticket right, set the age (at the time of travel) on the request, not a user type.
This lets the offer service determine whether the offer should be for an adult or a child.
Fall back to userType: ADULT only if the birthdate is missing.
⚠️ Do not send ANYONE. Children will get adult offers, which leads to wrong tax reporting.
3. Search for discounted offers
After the user selects ticket rights, search for offers with Offers v2.
- Include the selected entitlement product IDs in
productIds - Include
ageoruserTypeas described in step 2 - The response will include discounted prices based on the personnel ticket rights
Example of travellers in the request body:
Code
4. Reserve offers
Add the selected offers to an order with
Use customers to link each customer and their selected ticket right to the order line:
Code
If the ticket right can't be used, the request fails. See Handle validation errors.
5. Complete the purchase
Complete the purchase as usual.
Once the ticket is distributed:
- Personnel ticket usage will be registered in the system
- The taxable benefit will be recorded for tax reporting purposes
Handle validation errors
Entur validates the ticket right automatically. Your client must handle the errors returned when a ticket right cannot be used.
The check runs twice:
| When | Status | Exception |
|---|---|---|
| Reserve offers (step 4) | 400 Bad Request | InvalidContractConsumptionException |
| Distribute tickets (after purchase) | 409 Conflict | InvalidContractException |
When reserving offers
This is where most errors are caught. Example message:
Invalid consumption of contract: User already has a ticket with overlapping time of travel.
Show the user a clear message. Let them pick another ticket right or travel date, or cancel the ticket that blocks the purchase.
When distributing tickets
⚠️ This check runs after the purchase is completed. If it fails, the ticket is not issued.
This can happen if the same customer buys tickets in two places at the same time, for example in two browser tabs. Both purchases pass reserve offers, because the ticket right is only marked as used when a ticket is distributed. The first purchase gets a ticket, the second fails at distribution. The second purchase is still counted in the tax report until it’s cancelled. Cancel it through your normal cancellation flow, or ask the customer to contact customer service.
Next steps
Guide: Fetching tax savings reports