Authentication
Start authentication
The POST /v3/bankid-se/auth endpoint is used to start an authentication using BankID (SE).
POST /v3/bankid-se/auth
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
{
"ssn": "YYYYMMDDXXXX",
"ipAddress": "8.8.8.8",
"pinRequired": true,
"intent": "Intention text",
"orgNumber": "559000-0948",
"requestAddress": false,
"callbackUrl": "https://...",
"refId": "12398698"
}
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/bankid-se/auth \
-H 'Content-Type: application/json' \
-d '{
"ssn": "YYYYMMDDXXXX",
"ipAddress": "8.8.8.8",
"callbackUrl": "https://example.com/callback",
"pinRequired": true,
"intent": "Intention text",
"orgNumber": "559000-0948",
"requestAddress": false,
"refId": "12398698"
}'
var status = await client.BankIdSe.AuthAsync(new BankIdSeAuthRequest
{
Ssn = "YYYYMMDDXXXX",
IpAddress = "8.8.8.8",
CallbackUrl = "https://example.com/callback",
PinRequired = true,
Intent = "Intention text",
OrgNumber = "559000-0948",
RequestAddress = false,
RefId = "12398698",
});
final status = await client.bankIdSe.auth(const BankIdSeAuthRequest(
ssn: 'YYYYMMDDXXXX',
ipAddress: '8.8.8.8',
callbackUrl: 'https://example.com/callback',
pinRequired: true,
intent: 'Intention text',
orgNumber: '559000-0948',
requestAddress: false,
refId: '12398698',
));
// func ptr[T any](v T) *T { return &v }
status, err := client.BankIdSe().Auth(ctx, identisure.BankIdSeAuthRequest{
Ssn: ptr("YYYYMMDDXXXX"),
IpAddress: ptr("8.8.8.8"),
CallbackUrl: ptr("https://example.com/callback"),
PinRequired: ptr(true),
Intent: ptr("Intention text"),
OrgNumber: ptr("559000-0948"),
RequestAddress: ptr(false),
RefId: ptr("12398698"),
})
const status = await client.bankidSe().auth({
ssn: "YYYYMMDDXXXX",
ipAddress: "8.8.8.8",
callbackUrl: "https://example.com/callback",
pinRequired: true,
intent: "Intention text",
orgNumber: "559000-0948",
requestAddress: false,
refId: "12398698",
});
import com.identisure.client.models.*;
var status = client.bankIdSe().auth(new BankIdSeAuthRequest()
.setSsn("YYYYMMDDXXXX")
.setIpAddress("8.8.8.8")
.setCallbackUrl("https://example.com/callback")
.setPinRequired(true)
.setIntent("Intention text")
.setOrgNumber("559000-0948")
.setRequestAddress(false)
.setRefId("12398698")
).join();
use Identisure\Client\Models\BankIdSe\BankIdSeAuthRequest;
$status = $client->bankIdSe()->auth(new BankIdSeAuthRequest(
ssn: 'YYYYMMDDXXXX',
ipAddress: '8.8.8.8',
callbackUrl: 'https://example.com/callback',
pinRequired: true,
intent: 'Intention text',
orgNumber: '559000-0948',
requestAddress: false,
refId: '12398698',
));
from identisure_client.models import BankIdSeAuthRequest
status = client.bankid_se().auth(
BankIdSeAuthRequest(
ssn="YYYYMMDDXXXX",
ip_address="8.8.8.8",
callback_url="https://example.com/callback",
pin_required=True,
intent="Intention text",
org_number="559000-0948",
request_address=False,
ref_id="12398698",
)
)
status = client.bank_id_se.auth(
Identisure::BankIdSe::AuthRequest.new(
ssn: 'YYYYMMDDXXXX',
ip_address: '8.8.8.8',
callback_url: 'https://example.com/callback',
pin_required: true,
intent: 'Intention text',
org_number: '559000-0948',
request_address: false,
ref_id: '12398698',
)
)
use identisure_client::models::{BankIdSeAuthRequest, IpAddress, OrgNumber, Pno, Url};
let request = BankIdSeAuthRequest::new()
.ssn(Pno::parse("YYYYMMDDXXXX")?)
.ip_address(IpAddress::parse("8.8.8.8")?)
.callback_url(Url::parse("https://example.com/callback")?)
.pin_required(true)
.intent("Intention text")
.org_number(OrgNumber::parse("559000-0948")?)
.request_address(false)
.ref_id("12398698");
let status = client.bankid_se().auth(request).await?;
let status = try await client.bankIdSe.auth(BankIdSeAuthRequest(
ssn: "YYYYMMDDXXXX",
ipAddress: "8.8.8.8",
callbackUrl: "https://example.com/callback",
pinRequired: true,
intent: "Intention text",
orgNumber: "559000-0948",
requestAddress: false,
refId: "12398698"
))
| Parameter | Required | Description |
|---|---|---|
| ssn | No | A Swedish personal identification number (YYYYMMDDXXXX) to be used to complete the transaction. If a BankID with another personal number attempts to authenticate, it fails. |
| ipAddress | No | The IP-address of the end user, or as close to the end user as possible. |
| pinRequired | No | Require users to sign using their PIN code, even if they have biometrics enabled. |
| intent | No | Text to be displayed in the users BankID app during authentication, for purposes of adding an intention for requesting the authentication. Max 1500 characters after base64. Formatting options can be found here: https://www.bankid.com/en/utvecklare/guider/formatera-text/syntax-specialtecken-atergivning |
| orgNumber | No | Swedish organization number, such as 559000-0948. Used to perform checks for company signatory. To enable this feature, contact IDkollen. |
| requestAddress | No | If set, will request the address of the authenticated user. The functionality needs to be enabled for your company. Contact support to enable requestAddress. |
| callbackUrl | No | Custom callback URL, must be whitelisted. See Callbacks. |
| refId | No | Reference ID which will be included in the result and in the callback. |
IDkollen will respond with HTTP status 201 for successful request, or 4xx/5xx on errors. For more information about errors, please see the Errors section.
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "PENDING",
"autoStartToken": "6e8fdb9e-4cc7-42a7-9ce7-59947aeec6e6",
"qrStartToken": "8b9c387f-8948-4b53-b6a5-519eee985d44",
"qrStartSecret": "f47d75e0-6662-4bb9-9b09-ca37849ef1e0",
"hintCode": "started"
}
| Property | Description |
|---|---|
| id | Authentication id, used to cancel or get the status of this authentication request. |
| refId | The refId given in the request, if any. |
| autoStartToken | A token used to launch the BankID app on the same device. See https://www.bankid.com/utvecklare/guider/teknisk-integrationsguide/programstart |
| qrStartToken | A token used, in combination with the qrStartSecret, to generate an animated QR code to authenticate using BankID on another device. See https://www.bankid.com/utvecklare/guider/teknisk-integrationsguide/qrkoder |
| qrStartSecret | Used to animate the QR code. |
| hintCode | A string (potentially null) that can be used to provide the user with instructions. See Messages to the user. |
Showing BankID to the user
After starting the authentication, bring the user to BankID in one of two ways. Most sites offer both: a QR code on desktop, and a button that opens the app on mobile.
QR code, for BankID on another device. The QR code changes every second, so generate it in your backend from
qrStartToken and qrStartSecret. Never send qrStartSecret to the browser. The content of the QR code is:
bankid.{qrStartToken}.{qrTime}.{qrAuthCode}
qrTime: the number of whole seconds since you received the response, starting at0.qrAuthCode: the hex-encoded HMAC SHA-256 ofqrTime(as a string), withqrStartSecretas the key.
For example, in Node.js:
import { createHmac } from "node:crypto";
function qrData(qrStartToken, qrStartSecret, startedAt) {
const qrTime = Math.floor((Date.now() - startedAt) / 1000).toString();
const qrAuthCode = createHmac("sha256", qrStartSecret).update(qrTime).digest("hex");
return `bankid.${qrStartToken}.${qrTime}.${qrAuthCode}`;
}
Let your frontend fetch a fresh value from your backend every second, together with the status, and render it with any
QR code library. Stop when the status is no longer PENDING. More details, including the recommended QR code size, are
in BankID's QR code guide.
App start, for BankID on the same device. Open this link with the autoStartToken:
https://app.bankid.com/?autostarttoken={autoStartToken}&redirect=null
On desktop, bankid:///?autostarttoken={autoStartToken}&redirect=null opens BankID for desktop. Open the link directly
from a user action such as a button click, or the browser may block it. See BankID's
app start guide for the
redirect parameter on mobile.
Messages to the user
While the flow is PENDING, hintCode tells you what the user is doing, so you can guide them:
| hintCode | Situation | Suggested message |
|---|---|---|
| outstandingTransaction | The order is created, and BankID has not been opened yet. | Start your BankID app. |
| noClient | BankID has not been opened yet (app start). | Start your BankID app. |
| started | The user opened BankID but has not finished. | Searching for BankID, it may take a little while. |
| userSign | The user is entering their security code or using biometrics. | Enter your security code in the BankID app. |
| userMrtd | The user is asked to scan their passport or ID card. | Scan your ID document with the BankID app. |
| userCallConfirm | The user is asked to confirm the phone call (phone auth). | Confirm the call in the BankID app. |
Other codes may appear. Show a general message such as "Identifying with BankID" for codes you don't recognize. BankID recommends specific wording for each situation, see the BankID integration guide.
Phone auth
The POST /v3/bankid-se/phone/auth endpoint can be used to start an authentication using BankID when the user is talking to the user over the phone.
This method will trigger the users BankID app to start the authentication using an SSN alone.
This is an addon feature. Contact us at support@idkollen.se to enable this feature.
POST /v3/bankid-se/phone/auth
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
{
"ssn": "YYYYMMDDXXXX",
"callInitiator": "USER",
"pinRequired": true,
"intent": "Intention text",
"orgNumber": "559000-0948",
"requestAddress": false,
"callbackUrl": "https://...",
"refId": "12398698"
}
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/bankid-se/phone/auth \
-H 'Content-Type: application/json' \
-d '{
"ssn": "YYYYMMDDXXXX",
"callInitiator": "USER",
"callbackUrl": "https://example.com/callback",
"pinRequired": true,
"intent": "Intention text",
"orgNumber": "559000-0948",
"requestAddress": false,
"refId": "12398698"
}'
var status = await client.BankIdSe.PhoneAuthAsync(new BankIdSePhoneAuthRequest("YYYYMMDDXXXX", "USER")
{
CallbackUrl = "https://example.com/callback",
PinRequired = true,
Intent = "Intention text",
OrgNumber = "559000-0948",
RequestAddress = false,
RefId = "12398698",
});
final status = await client.bankIdSe.phoneAuth(const BankIdSePhoneAuthRequest(
ssn: 'YYYYMMDDXXXX',
callInitiator: 'USER',
callbackUrl: 'https://example.com/callback',
pinRequired: true,
intent: 'Intention text',
orgNumber: '559000-0948',
requestAddress: false,
refId: '12398698',
));
// func ptr[T any](v T) *T { return &v }
status, err := client.BankIdSe().PhoneAuth(ctx, identisure.BankIdSePhoneAuthRequest{
Ssn: "YYYYMMDDXXXX",
CallInitiator: "USER",
CallbackUrl: ptr("https://example.com/callback"),
PinRequired: ptr(true),
Intent: ptr("Intention text"),
OrgNumber: ptr("559000-0948"),
RequestAddress: ptr(false),
RefId: ptr("12398698"),
})
const status = await client.bankidSe().phoneAuth({
ssn: "YYYYMMDDXXXX",
callInitiator: "USER",
callbackUrl: "https://example.com/callback",
pinRequired: true,
intent: "Intention text",
orgNumber: "559000-0948",
requestAddress: false,
refId: "12398698",
});
import com.identisure.client.models.*;
var status = client.bankIdSe().phoneAuth(new BankIdSePhoneAuthRequest()
.setSsn("YYYYMMDDXXXX")
.setCallInitiator(CallInitiator.USER)
.setCallbackUrl("https://example.com/callback")
.setPinRequired(true)
.setIntent("Intention text")
.setOrgNumber("559000-0948")
.setRequestAddress(false)
.setRefId("12398698")
).join();
use Identisure\Client\Models\BankIdSe\BankIdSePhoneAuthRequest;
$status = $client->bankIdSe()->phoneAuth(new BankIdSePhoneAuthRequest(
ssn: 'YYYYMMDDXXXX',
callInitiator: 'USER',
callbackUrl: 'https://example.com/callback',
pinRequired: true,
intent: 'Intention text',
orgNumber: '559000-0948',
requestAddress: false,
refId: '12398698',
));
from identisure_client.models import BankIdSePhoneAuthRequest
status = client.bankid_se().phone_auth(
BankIdSePhoneAuthRequest(
ssn="YYYYMMDDXXXX",
call_initiator="USER",
callback_url="https://example.com/callback",
pin_required=True,
intent="Intention text",
org_number="559000-0948",
request_address=False,
ref_id="12398698",
)
)
status = client.bank_id_se.phone_auth(
Identisure::BankIdSe::PhoneAuthRequest.new(
ssn: 'YYYYMMDDXXXX',
call_initiator: 'USER',
callback_url: 'https://example.com/callback',
pin_required: true,
intent: 'Intention text',
org_number: '559000-0948',
request_address: false,
ref_id: '12398698',
)
)
use identisure_client::models::{BankIdSePhoneAuthRequest, CallInitiator, OrgNumber, Pno, Url};
let request = BankIdSePhoneAuthRequest::new(Pno::parse("YYYYMMDDXXXX")?, CallInitiator::User)
.callback_url(Url::parse("https://example.com/callback")?)
.pin_required(true)
.intent("Intention text")
.org_number(OrgNumber::parse("559000-0948")?)
.request_address(false)
.ref_id("12398698");
let status = client.bankid_se().phone_auth(request).await?;
let status = try await client.bankIdSe.phoneAuth(BankIdSePhoneAuthRequest(
ssn: "YYYYMMDDXXXX",
callInitiator: "USER",
callbackUrl: "https://example.com/callback",
pinRequired: true,
intent: "Intention text",
orgNumber: "559000-0948",
requestAddress: false,
refId: "12398698"
))
| Parameter | Required | Description |
|---|---|---|
| ssn | Yes | The Swedish personal identification number (YYYYMMDDXXXX) of the user to authenticate. |
| callInitiator | Yes | Can be one of: 'USER' or 'RP'. Indicates whether the user or the RP initiated the phone call. |
| pinRequired | No | Require users to sign using their PIN code, even if they have biometrics enabled. |
| intent | No | Text to be displayed in the users BankID app during authentication, for purposes of adding an intention for requesting the authentication. Max 1500 characters after base64. Formatting options can be found here: https://www.bankid.com/en/utvecklare/guider/formatera-text/syntax-specialtecken-atergivning |
| orgNumber | No | Swedish organization number, such as 559000-0948. Used to perform checks for company signatory. To enable this feature, contact IDkollen. |
| requestAddress | No | If set, will request the address of the authenticated user. The functionality needs to be enabled for your company. Contact support to enable requestAddress. |
| callbackUrl | No | See Callbacks. |
| refId | No | Reference ID which will be returned with the status and included in the callback. |
IDkollen will respond with HTTP status 201 for successful request, or 4xx/5xx on errors. For more information about errors, please see the Errors section.
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "PENDING",
"hintCode": "started"
}
| Property | Description |
|---|---|
| id | Authentication id, used to cancel or get the status of this authentication request. |
| refId | The refId given in the request, if any. |
| hintCode | A string (potentially null) that can be used to provide the user with instructions. See Messages to the user. |
Fetch result
As an alternative to receiving a callback from IDkollen on successful or failed requests, you can use the
GET /v3/bankid-se/auth/{{id}} endpoint to check the status of an auth request.
NOTE: This endpoint is rate limited to one request per second. See Errors.
GET /v3/bankid-se/auth/{{id}}
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/bankid-se/auth/$ID
var status = await client.BankIdSe.AuthStatusAsync(id);
final status = await client.bankIdSe.authStatus(id);
status, err := client.BankIdSe().AuthStatus(ctx, id)
const status = await client.bankidSe().authStatus(id);
var status = client.bankIdSe().authStatus(id).join();
$status = $client->bankIdSe()->authStatus($id);
status = client.bankid_se().auth_status(id)
status = client.bank_id_se.auth_status(id)
let status = client.bankid_se().auth_status(&id).await?;
let status = try await client.bankIdSe.authStatus(id: id)
This endpoint will respond with a HTTP status of 404 if the authentication session has expired.
The status of an authentication can be either one of: PENDING, COMPLETED or FAILED.
Pending
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "PENDING",
"hintCode": "started"
}
| Parameter | Description |
|---|---|
| refId | The refId given in the request, if any. |
| hintCode | What the user is doing. See Messages to the user. |
Completed
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "COMPLETED",
"ssn": "YYYYMMDDXXXX",
"name": "Firstname Lastname",
"givenName": "Firstname",
"surname": "Lastname",
"certStartDate": "2020-01-01",
"ocspResponse": "MIIHfgoBAKCCB3cwggdzBgkrBgEFBQcwAQEEggdk...",
"risk": "low",
"device": {
"ipAddress": "192.0.2.1",
"uhi": "OZvYM9VvyiAmG7NA5jU5zqGcVpo="
},
"stepUp": {
"mrtd": true,
"face": false
},
"address": "Address",
"companySignatoryText": "X är företrädare för Y...",
"authenticatedAt": "2024-01-15T13:37:00Z"
}
| Parameter | Description |
|---|---|
| refId | The refId given in the request, if any. |
| ssn | The Swedish personal identification number (YYYYMMDDXXXX) of the authenticated user. |
| name | The full name of the authenticated user. |
| givenName | The given name of the authenticated user. |
| surname | The surname of the authenticated user. |
| certStartDate | The date the BankID was issued to the user (yyyy-MM-dd). |
| ocspResponse | The base64-encoded OCSP response from BankID, proving that the certificate was valid at the time of the order. |
| risk | BankID's risk indication: low, moderate or high. Only present if ipAddress was given in the request and BankID could calculate it. |
| device | Information about the user's device, as seen by BankID. Omitted if BankID returned no device information. |
| device.ipAddress | The IP address of the user's device, as seen by BankID. |
| device.uhi | A unique hardware identifier for the user's device. |
| stepUp | Additional verifications that were part of the order. Omitted if BankID performed none. |
| stepUp.mrtd | Whether a check of a machine readable travel document (MRTD), such as a passport, was performed. |
| stepUp.face | Whether the order was stepped up with facial recognition. |
| address | An address of the authenticated user. May be null if requestAddress was unset, or if no such data is available. |
| companySignatoryText | A text describing whether the authenticated user is a signatory for the given organisation number. |
| authenticatedAt | The time the authentication completed (ISO-8601). |
Failed
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "FAILED",
"error": "INVALID_ID"
}
| Parameter | Description |
|---|---|
| refId | The refId given in the request, if any. |
| error | An error code describing the reason for why the authentication failed. |
The error may be one of the following values:
| Code | Description |
|---|---|
| AUTH_FAILED | A generic code for any kind of failure. |
| CANCELLED | The authentication was cancelled either by the user or the partner. |
| INVALID_ID | The ID has expired or is otherwise invalid. |
| INTERNAL_ERROR | An internal error occurred causing the authentication to fail. |
| SESSION_TIMEOUT | The authentication expired or timed out. |
| UNSUPPORTED_CLIENT | The client used for the authentication is not supported. |
New error codes may be added in the future without prior notice. The partner should therefore handle unknown error codes in their implementations.
Cancel authentication
The DELETE /v3/bankid-se/auth/{{id}} endpoint is used to cancel an ongoing BankID authentication.
DELETE /v3/bankid-se/auth/{{id}}
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" -X DELETE https://api.idkollen.se/v3/bankid-se/auth/$ID
await client.BankIdSe.CancelAuthAsync(id);
await client.bankIdSe.cancelAuth(id);
err := client.BankIdSe().CancelAuth(ctx, id)
await client.bankidSe().cancelAuth(id);
client.bankIdSe().cancelAuth(id).join();
$client->bankIdSe()->cancelAuth($id);
client.bankid_se().cancel_auth(id)
client.bank_id_se.cancel_auth(id)
client.bankid_se().cancel_auth(&id).await?;
try await client.bankIdSe.cancelAuth(id: id)
IDkollen will respond with HTTP status 204 for successful request, or 4xx/5xx on errors. For more information about errors, please see the Errors section.