Skip to content

Auth API

Base path: /api/auth

MethodPathAuth requiredDescription
GET/api/auth/bootstrapNoCheck if setup is needed
POST/api/auth/registerNo (if 0 users)Create user account
POST/api/auth/loginNoUsername/password login
POST/api/auth/validateYesValidate token
POST/api/auth/logoutYesEnd session
POST/api/auth/keysYes (or No if 0 keys)Create API key
GET/api/auth/keysYesList API keys
DELETE/api/auth/keys/{id}YesRevoke API key

Check whether first-time setup is needed. Used by the UI to redirect to /setup.

Terminal window
curl http://localhost:18781/api/auth/bootstrap

Response:

{ "needs_setup": false }

Create a user account. Only succeeds if no users exist yet.

Terminal window
curl -X POST http://localhost:18781/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "alice", "password": "mypassword123"}'
FieldTypeRequiredDescription
usernamestringYesMinimum 3 characters
passwordstringYesMinimum 8 characters

Response: 201 Created

{
"user_id": "usr_abc123",
"username": "alice",
"token": "sess_abc123...",
"token_type": "session",
"message": "Account created successfully"
}

Authenticate with username and password. Returns a session token.

Terminal window
curl -X POST http://localhost:18781/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "alice", "password": "mypassword123"}'

Response: 200 OK

{
"token": "sess_abc123...",
"token_type": "session",
"expires_in": 86400,
"user": { "id": "usr_xyz", "username": "alice" }
}

Validate a token (session or API key). Requires auth.

Terminal window
curl -X POST http://localhost:18781/api/auth/validate \
-H "Authorization: Bearer snip_your_key"

Response: 200 OK

{ "valid": true, "token_type": "api_key" }

End the current session. Requires auth.

Terminal window
curl -X POST http://localhost:18781/api/auth/logout \
-H "Authorization: Bearer sess_abc123"

Response: 200 OK

{ "success": true }

Create a new API key. Requires auth (or no auth if zero keys exist).

Terminal window
curl -X POST http://localhost:18781/api/auth/keys \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "CI automation"}'
FieldTypeRequiredDescription
namestringYesHuman-readable label

Response: 200 OK

{
"id": "key_abc123",
"name": "CI automation",
"key": "snip_abc123...",
"created_at": "2026-03-01T09:00:00Z"
}

List all API keys. Requires auth.

Terminal window
curl http://localhost:18781/api/auth/keys \
-H "Authorization: Bearer $API_KEY"

Response: 200 OK

{
"keys": [
{ "id": "key_abc123", "name": "CI automation", "created_at": "...", "last_used": "..." }
]
}

Revoke an API key permanently. Requires auth.

Terminal window
curl -X DELETE http://localhost:18781/api/auth/keys/key_abc123 \
-H "Authorization: Bearer $API_KEY"

Response: 204 No Content