Reference documentation

1. Endpoints

1.1 POST /contacts/email

Search for an SJ customer by e-mail address.

Query string parameters

None

Request body

{ 
   “email”: “string” 
} 

email

optionality: required

nullable: no

empty allowed: no

comment: Must be URL encoded

Example request

{
   "email": "myemailaddress@sjmail.se"
}

Response body 200

A Customer object (see schema definitions)

Response body 404

There is no SJ customer with this email address.

1.2 POST /contacts/prio-number

Search for an SJ customer by SJ Prio membership number

Query string parameters

None

Request body

{ 
   “memberNumber”: “string” 
} 

memberNumber

optionality: required

Nullable: no

Empty allowed: no

Comment: Note that “Prio membership number” is not the same as “Prio number”

Example request

{  
   "memberNumber": "9752210230122059"  
} 

Response body 200

A Customer object (see schema definitions)

Response body 404

There is no SJ customer with this SJ Prio membership number.

1.3 POST /contacts/ssn

Search for an SJ customer by Personal Identity Number (Personnummer)

Querystring parameters

None

Request body

{ 
   “ssn”: “string” 
} 

ssn

optionality: required

nullable: no

empty allowed: no

Example request

{
    "ssn": "199101262385"
}

Response body 200

A Customer object (see schema definitions)

Response body 404

There is no SJ customer with this personal identity number.

1.4 POST contracts/contract-number

Search for an SJ corporate contract by its corporate code.

Querystring parameters

None

Request body

{
    “contractNumber”: “string”
}

contractNumber

optionality: required

nullable: no

empty allowed: no

Example request

{
   "contractNumber": "800183"
}

Response body 200

A Contract object (see schema definitions)

Response body 404

There is no SJ corporate contract with this code.

2. Schema definitions

2.1 Customer

{ 
    "firstName": "string", 
    "lastName": "string", 
    "memberNumber": "string", 
    "level": "string", 
    "email": "string", 
    "phoneNumber": "string", 
    "travelPasses": [ 
        { 
            "cardNumber": "string", 
            "cardType": "string", 
            "description": "string", 
            "validFrom": "datetime", 
            "validTo": "datetime" 
        } 
    ] 
}

Customer properties

NameJSON typeDomain typeOptionalityNullableEmpty allowed
firstNamestringrequiredyes
lastNamestringrequiredyes
memberNumberstringPrio card code
levelstringPrio level enum nameyes
emailstringemail addressrequiredyes
phoneNumberstringphone numberrequiredyes
travelPassesarrayoptionalyes

Travel pass properties

NameJSON typeDomain typeOptionalityNullableEmpty allowedComment
cardNumberstringrequiredyes
cardTypestringrequiredyesExample: SJ_ANNUAL_GOLD
descriptionstringrequiredyesExample: "SJ Årskort Guld"
validFromstringrequiredyes
validTodatetimerequiredyes

Example customer

{ 
    "firstName": "Oscaro", 
    "lastName": "Carlssonf", 
    "memberNumber": "9752210236055741", 
    "level": " SJ_PRIO_BLACK", 
    "email": "oscaro.carlssonf.nosmsmfa@sjmail.se, 
    "phoneNumber": "+55504535306", 
    "travelPasses": [ 
        { 
            "cardNumber": "9752209709109276",              
            "cardType": "SJ_ANNUAL_GOLD", 
            "description": "SJ Årskort Guld", 
            "validFrom": "2023-11-24", 
            "validTo": "2024-11-24" 
        } 
    ] 
} 

2.2 Contract

{ 
    "organizationName": "string", 
    "department": "string", 
    "contractNumber": "string", 
    "organizationNumber": "string" 
}

Contract properties

NameJSON typeDomain typeOptionalityNullableEmpty allowed
organizationNamestringrequirednono
departmentstringrequiredyesyes
contractNumberstringSJ corporate coderequirednono
organizationNumberstringrequirednono

3. Miscellaneous

3.1 Authentication

Customer API uses the same authentication method as R-API, OAuth2 Client Credentials flow.

The client ID and client secret for R-API are also valid for Customer API.

3.2 Required headers

  • Ocp-Apim-Subscription-Key
  • Authorization header with Bearer token
  • Requestor header is not needed.