Create a session#
On this page
Create an ID Check session for one user, and get the link that starts it in the BankID app.
POST https://handover.prod.idcheck.bankid.no/api/v1/sessionSee the Handover API spec for full request and response schemas.
How it fits#
- Each request creates a new session with a new
id. - Give the user the
intent_urlfrom the response. On a phone, show it as a link. On a computer, show it as a QR code that the user scans with their phone. - If nobody opens the session, it expires after 5 minutes.
- To show the user the progress of the session, fetch the session until its state is final. Never base a decision on the state.
- Someone other than the expected customer can complete the session. Check the results as Check the results describes.
For the full flow, see the process overview.
Request#
Send an access token with the handover:create scope. See Authentication.
| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization header | string | Yes | Bearer <<ACCESS_TOKEN>> |
Content-Type header | string | Yes | application/json |
Send the body as JSON, in this envelope:
| Parameter | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | A unique ID for the request, such as a UUID. The Handover API returns it in the response. |
timestamp | string | Yes | The time of the request, in UTC, in ISO 8601 format. |
payload | object | Yes | The values of the session, as in the next table. |
Put these values in payload:
| Parameter | Type | Required | Description |
|---|---|---|---|
client_reference | string | Yes | The merchant's own reference for the session. See Client reference. |
reason | string | Yes | REIDENTIFICATION or TESTING. New values may be added in the future and may influence what users see in the BankID app when verifying their identity. |
success_url | string | Yes | The URL that the BankID app opens when the user completes ID Check. See Success and failure URLs. |
failure_url | string | Yes | The URL that the BankID app opens when ID Check fails or the user cancels it. See Success and failure URLs. |
If a value is missing or not valid, the response is 400 Bad Request. The message names the value, for example Invalid property: success_url.
POST /api/v1/session HTTP/1.1
Host: handover.prod.idcheck.bankid.no
Authorization: Bearer <<ACCESS_TOKEN>>
Content-Type: application/json
{
"request_id": "75a1f89f-3569-4bd1-81ca-ae2ad173d1b2",
"timestamp": "2021-06-22T11:53:27.689Z",
"payload": {
"client_reference": "2e496a55-3b51-4180-be71-bfd396043065",
"reason": "REIDENTIFICATION",
"success_url": "https://example.com/id-check/success",
"failure_url": "https://example.com/id-check/failure"
}
}Client reference#
- Use the client reference to match the session and its results to the expected customer in the merchant's system.
- Send 1 to 64 characters. Use only
A–Z,a–z,0–9,.,_,:,~and-. A UUID meets these rules. - Use a new value for each session. The Handover API does not check this.
- Do not put personal data in the client reference, such as a national identity number, a user ID or an email address.
- The Handover API returns the client reference with the session, and ID Check puts it in the JSON file of the results.
Success and failure URLs#
- Send absolute URLs, such as
https://example.com/id-check/success. - The BankID app opens the URL on the user's phone when the session ends in the app. This also applies when the user started on a computer. The pages at these URLs must work on a phone.
- The Handover API adds the session ID to both URLs as the query parameter
id. If a URL already has anidparameter, the Handover API replaces its value. - The BankID app adds the query parameter
codeto the failure URL. See Redirect codes.
This is an example of a failure URL that the BankID app opens:
https://example.com/id-check/failure?id=3fa85f64-5717-4562-b3fc-2c963f66afa6&code=USER_CANCELLEDRedirect codes#
The code parameter on the failure URL can have these values:
| Code | Meaning |
|---|---|
BAD_DOCUMENT | The app could not accept the identity document. For example, the document has expired, or the app could not read its chip. |
BAD_PERSON | The face scan failed. |
CLIENT_FAILURE | An error occurred in the BankID app. For example, the phone cannot read near-field communication (NFC) chips. |
SERVER_FAILURE | A server returned an error to the BankID app. |
SESSION_TIMEOUT | The session expired, or it was not available. |
USER_CANCELLED | The user cancelled ID Check. |
The iOS app and the Android app can send different codes for the same problem.
These codes are not the same as the code values of a session. For those, see Failure codes.
Response#
A successful request returns 202 Accepted and the new session in payload.
{
"payload": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"branch_id": "e2c236a3-01f2-44a6-bb2a-1350938d84e4",
"human_id": "not-used-1234",
"client_reference": "2e496a55-3b51-4180-be71-bfd396043065",
"state": "created",
"reason": "REIDENTIFICATION",
"artefact_type": "PDF",
"success_url": "https://example.com/id-check/success?id=3fa85f64-5717-4562-b3fc-2c963f66afa6",
"failure_url": "https://example.com/id-check/failure?id=3fa85f64-5717-4562-b3fc-2c963f66afa6",
"intent_url": "https://prod.idcheck.bankid.no/start?handoverId=3fa85f64-5717-4562-b3fc-2c963f66afa6",
"last_update": "2021-06-22T11:53:28.150Z",
"qr_svg_path": "<<SVG_PATH_DATA>>",
"play_store_url": null,
"apple_store_url": null
},
"request_id": "75a1f89f-3569-4bd1-81ca-ae2ad173d1b2",
"response_id": "response:0b3f8c5e-2f4a-4f7e-9c1d-5a6b7c8d9e0f",
"timestamp": "2021-06-22T11:53:28.153Z"
}The envelope has these properties:
| Property | Type | Description |
|---|---|---|
payload | object | The session. |
request_id | string | The request_id from the request. |
response_id | string | An ID for the response. Give it to Stø in each problem report. |
timestamp | string | The time of the response, in UTC, in ISO 8601 format. |
The session has these properties:
| Property | Type | Description |
|---|---|---|
id | string | The session ID, a UUID. Use it to fetch the session. |
branch_id | string | The ID of the integration in ID Check. The BankID app uses it to show the name and logo of the merchant. |
human_id | string | Deprecated. Ignore it. |
client_reference | string | The client reference from the request. |
policy | string | The name of the rules that ID Check uses to check the identity document. It is present only when the session has such rules. The integration can ignore it. |
state | string | The state of the session. See Session states. |
code | string | The failure code. It is present only in some sessions with the state failed. See Failure codes. |
reason | string | The reason from the request. |
artefact_type | string | Deprecated. Ignore it. |
success_url | string | The success URL from the request, with the session ID added as id. |
failure_url | string | The failure URL from the request, with the session ID added as id. |
intent_url | string | The link that starts the session in the BankID app. On a phone, show it as a link. On a computer, show it as a QR code. |
last_update | string or null | The time of the last change to the session, in ISO 8601 format, or null. |
qr_svg_path | string | Deprecated. SVG path data for a QR code of intent_url. Make a QR code from intent_url instead. |
play_store_url | null | Not used. The value is always null. |
apple_store_url | null | Not used. The value is always null. |
Stø does not remove properties from version 1 of the API.
Session states#
| State | Meaning | Final |
|---|---|---|
created | The Handover API created the session. Nobody has opened it yet. | No |
started | The user opened the session in the BankID app. | No |
mrz_completed | The app read the machine-readable zone (MRZ) of the identity document. | No |
nfc_completed | The app read the chip in the identity document. | No |
face_match_retry | The face scan failed, and the user can try again. | No |
completed | The user completed ID Check. | Yes |
failed | The session failed. code can give the reason. | Yes |
aborted | The user cancelled ID Check in the app. | Yes |
expired | Nobody opened the session in time. | Yes |
- A session moves forward through the states. It can skip states, so a poll does not always show each state.
- A session expires only if nobody opens it.
- If the user stops after opening the session, the state changes to
failedwith the codeABANDONED. - A final state does not change.
- The state can change after the results arrive, or not at all. Use it only to show the user information.
Failure codes#
When the state is failed, code can have these values:
| Code | Meaning |
|---|---|
ABANDONED | The user did not finish. There was no progress for 15 minutes, or the session was not complete 1 hour after the user started it. |
BAD_DOCUMENT | The identity document failed the checks. |
BAD_PERSON | The face scan failed. |
CLIENT_FAILURE | The BankID app could not continue. For example, ID Check could not verify the requests of the app, or the document reader returned an error. |
SERVER_FAILURE | An error stopped the session. |
A session with the state aborted has no code. A session with the state failed can have no code, or a code that is not in this table. Handle these as a failure with no known reason.
Errors#
Errors use the same envelope as a successful response. In payload, code identifies the error and message describes it. Use code in the integration logic, because the message can change.
| Status | code | Cause |
|---|---|---|
400 Bad Request | EINVALIDREQUEST | A value is missing or not valid, or the body has no request_id or payload. |
401 Unauthorized | EUNAUTHORISED | The access token is not valid or has expired, or the API client is not set up correctly. |
403 Forbidden | EFORBIDDEN | The request has no Authorization header, or the access token does not have the handover:create scope. |
406 Not Acceptable | EINVALIDCONTENTTYPE | The request has a Content-Type header with a value other than application/json. |
500 Internal Server Error | EUNKNOWN | An error occurred in the Handover API. |
503 Service Unavailable | EUNAVAILABLE | The service is not available. Wait for the time in the Retry-After header, then try again. |
{
"payload": {
"code": "EINVALIDREQUEST",
"message": "Invalid property: success_url"
},
"request_id": "75a1f89f-3569-4bd1-81ca-ae2ad173d1b2",
"response_id": "response:9d8c7b6a-5f4e-4d3c-8b2a-1f0e9d8c7b6a",
"timestamp": "2021-06-22T11:53:28.153Z"
}A request that does not return 202 Accepted returns no session. To try again, send a new request.
Next steps#
- Fetch a session: read the state of the session, to show it to the user.
- Receive the results: how ID Check sends the results of a completed session.
- Check the results: verify the results and compare them with the expected customer.
- Handover API spec: the full request and response schemas.