ampr docs

Authentication

Dashboard user authentication (password login, sessions, RBAC)

POST /auth/signup Sign up (self-serve org provisioning)

Create a user, provision a new organization + `owner` membership, and send a verification email. Decoupled from auto-login: NO session cookie is set on any branch, and the response is header-identical for new vs existing emails (enumeration-safe). The first session is established via `POST /auth/login` after email verification.

Request body

PropertyTypeRequiredDescription
emailstringformat: emailrequired
passwordstringrequired
namestring
org_namestring

Responses

201 Account creation accepted (verify your email, then sign in)

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
messagestring

400 Invalid request parameters application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/signup" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "string",
    "password": "string",
    "name": "string",
    "org_name": "string"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/login Log in (password)

Verify credentials, rotate the session (fixation defence), and set the `httpOnly` + `Secure` + `SameSite=Lax` session cookie and the `__Secure-` CSRF cookie. Requires a verified email. Rate-limited and lockout-guarded; unknown-email, wrong-password, locked, and unverified all return an identical generic failure (enumeration-safe).

Request body

PropertyTypeRequiredDescription
emailstringformat: emailrequired
passwordstringrequired

Responses

200 Authenticated; session + CSRF cookies set

PropertyTypeRequiredDescription
dataAuthSessionThe authenticated user, their active org, live role, and memberships.
PropertyTypeRequiredDescription
userUserrequired
PropertyTypeRequiredDescription
idstringrequired
emailstringformat: emailrequired
namestringnullable
email_verifiedbooleanrequiredWhether the account's email has been verified. Login is gated on this in V1.
created_atstringformat: date-time
active_org_idstringrequired
roleOrgRole
  • owner
  • admin
  • operator
  • viewer
requiredOrdinal organization role — `owner > admin > operator > viewer`.
membershipsarray<Membership>Every org the user belongs to (present on `GET /auth/me`).
PropertyTypeRequiredDescription
org_idstringrequired
org_namestring
roleOrgRole
  • owner
  • admin
  • operator
  • viewer
requiredOrdinal organization role — `owner > admin > operator > viewer`.

401 Missing or invalid API key application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/login" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "string",
    "password": "string"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/logout Log out

Revoke the current session (Redis DEL + Postgres `revoked_at`) and clear the cookies.

Parameters

Name In Type Required Description
X-CSRF-Token header string required Signed, session-bound CSRF token (from the `__Secure-ampr_csrf` cookie). Required on session-authenticated `POST`/`PATCH`/`DELETE`. API-key callers are exempt.

Responses

200 Logged out

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
successboolean

401 Missing or invalid API key application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/logout" \
  -H "Authorization: Bearer $AMPR_API_KEY"
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

GET /auth/me Current authenticated user

The current user, their active org, live role, and full membership list (org-switcher).

Responses

200 Current session context

PropertyTypeRequiredDescription
dataAuthSessionThe authenticated user, their active org, live role, and memberships.
PropertyTypeRequiredDescription
userUserrequired
PropertyTypeRequiredDescription
idstringrequired
emailstringformat: emailrequired
namestringnullable
email_verifiedbooleanrequiredWhether the account's email has been verified. Login is gated on this in V1.
created_atstringformat: date-time
active_org_idstringrequired
roleOrgRole
  • owner
  • admin
  • operator
  • viewer
requiredOrdinal organization role — `owner > admin > operator > viewer`.
membershipsarray<Membership>Every org the user belongs to (present on `GET /auth/me`).
PropertyTypeRequiredDescription
org_idstringrequired
org_namestring
roleOrgRole
  • owner
  • admin
  • operator
  • viewer
requiredOrdinal organization role — `owner > admin > operator > viewer`.

401 Missing or invalid API key application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X GET "https://api.ampr.dev/v1/auth/me" \
  -H "Authorization: Bearer $AMPR_API_KEY"
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/verify-email Verify email

Consume a single-use, hashed, expiring `verify_email` token and mark the account verified.

Request body

PropertyTypeRequiredDescription
tokenstringrequired

Responses

200 Email verified

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
messagestring

400 Invalid request parameters application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/verify-email" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "string"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/verify-email/resend Resend the verification email

Re-issue a verification token. Enumeration-safe and rate-limited (per-email + per-IP, fail-closed): the response is identical whether the email is unknown, already verified, or pending.

Request body

PropertyTypeRequiredDescription
emailstringformat: emailrequired

Responses

200 Fixed, enumeration-safe response

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
messagestring

400 Invalid request parameters application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/verify-email/resend" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "string"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/forgot-password Request a password reset

Issue a single-use reset token by email if the account exists. Enumeration-safe (identical response whether or not mail is sent) and rate-limited per-email + per-IP (fail-closed).

Request body

PropertyTypeRequiredDescription
emailstringformat: emailrequired

Responses

200 Fixed, enumeration-safe response

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
messagestring

400 Invalid request parameters application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/forgot-password" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "string"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/reset-password Reset password

Consume a single-use `reset_password` token, set the new password, and revoke ALL of the user's sessions (Redis + Postgres).

Request body

PropertyTypeRequiredDescription
tokenstringrequired
passwordstringrequired

Responses

200 Password updated

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
messagestring

400 Invalid request parameters application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/reset-password" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "string",
    "password": "string"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.

POST /auth/switch-org Switch active organization

Change the session's active org to another the user is a member of. Rotates the session (revokes the old id, mints a new one pinned to the new org).

Parameters

Name In Type Required Description
X-CSRF-Token header string required Signed, session-bound CSRF token (from the `__Secure-ampr_csrf` cookie). Required on session-authenticated `POST`/`PATCH`/`DELETE`. API-key callers are exempt.

Request body

PropertyTypeRequiredDescription
org_idstringrequired

Responses

200 Active org switched; session rotated

PropertyTypeRequiredDescription
dataobject
PropertyTypeRequiredDescription
active_org_idstring
roleOrgRole
  • owner
  • admin
  • operator
  • viewer
Ordinal organization role — `owner > admin > operator > viewer`.

403 Authenticated but not authorized for this action (insufficient role) application/problem+json

PropertyTypeRequiredDescription
typestringformat: urirequired
titlestringrequired
statusintegerrequired
detailstringnullable
instancestringnullable

Request example

curl -X POST "https://api.ampr.dev/v1/auth/switch-org" \
  -H "Authorization: Bearer $AMPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "org_id": "org_example"
  }'
Note
This endpoint requires an API key. Send it as a Bearer token in the Authorization header.