Skip to main content
In this guide, you verify a person’s identity with sajn ID. sajn sends the person a link by email or SMS, the person identifies with Swedish BankID, and you get the result. Use it before you grant access to a service, open an account, or send a contract. sajn ID checks the identity in one of two ways:
  • With a national identity number: when you send nationalId, BankID checks that the person has that number.
  • With the name: without nationalId, BankID checks that the person’s name matches fullName. Use this when you don’t need the identity number.

Before you begin

  • Store your API key in the SAJN_API_KEY environment variable. To create a key, go to workspace settings in the sajn app, then Utvecklare (Developer) > API-nycklar (API keys).
  • Subscribe a webhook endpoint to identity_check.verified, identity_check.failed, and identity_check.cancelled. For more information, see Webhooks.
  • Each check counts toward your organization’s monthly identity check quota.

Run an identity check

1

Create the check

Send a POST request to /api/v1/identity-checks. Creating the check also sends it, so there’s no separate send step:
The request takes the following fields:
  • fullName and channel are required. With "channel": "SMS", send phone instead of email.
  • nationalId makes BankID check the identity number.
  • reference is your own ID for the check, returned in the check and its webhook events.
  • contactId links the check to a contact.
  • language is the language of the messages, as an ISO 639-1 code such as en. The default is sv.
  • expiresAt is when the link stops working. The default is seven days after creation.
The response is the check. Store its id. Only this response has verificationUrl, in case you want to show the link yourself:
2

Get the result

When the person finishes, sajn sends an identity_check.verified event. A failed or cancelled check sends identity_check.failed or identity_check.cancelled, and identity_check.failed adds the reason in data.failureReason. The event’s data.object is the check, so find your record by its reference:
markVerified and markFailed stand for your own code. To verify the signature, see Verify webhook signatures. For the full event, see Webhook payloads.To read the check without webhooks, poll it:
Replace CHECK_ID with the check id. status moves through CREATED, SENT, OPENED, and ends at VERIFIED, FAILED, EXPIRED, or CANCELLED. A verified check also has verifiedAt, the BankID result in data, and its event history in audits.
The BankID result in data contains personal data, such as the identity number. Store only what you need.

List checks

GET /api/v1/identity-checks lists the organization’s checks, newest first. Filter with status, such as status=VERIFIED,FAILED, and with createdAfter, createdBefore, updatedAfter, and updatedBefore. The response has the checks in data, each with audits, data, and verificationUrl set to null. To read audits and data, get the check by ID. While hasMore is true, pass nextCursor as cursor to get the next page. For more information, see Pagination.

Handle errors

  • 400 VALIDATION_FAILED: fullName or channel is missing, the channel’s address is missing, or expiresAt isn’t in the future.
  • A check with status FAILED: the person canceled, BankID failed, or the name or identity number didn’t match. The person can open the link again until it expires. Otherwise, create a new check.
  • A check with status EXPIRED: the person didn’t finish before expiresAt. Create a new check.
For the error shape and every code, see Errors.

Next steps

Verify identity before signing

Run a sajn ID check, then send a contract.

sajn ID

Learn how sajn ID works.

Set the signing method

Verify identity as part of signing instead.

Create an identity check

See the endpoint in the API reference.