Admin API

Last updated 9 days ago

Manage specs, API keys, backups, and configure your instance via the Admin API. All admin endpoints use JWT authentication on the console API.

Authentication

All admin endpoints require JWT authentication on the console API:

curl https://console.j17.dev/api/instances \
  -H "Authorization: Bearer $JWT_TOKEN"

Get a JWT via login:

curl -X POST https://console.j17.dev/api/login \
  -H "Content-Type: application/json" \
  -d '{"email": "admin@example.com", "password": "..."}'

Spec management

Deploy spec

POST /api/instances/:instance_id/spec
Authorization: Bearer $JWT
Content-Type: application/json

{
  "environment": "prod",
  "spec": {
    "aggregate_types": { ... },
    "agent_types": [ ... ]
  }
}

The spec goes inside the "spec" key. The dashboard upload expects the same format.

Specs are validated before deployment. Invalid specs return 422 with error details. Incompatible changes (removing types, changing required fields) are rejected unless "force": true is passed (non-prod environments only).

This is the JWT path on the console API. To deploy from CI with just an API key — no JWT, same host as your reads and writes — use a deploy-scoped key against POST /_spec on your instance. See Schema Deployment.

Get current spec

The current spec is available through the dashboard UI.

API key management

All key management is on the console API.

List keys

GET /api/instances/:instance_id/keys
Authorization: Bearer $JWT

Create key

Scopes are read, write, deploy, and admin. Use separate deploy and write keys to keep deployment access separate from event writes; an admin key grants read, write, and deployment access together.

POST /api/instances/:instance_id/keys
Authorization: Bearer $JWT

{
  "name": "Production Backend",
  "scope": "write",
  "environment": "prod"
}

Response includes the key (shown once):

{
  "id": "key-uuid",
  "name": "Production Backend",
  "key": "j17_0_prod_xyz789...",
  "scope": "write",
  "environment": "prod",
  "created_at": "2024-01-15T10:00:00Z"
}

Rotate key

POST /api/keys/:id/rotate
Authorization: Bearer $JWT

Creates a new key and revokes the old one.

Schedule revocation

POST /api/keys/:id/schedule_revocation
Authorization: Bearer $JWT

{
  "revoke_at": "2024-02-01T00:00:00Z"
}

Revoke key

DELETE /api/keys/:id
Authorization: Bearer $JWT

A previously validated API key can continue to work for up to 30 seconds after revocation. Allow for that interval when rotating or revoking credentials.

Instance operations

Delete an instance

DELETE /api/instances/:id requests deletion of one instance. Use an instance ID or name. Instance admins can delete using a user JWT. CLI-issued tokens need the instances scope. Platform admins can also use the admin scope.

Success returns {"ok": true} once deletion is recorded. The worker stops the instance and retains its data volume. Permanent purge requires a platform administrator.

The CLI equivalent is j17 instance delete <name-or-id>. It displays the instance and owner before asking for confirmation. Pass --yes in scripts.

The operations below use /api/instances/:id/ops/:environment/.

Checkpoints

Checkpoints snapshot aggregate state for faster replay.

Method Endpoint Description
GET /ops/:env/checkpoints List checkpoints
POST /ops/:env/checkpoints Create checkpoint
POST /ops/:env/checkpoints/:checkpoint_id/restore Restore checkpoint
DELETE /ops/:env/checkpoints/:checkpoint_id Delete checkpoint

Root anchors capture Merkle roots for cryptographic verification:

Method Endpoint Description
GET /ops/:env/root_anchors List root anchors
POST /ops/:env/root_anchors Create root anchor
DELETE /ops/:env/root_anchors/:id Delete root anchor
PUT /ops/:env/anchor_schedule Update auto-anchor schedule

Backups

Method Endpoint Description
GET /ops/:env/backups List backups
POST /ops/:env/backups Create backup
DELETE /ops/:env/backups/:backup_id Delete backup

Creation returns HTTP 201 on success. If instance configuration changes during capture, a completed backup is not published. The console API returns HTTP 409 with error: "Instance changed during backup; retry the capture"; retry the capture against the current configuration. Other capture failures return HTTP 422.

Backup capture does not provide one atomic snapshot across concurrent stream writes. Stop application writers when your recovery procedure requires that consistency. A JSONL download from the dashboard contains events only; keep your spec and projection definitions with your application so you can deploy them when importing that data elsewhere.

Backup settings (offsite S3 configuration):

Method Endpoint Description
GET /api/instances/:id/backup_settings Get backup settings
PUT /api/instances/:id/backup_settings Update backup settings

Blobs

Binary data storage (e.g., WASM modules, config files).

Method Endpoint Description
GET /ops/:env/blobs List blobs
DELETE /ops/:env/blobs/:name?version=:version Delete a specific blob version

The version query parameter is required for blob deletion. Deleting a published version does not make that name/version reusable for different content. Publish a new version instead.

Scheduled events

Method Endpoint Description
POST /ops/:env/scheduled/:event_id/cancel Cancel scheduled event
POST /ops/:env/scheduled/:event_id/retry Retry failed event

Sagas

Method Endpoint Description
POST /ops/:env/sagas/:saga_id/retry Retry failed saga

Tombstones (GDPR erasure)

Erasure requests currently require assistance from j17. Customer-facing request management and tombstone-consistency monitoring are not yet available through a supported dashboard or API. See the tombstones reference for erasure scope and onTombstone cascade rules.

Listener deliveries (webhooks)

Listeners deliver events to HTTP endpoints with HMAC-SHA256 signed payloads. Guaranteed deliveries allow up to 3 total attempts, with retries scheduled 5s after the first failure and 25s after the second. Delivery history is viewable in the dashboard.

Listeners are configured in your spec, not via API. The delivery system handles: - Automatic retry with exponential backoff - HMAC-SHA256 payload signing (j17-signature header; X-J17-Signature is also sent with the same value) - Delivered history is eligible for cleanup after 7 days; failed history after 30 days. Background cleanup can occur later. Pending deliveries and original application events are preserved.

Audit

Cryptographic verification of event integrity, on your instance with API key auth:

Method Endpoint Description
GET /:type/:id/audit/merkle-root Get Merkle root for aggregate
GET /:type/:id/audit/merkle-proof/:index Get Merkle proof for event
GET /:type/:id/audit/verify-chain Verify hash chain integrity

Data loading

Method Endpoint Description
POST /ops/:env/inject Inject test data (staging/test only)
POST /ops/:env/import Import historical events (mode=append or mode=replace; replace is non-prod only)
POST /ops/:env/cold_start Load initial events into a fresh environment

import changes data at any time (append, or replace to wipe first); cold_start is intended for loading an export into a fresh environment. It validates the batch before writing, but does not guarantee atomic initialization or exactly-once execution. Establish that the target is empty and stop other writers and loaders before using it. Interrupted or partial writes are not rolled back.

The console API returns HTTP 201 for a completed load and HTTP 422 for failed or refused loads. An error does not establish that nothing was written. Inspect the environment before retrying; the console response does not provide a per-event recovery report.

Both endpoints take { "events": [...] } and replay historical events without generating implied events or triggering live business actions. Use ordinary writes for application seed scripts that should execute business behavior, with stable IDs and create-only preconditions; see Initializing data safely. The same bulk cold-start operation is available to a deploy-scoped API key on non-production environments — see Schema Deployment.

Data reset

Clear customer event data and projection contents, cancel pending timers, and remove the deployed spec in the selected environment. Other environments are kept. Saga records, dead letters and timer history are not deleted. Restricted to staging and test; production reset is refused.

POST /api/instances/:id/ops/:environment/reset
Authorization: Bearer $JWT

No request body. Returns HTTP 201 with ok: true on success; refused or failed operations return HTTP 422. Requires the instance_admin role. Redeploy the spec before writing new application events.

This console operation differs from the deploy-key POST /_reset, which keeps the deployed spec.

This is destructive and irreversible — there is no undo. Use it to recycle non-production environments between test runs or after incompatible spec changes. Stop application writes and seed jobs before reset when the environment must remain empty afterward.

Error lookup

GET /api/instances/:id/ops/:environment/errors/:error_id
Authorization: Bearer $JWT

Returns details for a specific error, including the full error context and stack trace.

Usage and billing

Usage and billing endpoints are on the console API.

Method Endpoint Description
GET /api/instances/:id Instance details including plan/tier

Usage metrics are tracked per instance.

Projections

Method Endpoint Description
POST /api/instances/:id/projections Deploy a projection definition
GET /api/instances/:id/projections List configured projections
DELETE /api/instances/:id/projections/:name Remove a projection

The deploy body wraps the definition:

{
  "name": "order_summary",
  "environment": "prod",
  "projection": {
    "for_each": "order",
    "sources": {"order": "$key"},
    "select": {"total": "$.order.total"}
  }
}

See the projections guide for full details on sources, select transforms, and SQL queries.

These are the JWT endpoints on the console API. To deploy or delete projections with a deploy-scoped API key on your instance, see Schema Deployment.

See also

Can't find what you need? support@j17.app