Skip to main content

REST API

Our REST API is pretty simple. Most of your calls will be against the token endpoint, however users can also be managed via the API. We'll be adding more capabilities to the API over the coming months.

API endpoint

Unless otherwise stated, you should make REST calls against the https://api.passlock.dev endpoint.

Tenancy ID

All endpoints paths should be prefixed with your Tenancy ID: https://api.passlock.dev/{tenancyId}/...

Authentication

All calls to the REST API must be authenticated with your API key. Pass your API Key in an Authorization: Bearer header.

Token exchange

Verify the passkey authentication claims by making a GET request to the token endpoint. If successful, this will return a Principal.

GET /{tenancyId}/token/{token} HTTP/1.1
Host: api.passlock.dev
Authorization: Bearer {apiKey}
Accept: application/json
{
"iss": "https://idp.passlock.dev",
"aud": "0o0b6z1ok95wo9i",
"sub": "hde6mkr591l4a6m",
"iat": 1725882236,
"nbf": 1725882236,
"exp": 1725882604,
"jti": "b1m7exct7l86ujj",
"token": "b1m7exct7l86ujj",
"userVerified": false,
"authType": 'passkey',
"authId": "z4hv4k8uwipooel",
"givenName": "John",
"familyName": "Doe",
"email": "jdoe@gmail.com",
"emailVerified": false
}

Fetching a user record

You can fetch a user without needing a token by making a GET request to the user endpoint:

GET /{tenancyId}/user/{sub} HTTP/1.1
Host: api.passlock.dev
Authorization: Bearer {apiKey}
Accept: application/json
{
"user": {
"sub": "khXCYCxcGwJTLoaG6kVxB",
"email": "jdoe@gmail.com",
"givenName": "John",
"familyName": "Doe",
"emailVerified": false
}
}

Updating a user record

Users can be updated by making a PATCH request to the user endpoint:

PATCH /{tenancyId}/user/{sub} HTTP/1.1
Host: api.passlock.dev
Authorization: Bearer {apiKey}
Accept: application/json
Content-Type: application/json

{
"givenName": "John",
"familyName": "Doe",
"emailVerified": true
}
warning

You can't change a users email address as it is also used by their browser/device as the passkey username.

info

We're working on a changeEmail function that will be added to the client library. This will handle the change on both the frontend and backend, send new verification emails etc. Subscribe to our newletter for updates.