Entur Developer
Personnel tickets

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:


Summary flow

  1. Get existing ticket rights
  2. Let user select ticket rights
  3. Search for discounted offers
  4. Reserve offers
  5. 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 passengerCategory and the holder's birthdate in contractOwnerBirthDate. See step 2 for how to use them.

  • contractUUID and productId from 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.

passengerCategorySend in offer request
SENIOR_CITIZENuserType: SENIOR
STUDENTuserType: STUDENT
ADULTage, 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 age or userType as described in step 2
  • The response will include discounted prices based on the personnel ticket rights

Example of travellers in the request body:

JSONCode
{ "travellers": [ { "id": "traveller-1", "customerId": "1234567", "age": 9, "productIds": ["ENT:EntitlementProduct:levelA1"] }, { "id": "traveller-2", "customerId": "7654321", "userType": "SENIOR", "productIds": ["ENT:EntitlementProduct:levelA1"] } ] }

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:

JSONCode
{ "offerConfigurations": [ { ... "offerId": "55a93db9-4a98-4c00-820f-cf43f15046e7", // offerId from step 3 "customers": [ { "customerId": "1234567", "entitlements": [ { "contractId": "5d3e9d2d-f9ac-4dd0-a735-100886278e0b", // contractUUID from ticket right "entitlementProductRef": { "id": "ENT:EntitlementProduct:levelA1" // productId from ticket right } } ] } ] ... } ] }

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:

WhenStatusException
Reserve offers (step 4)400 Bad RequestInvalidContractConsumptionException
Distribute tickets (after purchase)409 ConflictInvalidContractException

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

Last modified on
Did you find what you were looking for?