Skip to content

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.


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_...
Terminal window
curl -sS https://auth.example.com/api/dev/account \
-H "Authorization: Bearer jat_your_token_here"
  • /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 or X-CSRF-Token.
  • Requests with a jat_ token are rate-limited per token ID and client IP via TOKEN_RATE_LIMITER (429 RATE_LIMITED).
  • Approved Developers Only: Only active users with developer_status === "approved" can create or use jat_ tokens. If a user’s developer access is revoked or their account is suspended, all of their existing jat_ tokens immediately return 401 INVALID_API_TOKEN.
  • Developer Surface Only: Even if a user holds role === "admin", jat_ tokens are rejected with 403 TOKEN_NOT_ALLOWED on /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_FOUND or 403 FORBIDDEN otherwise).
  • Fail Closed: Presenting an unknown, expired, or revoked jat_ token immediately fails with 401 INVALID_API_TOKEN without falling back to browser session cookies.
  • Passwordless Secret Rotation (When Authorized): Rotating a client secret or webhook secret using a jat_ token carrying apps:secrets does not require currentPassword (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"
}
}

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).

  • 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

  • Naming: Required name (2–64 characters after trimming).
  • Expiration Options:
    • expiresInDays: number from 1 to 3650 (computes now + expiresInDays * 86400), or 0 / null for never expires.
    • expiresAt: future Unix timestamp (seconds) or ISO 8601 date string within 10 years, or null for never expires.
    • If both expiresInDays and expiresAt are omitted on POST /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_REVOKED on PATCH) and are purged after 90 days by the daily cron job.

All /api/dev/* JSON endpoints return { "ok": true, "data": ... } on success or { "ok": false, "error": { "code": "...", "message": "..." } } on error.

  • 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
}
}
}
  • Required Scope: account:write
  • Body: { "name": "New Display Name" } (2–64 chars)
  • Response (200 OK): { "ok": true, "data": { "id": "...", "email": "...", "name": "New Display Name", "updated_at": ... } }
  • Required Scope (if using token): account:read
  • Response (200 OK): { "ok": true, "data": { "developer_status": "approved", "applications": [...] } }

  • Required Scope: tokens:manage
  • Response (200 OK): Lists all tokens (never returning hashes or raw secrets) plus available_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": [...]
}
}
  • 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-time token string ("jat_...").
  • Errors: 400 INVALID_NAME, 400 INVALID_SCOPES, 400 INVALID_EXPIRATION, 400 TOKEN_LIMIT_REACHED, 403 INSUFFICIENT_TOKEN_SCOPE.
  • 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.
  • Required Scope: tokens:manage
  • Response (200 OK): { "ok": true, "data": { "revoked": true, "id": "..." } } (404 NOT_FOUND if 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)

Create an application using appSlug:

Terminal window
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:

Terminal window
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:

Terminal window
curl -sS -X DELETE https://auth.example.com/api/dev/apps/inventory_api \
-H "Authorization: Bearer $JOE_TOKEN"