Developer Account Control API
JoeAuth provides a Developer Account Control API allowing any account with developer_status = "approved" to generate, configure, and revoke scoped Personal Access Tokens (jat_...) in order to manage their developer account and OAuth applications programmatically from CI/CD pipelines, CLI scripts, or automation tools.
1. Authentication
Section titled “1. Authentication”Every token begins with the prefix jat_ and is shown once at creation time (JoeAuth stores only its peppered HMAC-SHA256 hash and a 12-character token_prefix).
Pass the token on any request to /api/dev/* or /api/apps/:appId/delegation using either header:
Authorization: Bearer jat_...X-API-Key: jat_...
curl -sS https://auth.example.com/api/dev/account \ -H "Authorization: Bearer jat_your_token_here"CORS, CSRF & Rate Limiting
Section titled “CORS, CSRF & Rate Limiting”/api/dev/*and/api/apps/*enable CORS (Allow-Origin: *,Authorization,X-API-Key,Content-Type).- Requests authenticated with a
jat_API token do not require cookies orX-CSRF-Token. - Requests with a
jat_token are rate-limited per token ID and client IP viaTOKEN_RATE_LIMITER(429 RATE_LIMITED).
Security Boundaries
Section titled “Security Boundaries”- Approved Developers Only: Only active users with
developer_status === "approved"can create or usejat_tokens. If a user’s developer access is revoked or their account is suspended, all of their existingjat_tokens immediately return401 INVALID_API_TOKEN. - Developer Surface Only: Even if a user holds
role === "admin",jat_tokens are rejected with403 TOKEN_NOT_ALLOWEDon/api/admin/*and/api/user/*. - Single-Token Ownership: A
jat_token can only inspect or mutate resources (apps,dev_api_tokens,users) owned by the token creator (404 NOT_FOUNDor403 FORBIDDENotherwise). - Fail Closed: Presenting an unknown, expired, or revoked
jat_token immediately fails with401 INVALID_API_TOKENwithout falling back to browser session cookies. - Passwordless Secret Rotation (When Authorized): Rotating a client secret or webhook secret using a
jat_token carryingapps:secretsdoes not requirecurrentPassword(unlike browser sessions). Audit logs record{ "viaTokenId": "<token-id>" }.
2. Permission Scopes & Least-Privilege Presets
Section titled “2. Permission Scopes & Least-Privilege Presets”Each token holds an explicit non-empty array of scopes configurable at creation time or later via PATCH /api/dev/tokens/:id:
| Scope | Permission Granted |
|---|---|
account:read |
Read developer profile, developer approval status, and metadata of the calling API token |
account:write |
Update developer account display name |
apps:read |
List owned apps, fetch single app details (GET /api/dev/apps/:id), and read OAuth error logs |
apps:write |
Create apps, update metadata / custom App ID (appSlug) / redirect URIs / allowed scopes / webhooks, and upload or delete 256×256 PNG logos |
apps:delete |
Permanently delete owned applications and clean up their OAuth codes, refresh tokens, device codes, error logs, and R2 logos |
apps:secrets |
Rotate client_secret, rotate webhook_secret, and send webhook.test deliveries |
apps:delegation |
Read and update cross-app delegation configuration (delegation_mode, blocked_source_apps, TTL, custom target scopes) |
tokens:manage |
List, create, rename/rescope/re-expire, and revoke developer API tokens (dev_api_tokens) |
Missing the required scope for an endpoint returns 403 Forbidden:
{ "ok": false, "error": { "code": "INSUFFICIENT_TOKEN_SCOPE", "message": "API token is missing required scope: apps:secrets" }}Anti-Escalation Rule (tokens:manage)
Section titled “Anti-Escalation Rule (tokens:manage)”When a jat_ token with tokens:manage creates a new token (POST /api/dev/tokens) or edits an existing token’s scopes (PATCH /api/dev/tokens/:id), it cannot grant any scope that the calling token itself does not already hold (403 INSUFFICIENT_TOKEN_SCOPE).
Recommended Least-Privilege Presets
Section titled “Recommended Least-Privilege Presets”- Read-Only Audit / Monitoring:
["account:read", "apps:read"] - App Provisioning / CI Deployer:
["apps:read", "apps:write", "apps:delegation"] - Secret Rotation Automation:
["apps:read", "apps:secrets"] - Full Developer Account Control: all 8 scopes
3. Token Lifecycle & Expiration Rules
Section titled “3. Token Lifecycle & Expiration Rules”- Naming: Required
name(2–64characters after trimming). - Expiration Options:
expiresInDays: number from1to3650(computesnow + expiresInDays * 86400), or0/nullfor never expires.expiresAt: future Unix timestamp (seconds) or ISO 8601 date string within 10 years, ornullfor never expires.- If both
expiresInDaysandexpiresAtare omitted onPOST /api/dev/tokens, the token defaults to never expires (expires_at: null).
- Active Token Quota: Up to 25 non-expired, non-revoked tokens per developer account (
400 TOKEN_LIMIT_REACHED). - Adjusting After Creation: Call
PATCH /api/dev/tokens/:id(or click Edit Permissions / Expiry in/developer) to rename the token, add/remove scopes, or extend/clear expiration—changes take effect on the next request without rotating the secret token value. - Revocation: Call
DELETE /api/dev/tokens/:id(or click Revoke in/developer). Revoked tokens cannot be reactivated (400 TOKEN_REVOKEDonPATCH) and are purged after 90 days by the daily cron job.
4. Endpoint Reference
Section titled “4. Endpoint Reference”All /api/dev/* JSON endpoints return { "ok": true, "data": ... } on success or { "ok": false, "error": { "code": "...", "message": "..." } } on error.
A. Account Control
Section titled “A. Account Control”GET /api/dev/account
Section titled “GET /api/dev/account”- Required Scope:
account:read - Response (
200 OK):
{ "ok": true, "data": { "user": { "id": "u_...", "email": "dev@example.com", "name": "Example Developer", "role": "user", "developer_status": "approved", "status": "active", "email_verified": true, "avatar_url": "/media/avatars/u_...", "created_at": 1764200000 }, "token": { "id": "tok_...", "name": "CI Deploy Key", "prefix": "jat_9xK2pQ...", "scopes": ["account:read", "apps:read"], "expiresAt": 1766792000 } }}PATCH /api/dev/account
Section titled “PATCH /api/dev/account”- Required Scope:
account:write - Body:
{ "name": "New Display Name" }(2–64chars) - Response (
200 OK):{ "ok": true, "data": { "id": "...", "email": "...", "name": "New Display Name", "updated_at": ... } }
GET /api/dev/status
Section titled “GET /api/dev/status”- Required Scope (if using token):
account:read - Response (
200 OK):{ "ok": true, "data": { "developer_status": "approved", "applications": [...] } }
B. Token Management
Section titled “B. Token Management”GET /api/dev/tokens
Section titled “GET /api/dev/tokens”- Required Scope:
tokens:manage - Response (
200 OK): Lists all tokens (never returning hashes or raw secrets) plusavailable_scopes.
{ "ok": true, "data": { "tokens": [ { "id": "c7a1...", "name": "CI Deploy Key", "token_prefix": "jat_x7Yp9kL2", "scopes": ["apps:read", "apps:write"], "expires_at": 1766792000, "last_used_at": 1764205000, "revoked_at": null, "is_expired": false, "is_active": true, "created_at": 1764200000, "updated_at": 1764200000 } ], "available_scopes": [...] }}POST /api/dev/tokens
Section titled “POST /api/dev/tokens”- Required Scope:
tokens:manage - Body:
{ "name": "CI Deploy Key", "scopes": ["account:read", "apps:read", "apps:write", "apps:secrets"], "expiresInDays": 30}- Response (
201 Created): Includes the one-timetokenstring ("jat_..."). - Errors:
400 INVALID_NAME,400 INVALID_SCOPES,400 INVALID_EXPIRATION,400 TOKEN_LIMIT_REACHED,403 INSUFFICIENT_TOKEN_SCOPE.
PATCH /api/dev/tokens/:id
Section titled “PATCH /api/dev/tokens/:id”- Required Scope:
tokens:manage - Body (all fields optional):
{ "name": "Updated Name", "scopes": ["apps:read"], "expiresAt": null}- Response (
200 OK): Updated token metadata (is_active,is_expired,scopes,expires_at, etc.). - Errors:
404 NOT_FOUND,400 TOKEN_REVOKED,400 INVALID_NAME,400 INVALID_SCOPES,400 INVALID_EXPIRATION,403 INSUFFICIENT_TOKEN_SCOPE.
DELETE /api/dev/tokens/:id
Section titled “DELETE /api/dev/tokens/:id”- Required Scope:
tokens:manage - Response (
200 OK):{ "ok": true, "data": { "revoked": true, "id": "..." } }(404 NOT_FOUNDif missing or already revoked).
C. Application Lifecycle (:id Accepts UUID id, client_id (ja_...), or app_slug)
Section titled “C. Application Lifecycle (:id Accepts UUID id, client_id (ja_...), or app_slug)”| Method & Path | Scope | Purpose |
|---|---|---|
GET /api/dev/apps |
apps:read |
List all apps owned by the developer |
GET /api/dev/apps/:id |
apps:read |
Get full app metadata + delegation config & scopes |
GET /api/dev/apps/:id/logs |
apps:read |
Fetch recent OAuth error logs for the app |
POST /api/dev/apps |
apps:write |
Create a new confidential or public PKCE app (returns one-time client_secret) |
PATCH /api/dev/apps/:id |
apps:write |
Update name, appSlug, description, privilegeDescription, homepageUrl, redirectUris, postLogoutRedirectUris, allowedScopes, webhookUrl |
POST /api/dev/apps/:id/logo |
apps:write |
Upload 256x256 PNG logo (multipart/form-data field file or logo, <= 128 KiB) |
DELETE /api/dev/apps/:id/logo |
apps:write |
Reset app logo to default icon |
POST /api/dev/apps/:id/rotate-secret |
apps:secrets |
Rotate client_secret (no currentPassword needed when using API token) |
POST /api/dev/apps/:id/webhook-secret |
apps:secrets |
Rotate webhook_secret (whsec_...; no currentPassword needed when using API token) |
POST /api/dev/apps/:id/webhook-test |
apps:secrets |
Dispatch signed webhook.test event to configured webhook URL |
DELETE /api/dev/apps/:id |
apps:delete |
Permanently delete the app and clean up tokens/codes/logs/logo |
GET /api/apps/:appId/delegation |
apps:delegation |
Read Target App delegation config (delegation_mode, blocked_source_apps, TTL, custom scopes) |
PUT /api/apps/:appId/delegation |
apps:delegation |
Update Target App delegation config (synchronized with delegation under allowed_scopes) |
Examples
Section titled “Examples”Create an application using appSlug:
curl -sS -X POST https://auth.example.com/api/dev/apps \ -H "Authorization: Bearer $JOE_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Inventory Service", "appSlug": "inventory_api", "homepageUrl": "https://inventory.example.com", "redirectUris": ["https://inventory.example.com/callback"], "allowedScopes": ["openid", "profile", "email", "request_delegation", "delegation"] }'Rotate client_secret by custom App ID (inventory_api) without password confirmation:
curl -sS -X POST https://auth.example.com/api/dev/apps/inventory_api/rotate-secret \ -H "X-API-Key: $JOE_TOKEN"Delete an application by client_id or app_slug:
curl -sS -X DELETE https://auth.example.com/api/dev/apps/inventory_api \ -H "Authorization: Bearer $JOE_TOKEN"