Skip to content

auth

20 endpoints at a glance
MethodPathSummary
POST/auth/2fa/disableDisable 2Fa
POST/auth/2fa/enableEnable 2Fa
POST/auth/2fa/enrollEnroll 2Fa
POST/auth/2fa/recovery-codesRegenerate Recovery Codes
GET/auth/configAuth Config
POST/auth/loginLogin
POST/auth/login/2faLogin 2Fa
POST/auth/logoutLogout
GET/auth/meMe
PATCH/auth/meUpdate Me
POST/auth/me/passwordChange Password
DELETE/auth/me/self-contactClear Self Contact
PUT/auth/me/self-contactSet Self Contact
POST/auth/registerRegister
GET/auth/users/List Users
POST/auth/users/Create User
DELETE/auth/users/{username}Delete User
PATCH/auth/users/{username}Update User
POST/auth/users/{username}/passwordAdmin Reset Password
GET/auth/users/lookupLookup Users

auth


Auth Config

GET
/auth/config

Public auth-flow flags the SPA reads at boot.

Anonymous-readable so the login + register views can adjust their
chrome (hiding the sign-up link when registration is closed) without
a round-trip to a protected endpoint.

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Samples


Login

POST
/auth/login

Verify credentials, set the session cookie, return the user.

Generic 401 on any failure — never leak whether the username exists.

When the account has 2FA enabled, the password check is only step one:
instead of a session we return {"mfa_required": true, "mfa_token": …}
and set a short-lived challenge cookie. No session is issued and
last_login is not stamped until the code step succeeds. Accounts
without 2FA get exactly the response shape they always have, so
existing clients (incl. the Swift app) are unaffected unless a user
opts in.

Request Body

application/json
JSON
{
  
"username": "string",
  
"password": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Body

Samples


Login 2Fa

POST
/auth/login/2fa

Complete login: verify a TOTP code (or a recovery code), open session.

The challenge is read from (in order) the request body, the
kancil_mfa cookie, or an Authorization: Bearer header — so both
the SPA and native clients work. A 6-digit input is checked as TOTP; any
other input is tried as a single-use recovery code. Consecutive bad
codes are rate-limited per :data:TOTP_MAX_ATTEMPTS.

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"code": "string",
  
"mfa_token": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Register

POST
/auth/register

Self-serve signup. Creates a viewer and auto-logs in.

Admins are still admin-created via POST /auth/users/
self-registration intentionally has no role field on the wire.
Gated by KANCIL_REGISTRATION_ENABLED; when False, returns 403
(so the SPA can render a friendly "signups are closed" message
rather than a confusing 404).

Request Body

application/json
JSON
{
  
"username": "string",
  
"password": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Body

Samples


Logout

POST
/auth/logout

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Samples


Me

GET
/auth/me

Parameters

Header Parameters

authorization

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers

Samples


Update Me

PATCH
/auth/me

Patch the current user's preferences (shallow-merged).

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"preferences": {
  
  
"additionalProperties": "string"
  
}
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Lookup Users

GET
/auth/users/lookup

Public user search for any authenticated caller.

Used by the MembersEditor autocomplete. Returns only username +
role so the caller can render a chip; preferences and last_login
stay restricted to the admin /users/ endpoint.

Empty q returns the most recent users — convenient default for
"open the picker and see what's there".

Parameters

Header Parameters

authorization

Query Parameters

q
Type
string
Default
""
limit
Type
integer
Default
10

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Variables
Key
Value

Samples


Set Self Contact

PUT
/auth/me/self-contact

Designate which contact card represents the logged-in user.

Stored in preferences.self_contact so it round-trips through
/auth/me. Validates the contact is actually one of the user's own
and caches its display name for the "Add myself" affordance.

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"addressbook_id": "string",
  
"uid": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Clear Self Contact

DELETE
/auth/me/self-contact

Forget the user's designated contact card.

Parameters

Header Parameters

authorization

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers

Samples


Change Password

POST
/auth/me/password

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"current_password": "string",
  
"new_password": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Enroll 2Fa

POST
/auth/2fa/enroll

Begin enrollment: mint a fresh secret, return its QR + otpauth URI.

The secret is stored pending (encrypted) and is not active until
:func:enable_2fa verifies a code from it. Calling this again before
enabling simply rolls a new pending secret; any live 2FA stays intact.

Parameters

Header Parameters

authorization

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers

Samples


Enable 2Fa

POST
/auth/2fa/enable

Finish enrollment: verify a code, activate 2FA, return recovery codes.

The recovery codes are shown here exactly once — only their hashes are
stored. If the user loses them, they regenerate (invalidating the old
set), they don't get to re-read these.

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"code": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Disable 2Fa

POST
/auth/2fa/disable

Turn off 2FA. Requires the account password (not just a session).

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"password": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Regenerate Recovery Codes

POST
/auth/2fa/recovery-codes

Issue a fresh recovery-code set, invalidating the old one.

Requires the password and an already-enabled 2FA. Returns the new
plaintext codes once.

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"password": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


List Users

GET
/auth/users/

Parameters

Header Parameters

authorization

Responses

Successful Response

application/json
JSON
[
  
{
  
  
"additionalProperties": "string"
  
}
]

Playground

Headers

Samples


Create User

POST
/auth/users/

Parameters

Header Parameters

authorization

Request Body

application/json
JSON
{
  
"username": "string",
  
"password": "string",
  
"role": "viewer"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Body

Samples


Delete User

DELETE
/auth/users/{username}

Parameters

Header Parameters

authorization

Path Parameters

username*
Type
string
Required

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Variables
Key
Value

Samples


Update User

PATCH
/auth/users/{username}

Parameters

Header Parameters

authorization

Path Parameters

username*
Type
string
Required

Request Body

application/json
JSON
{
  
"role": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Variables
Key
Value
Body

Samples


Admin Reset Password

POST
/auth/users/{username}/password

Parameters

Header Parameters

authorization

Path Parameters

username*
Type
string
Required

Request Body

application/json
JSON
{
  
"new_password": "string"
}

Responses

Successful Response

application/json
JSON
{
  
"additionalProperties": "string"
}

Playground

Headers
Variables
Key
Value
Body

Samples


Kancil — one workspace for contacts, work and money.