Skip to main content
Developer

Create a session#

View as Markdown
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/session

See 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_url from 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.

ParameterTypeRequiredDescription
Authorization headerstringYesBearer <<ACCESS_TOKEN>>
Content-Type headerstringYesapplication/json

Send the body as JSON, in this envelope:

ParameterTypeRequiredDescription
request_idstringYesA unique ID for the request, such as a UUID. The Handover API returns it in the response.
timestampstringYesThe time of the request, in UTC, in ISO 8601 format.
payloadobjectYesThe values of the session, as in the next table.

Put these values in payload:

ParameterTypeRequiredDescription
client_referencestringYesThe merchant's own reference for the session. See Client reference.
reasonstringYesREIDENTIFICATION 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_urlstringYesThe URL that the BankID app opens when the user completes ID Check. See Success and failure URLs.
failure_urlstringYesThe 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 an id parameter, the Handover API replaces its value.
  • The BankID app adds the query parameter code to 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_CANCELLED

Redirect codes#

The code parameter on the failure URL can have these values:

CodeMeaning
BAD_DOCUMENTThe app could not accept the identity document. For example, the document has expired, or the app could not read its chip.
BAD_PERSONThe face scan failed.
CLIENT_FAILUREAn error occurred in the BankID app. For example, the phone cannot read near-field communication (NFC) chips.
SERVER_FAILUREA server returned an error to the BankID app.
SESSION_TIMEOUTThe session expired, or it was not available.
USER_CANCELLEDThe 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:

PropertyTypeDescription
payloadobjectThe session.
request_idstringThe request_id from the request.
response_idstringAn ID for the response. Give it to Stø in each problem report.
timestampstringThe time of the response, in UTC, in ISO 8601 format.

The session has these properties:

PropertyTypeDescription
idstringThe session ID, a UUID. Use it to fetch the session.
branch_idstringThe ID of the integration in ID Check. The BankID app uses it to show the name and logo of the merchant.
human_idstringDeprecated. Ignore it.
client_referencestringThe client reference from the request.
policystringThe 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.
statestringThe state of the session. See Session states.
codestringThe failure code. It is present only in some sessions with the state failed. See Failure codes.
reasonstringThe reason from the request.
artefact_typestringDeprecated. Ignore it.
success_urlstringThe success URL from the request, with the session ID added as id.
failure_urlstringThe failure URL from the request, with the session ID added as id.
intent_urlstringThe 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_updatestring or nullThe time of the last change to the session, in ISO 8601 format, or null.
qr_svg_pathstringDeprecated. SVG path data for a QR code of intent_url. Make a QR code from intent_url instead.
play_store_urlnullNot used. The value is always null.
apple_store_urlnullNot used. The value is always null.

Stø does not remove properties from version 1 of the API.

Session states#

StateMeaningFinal
createdThe Handover API created the session. Nobody has opened it yet.No
startedThe user opened the session in the BankID app.No
mrz_completedThe app read the machine-readable zone (MRZ) of the identity document.No
nfc_completedThe app read the chip in the identity document.No
face_match_retryThe face scan failed, and the user can try again.No
completedThe user completed ID Check.Yes
failedThe session failed. code can give the reason.Yes
abortedThe user cancelled ID Check in the app.Yes
expiredNobody 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 failed with the code ABANDONED.
  • 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:

CodeMeaning
ABANDONEDThe 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_DOCUMENTThe identity document failed the checks.
BAD_PERSONThe face scan failed.
CLIENT_FAILUREThe 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_FAILUREAn 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.

StatuscodeCause
400 Bad RequestEINVALIDREQUESTA value is missing or not valid, or the body has no request_id or payload.
401 UnauthorizedEUNAUTHORISEDThe access token is not valid or has expired, or the API client is not set up correctly.
403 ForbiddenEFORBIDDENThe request has no Authorization header, or the access token does not have the handover:create scope.
406 Not AcceptableEINVALIDCONTENTTYPEThe request has a Content-Type header with a value other than application/json.
500 Internal Server ErrorEUNKNOWNAn error occurred in the Handover API.
503 Service UnavailableEUNAVAILABLEThe 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#

Was this page helpful?