Skip to content
MantraWorx
Developers › Authentication

Developers

Authentication

Sign in, send the token with each request, check who you are and sign out.

On this page

Sign in with your email and password to receive an access token. Send that token with every other request.

Sign in#

POST /api/auth/login

FieldTypeRequired
emailstringYes
passwordstringYes
timezonestringNo
bash
curl -X POST https://<your-host>/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "your-password"}'

A successful sign-in returns 200 with the token and the signed-in user. The response is shown here with the fields shortened.

json
{
  "message": "Login successful",
  "accessToken": "<token>",
  "user": {
    "id": "…",
    "email": "you@example.com",
    "name": "…",
    "role": "…",
    "roleLabel": "…",
    "department": "…"
  }
}

Use the token#

Send the token in the Authorization header on every other request.

bash
Authorization: Bearer <accessToken>

Browsers do not need to do this. A successful sign-in also sets an HttpOnly auth_token cookie, and the API accepts either one.

Check who you are#

GET /api/auth/me returns the signed-in user. It is a quick way to test that a token still works.

Sign out#

POST /api/auth/logout ends the session. After that, the token is refused with 401.

Failed sign-ins#

SituationWhat you get
Too many failed sign-ins429 with Too many login attempts, please try again later. The limit is 20 failed attempts per 15 minutes for the same address and email.
Account locked after repeated failures429. Wait, or ask an administrator for help.
Missing, expired or revoked token on another call401. Sign in again.

Successful sign-ins do not count towards the limit.

Other password endpoints#

EndpointUsed for
POST /api/auth/forgot-passwordStart a password reset by email.
POST /api/auth/reset-passwordFinish a reset with the emailed token.
POST /api/auth/setup-passwordSet a password when you accept an invitation.
POST /api/auth/change-passwordChange your password while signed in.

Need more help?

Can’t find what you need? Talk to the team.

Contact support