Samtrafiken Connect Quick Start Guide version 1.8
Version: 1.8
Updated at: 2025-04-01
- 1 Introduction
- 2 APIs
- 2.1.1 Device Management API
- 2.1.1.1 POST /device-challenges
- 2.1.1.2 POST /device-keys
- 2.1.1.3 GET /user-agents
- 2.1.1.4 GET /user-agents/{ua}
- 2.1.2 Samtrafiken Connect API
- 2.1.2.1 GET /participants
- 2.1.2.2 GET /participants/{pid}
- 2.1.2.3 POST /alternatives
- 2.1.2.4 GET /alternatives/{alternativeId}
- 2.1.2.5 POST /manifests
- 2.1.2.6 GET /manifests/{manifestId}
- 2.1.2.7 POST /ticket-bundles
- 2.1.2.8 GET /ticket-bundles/{ticketBundleId}
- 2.1.2.9 PATCH /ticket-bundles/{ticketBundleId}
- 2.1.2.10 GET /ticket-bundles/{ticketBundleId}/jobs/{jobId}
- 2.1.1 Device Management API
- 2.2 Requirements on a retailer using Samtrafiken’s APIs
- 3 Getting Started
- 3.1 Fetching Device ID and Device Key
- 3.2 Getting Participant information
- 3.3 Fetch tickets from ticket issuers
- 3.4 Updating a Ticket Bundle
- 3.4.1 Activate tickets in a Ticket Bundle
- 3.4.2 Update MTB Issuer Signature
- 3.4.3 Device ID update
- 3.4.4 Forced Device ID updates
- 3.4.5 Refund
- 3.4.6 Force Refund
- 3.4.7 Revoke
- 3.4.8 Asynchronous Operation
- 3.4.8.1 How to Use Asynchronous Execution
- 3.4.8.2 Retries
- 4 Propagation of Organization-Code and Sales-Unit-Code Headers
- 4.1 Purpose
- 4.2 Implementation
- 4.3 Example
- 5 Error Handling and RFC 9457 Compliance
Introduction
Samtrafiken provides an access point enabling third party retailers to fetch products and tickets from ticket issuing BoB Participants, such as PTAs. For more information on the BoB standard, please visit BoB - National Ticket & Payment Standards for Public Transport 1.
This guide aims to describe the APIs Samtrafiken makes available, and an introduction on how to use them. It is assumed that readers of this guide have some basic knowledge of BoB concepts.
APIs
The following APIs enable retailers to fetch and manage BoB tickets from ticket issuers:
Samtrafiken Device Management API - allows retailers to fetch the Device IDs and Device Keys required to add the Device Signature (adding copy protection) to an MTB
Samtrafiken Connect API - allows retailers to fetch products and tickets from ticket issuers
Please note that neither of these are standard BoB APIs. The BoB APIs are designed for one-to-one integrations, eg. for a retailer to fetch BoB Products from a ticket issuer using a certain version of the BoB Product API. Samtrafiken Connect API and Samtrafiken Device Management API however are proprietary APIs enabling:
A BoB version independent way of performing certain BoB operations towards connected ticket issuers:
Retrieve ticket issuers' traveller categories and product categories
Retrieve BoB Products
Retrieve BoB Tickets
Refund BoB Tickets
Revoke BoB Tickets
Device ID and Device Key creation
Authentication using Auth2/OpenID Connect
For detailed information about authentication processes, refer to the Samtrafiken Authentication Guide. This guide provides comprehensive instructions on implementing OAuth2 and OpenID Connect for secure access.
The APIs are documented using the Open API 3 specification format.
The APIs are not BoB APIs, but they share concepts and terminology with the BoB APIs, in order to ease understanding and compatibility for retailers that have already invested in BoB.
Device Management API
Samtrafiken Device Management API enables retailers to conveniently create Device IDs and Device Keys. Device IDs and Device Keys are used to create the Device Signature, i.e. the outer signature of an MTB (see MTS12 of the BoB Standard).
POST /device-challenges
Post an app public key (in JWK format) to retrieve a device challenge
POST /device-keys
Post the challenge and the challenge signature (in P1363 format). Note: The P1363 format specifies that the
randscomponents of the signature are concatenated. This format differs from the DER/ASN.1 standard.The user agent client hint request headers (SecSH-UA et al.) can be used to specify the branding and version of the user-agent making the request; see MDN Web Docs page describing the Sec-SH-UA header3 for further details.
A Device ID is returned upon successful challenge signature validation
The Device ID is to be used in the field did of the Device Signature Protected Header.
It is also used in subsequent calls to the Samtrafiken Connect API, endpoints
POST /ticket-bundlesandPATCH /ticket-bundles/{ticketBundleId}
If user agent client hint headers were provided in the request, a user agent ID (ua) is returned
Use this user agent ID in the field ua in the Device Signature Protected Header of the MTB. The ID will then be available to a validator validating the MTB.
The user agent ID can later on be used to get the information sent in via the user agent client hint headers. This may help pinpointing errors as information about the ticket bearer device, such as device model, operating system, app and app version, becomes available to the ticket issuer.
An encrypted Device Key is returned
Store the Device Key encrypted on the device
Use the app private key to decrypt it
Use the Device Key to create the Device Signature of the MTB
In test environments or during pilot deployments, there is an option to disable device key encryption.
GET /user-agents
Retrieves the complete set of user agents
GET /user-agents/{ua}
Retrieves a specific user agent
Samtrafiken Connect API
GET /participants
Retrieves information about connected Participants (ticket issuers), including details on the traveller categories and product categories they offer
GET /participants/{pid}
Retrieves information about a specific connected Participant
POST /alternatives
Find ticket alternatives matching specified criteria
Alternatives contain one or more products, which represent offerings from the ticket issuer
An Alternative may contain several products from a single ticket issuer
An Alternatives expiry date-time is set to the earliest product expiry date-time. If no products have an expiry date-time, the end of the current UTC day is used as default (i.e., 23:59:59 UTC).
GET /alternatives/{alternativeId}
Retrieves a previously fetched Alternative
POST /manifests
Generates a Manifest from a specified selection of Alternatives. A Manifest serves as a binding contract, confirming that a ticket meeting the selected Alternative can be issued.
GET /manifests/{manifestId}
Retrieves a previously fetched Manifest
POST /ticket-bundles
Fetch a Ticket Bundle containing tickets corresponding to theMmanifest received in the preceding manifest call
The Manifest
The startOfValidity property states the date and time for the start of the relative validity, i.e. the time frame in which the ticket is valid for travelling
The deviceId must be provided by the client, this ties the MTB to a specific device. Note: since it is mandatory to provide a Device ID, it follows that no tickets can be issued to non-app clients.
The signatureLifetime enables clients to request a shorter signature expiry
The MTB returned by Samtrafiken is signed using Samtrafiken’s MTB Signing Key
The signatureExpiresAt returned by Samtrafiken indicates when the MTB issuer signature expires and must be updated.