Skip to main content

Admin API

Everything the console does goes through the admin API, without exception: the very same router is served on two mounts.

MountAuthenticationUsed by
/apiAuthorization: Bearer <token>the CLI, CI, scripts
/backoffice/apithe console's session cookie (mutations must be JSON)the console

So a feature cannot exist only on screen: every action of the console replays from the CLI.

Tokens​

  • Personal tokens: in the console, user menu → API tokens, or POST /api/me/tokens ({"name": "ci"}). The token is shown once; it acts as its owner, with its rights.
  • The bootstrap token: APIM_ADMIN_TOKEN acts as the first bootstrap administrator.
curl -H 'Authorization: Bearer apim-admin-token' http://localhost:9000/api/me

Errors are JSON: {"error": "…", "details": …} with a meaningful status (400, 401, 403, 404, 409). A draft that cannot be published answers 400 with the validation errors in details.errors.

Resources​

Workspace-scoped resources live under /api/workspaces/<workspace> (slug or id); an API is addressed by id or slug.

AreaEndpoints
youGET /me, GET POST DELETE /me/tokens
installationGET /settings, PUT /settings/{gateway,ingest,auth}, POST /settings/ingest/run (roll up and purge now), GET POST PUT DELETE /users (a person deleted with their personal applications: DELETE /users/<id or email>), GET /audit, GET POST PUT DELETE /audit/exporters, POST /audit/exporters/<id>/test
gatewayGET /gateway/status, GET /gateway/tasks, POST /gateway/tasks/<id>/retry, POST /gateway/tasks/<id>/dismiss, GET /gateway/references, GET /gateway/plugins, GET /gateway/plugins/<id> (with its form description), POST /gateway/exporter, GET POST /gateway/setup (the setup: its report, a run), POST /gateway/drift, GET /gateway/drift-reports, GET /gateway/threat-protection, GET /gateway/unmanaged-apis
workspacesGET POST /workspaces, GET PUT DELETE /workspaces/<ws>, …/members, …/teams, …/teams/<team>/members
portal designGET PUT …/portal/design (the draft, the published version, what differs), POST …/portal/publish, GET …/portal/versions, GET …/portal/versions/<n>, POST …/portal/versions/<n>/restore, POST …/portal/assets ({path, data} in base64), GET …/portal/assets/<digest>, GET …/portal/document, POST …/portal/apply (?publish=true&managed_by=…; a design a source owns is refused to a document without one, unless force=true), GET PUT …/portal/scripts ({enabled, acknowledge}), POST …/portal/preview (a link to the draft, for an hour)
APIsGET POST …/apis, GET PUT DELETE …/apis/<api>, PUT …/draft, POST …/validate, POST …/lifecycle, POST …/versions, GET …/plans, GET …/document, PUT …/placement (categories, featured), GET …/reviews, POST …/reviews/<review>/hide
documentationGET POST …/apis/<api>/pages, GET PUT DELETE …/pages/<page>
publicationGET …/changes, POST …/publish, GET …/snapshots, GET …/snapshots/<n>
promotionGET …/apis/<api>/snapshots/<n | deployed>/promotion, POST …/promotions ({"document": …, "dry_run": true, "deploy": true, "replace_draft": true})
deploymentGET …/deployments, POST …/deploy ({"snapshot": …, "dry_run": true}), POST …/undeploy, GET …/projection, POST …/test
applicationsGET POST …/applications, GET PUT DELETE …/applications/<app>
dictionariesGET POST …/dictionaries, GET PUT DELETE …/dictionaries/<name or id>, POST …/refresh
subscriptionsGET POST …/subscriptions, GET …/subscriptions/<sub>, POST …/{accept,reject,suspend,resume,close,transfer,resync}, POST …/transfer/decision, POST …/ending ({"at": "2027-01-31T00:00:00Z"}, or null), PUT …/metadata, POST …/credentials/<cred>/rotate, GET …/usage (the usage billed)
compositionGET POST …/policy-groups, GET PUT DELETE …/policy-groups/<pg>, POST …/publish, POST …/upgrade ({publish, deploy, apis}: the APIs behind moved to the latest version) · the same for …/shared-resources
metadataGET PUT …/metadata-fields
GitOpsPOST …/apply, GET …/export, POST …/import, GET POST …/catalogs, PUT DELETE …/catalogs/<cat>, POST …/preview, POST …/sync, POST …/adopt
observabilityGET …/analytics, GET …/analytics/calls, GET …/analytics/calls/export, GET …/analytics/security, GET …/audit, GET POST …/drift, GET …/search, GET …/home
notificationsGET …/notifications, POST …/notifications/{read,done}
paymentsGET DELETE …/payments (the Stripe account of the workspace), POST …/payments/connect, GET …/payments/events, POST …/payments/reconcile

Trying a request​

POST …/apis/<api>/test sends a request through the API on the gateway — its real routing, plans, quotas and keys — with Otoroshi's request tester: {"method": "GET", "path": "/search", "query": "q=x", "headers": {…}, "body": "…", "subscription_id": "sub_…"}, the credentials of a subscription the caller can see when it names one. The answer holds the response (status, headers, body) and its execution trace: the consumer the plans identified (client_id, plan_id), then each step that ran plugins, each plugin allowed, denied (with its status), successful or failure, and its duration — which plan recognised the caller, and what refused it. The request is sent by the gateway itself, from 127.0.0.1: a keyless plan identifies it by that address. The raw report of the gateway is never answered: it holds the headers of the request, credentials included.

Paged lists​

The lists that grow — the audit trail (GET …/audit, GET /audit), the request log (GET …/analytics/calls), the task queue (GET /gateway/tasks) and the people (GET /users, searched by email, name and tags) — are searched and paged on the server: ?q= (free text), ?limit= (up to 500) and ?offset=, answered as { "items": […], "total": 1234, "limit": 50, "offset": 0 }. The same parameters search and page the deployment history of an api (GET …/apis/<api>/deployments: history and total), the usage billed for a subscription (GET …/subscriptions/<sub>/usage: reports and total, the sums over every batch) and the security events (GET …/analytics/security: items and total follow the search, events and the breakdowns follow the filters only). The other lists are answered whole; the console and the portal search and page every list, in the url so a filtered list is a link — or, in a modal or a drawer, in the list itself.

A complete flow​

H='Authorization: Bearer apim-admin-token'; J='Content-Type: application/json'
B=http://localhost:9000/api/workspaces/default

curl -s -H "$H" -H "$J" -X POST $B/apis \
-d '{"name": "Books", "version": "1.0.0", "domain": "books.oto.tools", "contextPath": "/v1"}'
curl -s -H "$H" -H "$J" -X POST $B/apis/books/publish -d '{"comment": "first", "deploy": true}'
curl -s -H "$H" -H "$J" -X POST $B/applications -d '{"name": "My app", "team_id": "<team id>", "shared_credential": true}'
curl -s -H "$H" -H "$J" -X POST $B/subscriptions \
-d '{"api_id": "<api id>", "plan_id": "<plan id>", "application_id": "<app id>"}'
curl -s -H "$H" $B/subscriptions/<sub id> # the credentials

Audit trail​

The admin API writes the audit trail itself: every write, plus the reads that touch secrets or personal data — credentials, request logs. Console → Audit, GET …/audit?action=api., or otoroshi-apim audit default.

Audit exporters​

Global settings → Audit export, or the admin API. The trail leaves the product in batches, to a SIEM or a log pipeline, like Otoroshi's data exporters do for its events. An exporter (installation administrators) posts JSON arrays of ApimAuditEvent to a URL, optionally restricted to a workspace and to action prefixes (subscription., credential.read…), with custom headers. Each exporter keeps a cursor: delivery is at least once, in order, and nothing is lost while the target is down — the batch is sent again at the next tick. A new exporter starts from now on, unless created with "from_beginning": true.

curl -X POST http://localhost:9000/api/audit/exporters \
-H 'Authorization: Bearer apim-admin-token' -H 'Content-Type: application/json' \
-d '{"name": "siem", "url": "https://siem.example.com/ingest", "actions": ["subscription.", "credential."]}'

GET /audit/exporters lists them with their lag; POST /audit/exporters/<id>/test sends a test event.

Export and import​

GET …/export returns the whole workspace — teams, every API (one document per API-version, with its documentation pages and snapshot history), applications and subscriptions — and POST …/import re-imports it elsewhere. Import is idempotent: objects are upserted by id, snapshots are never rewritten, and nothing is deployed.