Reference

API Endpoints

Complete API reference for IdP and SP endpoints.

API Endpoints

All HTTP endpoints registered by @openape/nuxt-auth-idp and @openape/nuxt-auth-sp.

Authentication

API endpoints use three authentication methods:

MethodHeaderWho uses it
Management TokenAuthorization: Bearer <management-token>Human administrators, deployment tools
Agent TokenAuthorization: Bearer <agent-jwt>Enrolled agents (from /api/agent/authenticate)
SessionCookie-based (automatic)Logged-in users in the browser

IdP — Agent Endpoints

POST /api/agent/enroll

Register a new agent. Requires Management Token or admin session.

curl -X POST https://id.example.com/api/agent/enroll \
  -H "Authorization: Bearer <management-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "agent+deploy@example.com",
    "name": "deploy-bot",
    "publicKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI..."
  }'
FieldRequiredDescription
emailYesAgent email (convention: agent+name@domain)
nameYesHuman-readable agent name
publicKeyYesSSH-format Ed25519 public key (ssh-ed25519 ...)
ownerNoOwner email (default: admin)
approverNoApprover email (default: admin)

Response: 201 with { agent_id, email, name, owner, approver, status }

POST /api/agent/challenge

Request an authentication challenge. No auth required.

curl -X POST https://id.example.com/api/agent/challenge \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "agent+deploy@example.com"}'

Response: 200 with { challenge: "<64-char-hex>" }

Challenge expires after 60 seconds. Single-use.

POST /api/agent/authenticate

Authenticate with a signed challenge. No auth required.

curl -X POST https://id.example.com/api/agent/authenticate \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent+deploy@example.com",
    "challenge": "<challenge-from-above>",
    "signature": "<base64-ed25519-signature>"
  }'

Response: 200 with { token, agent_id, email, name, expires_in }

The token is a JWT with claims { sub, act: "agent", iss, iat, exp }.

IdP — Grant Endpoints

POST /api/grants

Create a grant request. Agent token or session optional (auto-sets requester).

curl -X POST https://id.example.com/api/grants \
  -H "Authorization: Bearer <agent-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "requester": "agent+deploy@example.com",
    "target_host": "prod-server.example.com",
    "audience": "escapes",
    "grant_type": "once",
    "command": ["systemctl", "restart", "nginx"],
    "reason": "Deploy hotfix"
  }'
FieldRequiredDescription
requesterYesAgent email
target_hostYesHost where grant is valid
audienceYesService identifier (escapes, proxy, etc.)
grant_typeNoonce (default), timed, always
commandNoCommand array
permissionsNoPermission strings
durationFor timedDuration in seconds
reasonNoHuman-readable reason
run_asNoExecute as this user

Response: 201 with { id, type, request, status: "pending", created_at }

For timed and always grants, the system checks for existing reusable grants with matching parameters. If found, the existing grant is returned instead of creating a new one.

GET /api/grants

List grants. Session or agent token required.

Query params: status, limit (max 100)

GET /api/grants/:id

Get grant details. Supports ETag-based polling via If-None-Match header.

Response: 200 with full grant object, or 304 Not Modified if unchanged.

POST /api/grants/:id/approve

Approve a pending grant. Requires admin session, management token, or authorized approver.

curl -X POST https://id.example.com/api/grants/<id>/approve \
  -H "Authorization: Bearer <management-token>" \
  -H "Content-Type: application/json" \
  -d '{"grant_type": "timed", "duration": 3600}'

The request body is optional. Use it to override the grant type or duration.

Response: 200 with { grant, authz_jwt }

AuthZ-JWT expiration by grant type:

  • once → 5 minutes
  • timedgrant.expires_at
  • always → 1 hour

POST /api/grants/:id/deny

Deny a pending grant. Same auth as approve.

POST /api/grants/:id/revoke

Revoke an approved grant. Only the agent's approver or admin.

POST /api/grants/:id/token

Get the AuthZ-JWT for an approved grant. Requires agent token or session matching the requester.

Response: 200 with { authz_jwt, grant }

POST /api/grants/:id/consume

Consume a once grant. Requires the AuthZ-JWT as Bearer token.

Response: 200 with { status: "consumed" } for once grants, or { status: "valid" } for timed/always.

POST /api/grants/verify

Verify an AuthZ-JWT. No auth required.

curl -X POST https://id.example.com/api/grants/verify \
  -H "Content-Type: application/json" \
  -d '{"token": "<authz-jwt>"}'

Response: 200 with { valid: true, claims: {...} } or { valid: false, error: "..." }

POST /api/grants/batch

Batch grant operations.

IdP — Delegation Endpoints

POST /api/delegations

Create a delegation. Session or agent token required.

curl -X POST https://id.example.com/api/delegations \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "delegate": "agent+bot@example.com",
    "audience": "escapes",
    "scopes": ["read", "exec"],
    "approval": "always"
  }'

GET /api/delegations

List delegations for the current user.

DELETE /api/delegations/:id

Delete a delegation.

POST /api/delegations/:id/validate

Validate a delegation token.

IdP — Admin Endpoints

All admin endpoints require Management Token or admin session.

Users

MethodPathDescription
GET/api/admin/usersList users
POST/api/admin/usersCreate user
DELETE/api/admin/users/:emailDelete user
GET/api/admin/users/:email/credentialsList user's WebAuthn credentials

Agents

MethodPathDescription
GET/api/admin/agentsList agents
POST/api/admin/agentsCreate agent
GET/api/admin/agents/:idGet agent details
PUT/api/admin/agents/:idUpdate agent
DELETE/api/admin/agents/:idDelete agent

Sessions

MethodPathDescription
GET/api/admin/sessionsList sessions
DELETE/api/admin/sessions/:familyIdDelete session by family ID
DELETE/api/admin/sessions/user/:emailDelete all sessions for user

Registration URLs

MethodPathDescription
GET/api/admin/registration-urlsList registration URLs
POST/api/admin/registration-urlsCreate registration URL
DELETE/api/admin/registration-urls/:tokenDelete registration URL

IdP — OAuth / OIDC Endpoints

MethodPathDescription
GET/authorizeOAuth authorization endpoint
POST/tokenToken exchange
POST/revokeToken revocation
GET/userinfoUser info
GET/.well-known/jwks.jsonJSON Web Key Set
GET/.well-known/openid-configurationOIDC discovery document

IdP — Auth Endpoints

MethodPathDescription
POST/api/logoutEnd session
GET/api/meGet current user
POST/api/webauthn/register/optionsGet registration options
POST/api/webauthn/register/verifyVerify registration
POST/api/webauthn/login/optionsGet login options
POST/api/webauthn/login/verifyVerify login
GET/api/webauthn/credentialsList credentials
POST/api/webauthn/credentials/add/optionsGet options for adding credential
POST/api/webauthn/credentials/add/verifyVerify added credential
DELETE/api/webauthn/credentials/:idDelete credential

IdP — Federation Endpoints

MethodPathDescription
GET/auth/federated/:providerIdInitiate federated login
GET/auth/federated/:providerId/callbackHandle federation callback
GET/api/federation/providersList configured federation providers

SP Endpoints

MethodPathDescription
POST/api/loginStart login (accepts { email }, returns redirect URL)
GET/api/callbackOAuth callback
POST/api/logoutEnd session
GET/api/meGet current user
GET/.well-known/oauth-client-metadataOAuth client metadata
GET/.well-known/auth.mdMachine-readable auth spec
GET/.well-known/openape.jsonService manifest