Skip to Content
bpms.ai

Authentication

Sign in, send the token, change the password, and sign out.

Every call under /api/ needs a session token. You get one by signing in with a BPMS username and password, the same ones the user has in BPMS 3.x, and you send it in the Authorization header of every other call.

The examples use BPMS_URL for the address of your server; the Quick start serves it at http://127.0.0.1:8080:

export BPMS_URL=http://127.0.0.1:8080

Sign in

Put the credentials in a login.json file kept out of version control, so the password stays out of your shell history:

{"username": "<username>", "password": "<password>"}
curl -sS -X POST "$BPMS_URL/api/v1/auth/login" \
  -H 'Content-Type: application/json' -d @login.json

The answer is the new session:

{"token": "bpms_...", "expiresAt": "...", "tenant": "tnt_...", "passwordChangeRequired": false}
FieldMeaning
tokenThe session token, shown only in this answer. Treat it as a password.
expiresAtWhen the session ends, 9 hours after sign-in by default.
tenantThe public token of the user's tenant.
passwordChangeRequiredtrue when the user must change the password before anything else.

Send the token

Send the token in the Authorization header of every other call:

TOKEN='<token from the sign-in answer>'
curl -sS -H "Authorization: Bearer $TOKEN" "$BPMS_URL/api/v1/access/roles"

The token also decides the tenant: every call sees only the data of the user's tenant.

Change the password

When passwordChangeRequired is true, every call except changing the password and signing out answers 403. Change it with the current and the new password; a successful change answers 204:

curl -sS -X POST "$BPMS_URL/api/v1/auth/password" -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' -d '{"currentPassword": "<current password>", "newPassword": "<new password>"}'

Sign out

curl -sS -X POST "$BPMS_URL/api/v1/auth/logout" -H "Authorization: Bearer $TOKEN"

After signing out, the token no longer authenticates.

Errors

StatuscodeWhen
401core.invalid-credentialsThe sign-in failed, whatever the cause, or the current password is wrong.
401core.authentication-requiredThe call has no valid token.
403core.password-change-requiredThe password must be changed first.
429core.too-many-login-attemptsToo many sign-in attempts; wait the seconds in Retry-After.

A user is locked after too many failed sign-ins, as in BPMS 3.x, and a locked user is refused even with the right password until the user is unlocked in BPMS 3.x.

On this page