- Create authentication token
Universal token creation with consistent token-in-body pattern.
- Header:
x-project-key(tenant identification) - Body:
{ authToken: "jwt_from_provider", authType: "user" } - Returns: User session with PERS JWT tokens
- Header:
x-project-key(tenant identification) - Body:
{ authToken: "jwt_from_provider", authType: "business", context: { businessId: "uuid" } } - Returns: Business session with PERS JWT tokens (includes
rolein JWT) - If user has single business membership,
context.businessIdis auto-selected - If user has multiple memberships without
context.businessId, returnsMULTIPLE_CONTEXT_SELECTION_REQUIREDerror with available options
- Header:
x-project-key(tenant identification) - Body:
{ authToken: "firebase_jwt", authType: "tenant" } - Returns: Admin session with PERS JWT tokens
When providing authToken from an external identity provider, the JWT must meet these requirements:
| Field | Required | Description |
|---|---|---|
kid | Yes | Key ID matching a key in your JWKS |
alg | Yes | Signing algorithm (RS256, ES256, EdDSA) |
| Claim | Required | Description |
|---|---|---|
iss | Yes | Issuer URL (used for JWKS discovery) |
sub | Yes | Subject identifier (user ID) |
aud | Yes | Audience (your registered client ID) |
exp | Yes | Expiration timestamp (Unix epoch) |
iat | Yes | Issued at timestamp (Unix epoch) |
Your identity provider must expose public keys via one of:
{issuer}/.well-known/jwks.json(JWKS endpoint){issuer}/.well-known/openid-configuration(OIDC discovery withjwks_uri)
- PERS extracts
issclaim from JWT - Fetches JWKS from
{issuer}/.well-known/jwks.json - Matches
kidheader to find signing public key - Verifies signature using matched key
- Validates
exp,iat,audclaims - Issues PERS access/refresh tokens on success
- JWKS:
https://api.pers.ninja/.well-known/jwks.json - Discovery:
https://api.pers.ninja/.well-known/openid-configuration
Authentication request with token and type. authType defaults to "user" if not specified.
Authentication token from identity provider (WebAuthn, DFNS, Firebase, Auth0, etc.).
Third-Party JWT Requirements:
- Header:
kid(Key ID matching JWKS),alg(RS256/ES256/EdDSA) - Payload Claims:
iss(issuer URL),sub(user ID),aud(audience),exp,iat - Provider Requirement: Must expose JWKS at
{issuer}/.well-known/jwks.json
PERS will automatically discover and fetch the issuer's public keys for verification.
Authentication context type - explicitly declares intent for admin vs user auth
Optional context for explicit business/tenant selection. Required when user has multiple memberships of that type.
if Tenant settings allowJWTForUnauthenticatedUsers is true, this field contains data to create user and setup unauthenticated user session instead of token verification. Useful for sandbox or trial modes. For now it is only used to create unauthenticated users.
{ "externalId": "", "email": "user@example.com", "firstName": "", "lastName": "", "customData": {} }
- Mock serverhttps://docs.pers.ninja/_mock/swagger/auth/token
- https://api.pers.ninja/v2https://api.pers.ninja/v2/auth/token
curl -i -X POST \
https://docs.pers.ninja/_mock/swagger/auth/token \
-H 'Content-Type: application/json' \
-H 'x-project-key: YOUR_API_KEY_HERE' \
-d '{
"authToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6ImtleS0xIn0.eyJpc3MiOiJodHRwczovL2lkcC5leGFtcGxlLmNvbSIsInN1YiI6InVzZXItMTIzIiwiYXVkIjoieW91ci1jbGllbnQtaWQiLCJleHAiOjE3MzM0MDAwMDAsImlhdCI6MTczMzM5NjQwMH0.signature",
"authType": "user",
"context": {
"businessId": "550e8400-e29b-41d4-a716-446655440000",
"tenantId": "550e8400-e29b-41d4-a716-446655440001"
},
"rawLoginData": {
"externalId": "",
"email": "user@example.com",
"firstName": "",
"lastName": "",
"customData": {}
}
}'Token created successfully
refresh token
{ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRJZCI6IjEiLCJpYXQiOjE2MjYxNzUwNzksImV4cCI6MTYyNjE3NTI3OX0.5w8A6t7b5lBx8D3FmLwJQgJ9z1D9c9Vz7A3f7BvzH2A", "accessToken": "string" }