# For AI agents (https://aperture-docs.mountaindev.com/docs/agents) These docs are published in machine-friendly formats so an agent can load exactly what it needs. | URL | Contents | | --- | --- | | [`/llms.txt`](https://aperture-docs.mountaindev.com/llms.txt) | An index of every page, with titles, descriptions and links to the Markdown version of each. | | [`/llms-full.txt`](https://aperture-docs.mountaindev.com/llms-full.txt) | Every page concatenated into one Markdown file. | | `/llms.mdx/docs/.md` | One page as Markdown, for example [`/llms.mdx/docs/cli.md`](https://aperture-docs.mountaindev.com/llms.mdx/docs/cli.md). | Every page also has a **Copy Markdown** button and a menu to open the page in an AI chat. ## Suggested prompt [#suggested-prompt] ```text Read https://aperture-docs.mountaindev.com/llms.txt and fetch the pages you need before writing code for Aperture. ``` ## Key facts for agents [#key-facts-for-agents] - A job is a directory with a `job.json` ([manifest](/docs/job-manifest)); the CLI reads `./jobs//job.json` by default. - All job input arrives as **environment variables** (params, declared secrets, `APERTURE_TRIGGER_*`). Exit code 0 means success. - The REST API base is `/api/v1`, with `Authorization: Bearer `. CI should use a project key (`apk_…`) with the `deploy`, `run` or `read` scope. - Check [Current limitations](/docs/limitations) before assuming a feature exists (timeouts, retries, job deletion). # REST API overview (https://aperture-docs.mountaindev.com/docs/api) Everything in the dashboard and CLI goes through the REST API, so you can do the same from any language. ## Base URL [#base-url] ```text https://aperture-server.mountaindev.com/api/v1 ``` Self-hosted servers use their own host with the same `/api/v1` prefix. All paths in this reference are relative to it. ## Authentication [#authentication] Send a token in the `Authorization` header: ```sh curl https://aperture-server.mountaindev.com/api/v1/teams \ -H "Authorization: Bearer $APERTURE_TOKEN" ``` Get a login token from `POST /signin`, or create a personal API key or a project key. See [Authentication](/docs/concepts/authentication) for the differences. ### `POST /signin` [#post-signin] ```sh curl -X POST https://aperture-server.mountaindev.com/api/v1/signin \ -H "Content-Type: application/json" \ -d '{"email": "you@example.com", "password": "…"}' ``` ```json { "data": { "jwt": "eyJ…", "claims": { "sub": "…", "email": "you@example.com", "exp": 1795000000 } } } ``` Wrong credentials return `401 {"error": "Unauthorized"}`. ### `POST /register` [#post-register] Creates an account and returns a token in the same shape as `/signin`. Registration can be turned off on a server, in which case it returns `422`. ```json { "user": { "username": "you@example.com", "password": "at least 8 chars", "name": "You" } } ``` ### `GET /health` [#get-health] No authentication. Returns `200 {"status": "ok"}`. ## Conventions [#conventions] - Request and response bodies are JSON, except deploy (multipart). - Most responses wrap their result in `data`: `{"data": {...}}` or `{"data": [...]}`. Exceptions are noted per endpoint. - IDs are UUIDs. Timestamps are ISO 8601 in UTC. - Create endpoints wrap their input in a resource key, for example `{"project": {...}}`. - Deletes return `204` with no body. - List endpoints aren't paginated. - Request bodies are limited to 8 MB. ## Errors [#errors] | Status | Typical body | Meaning | | --- | --- | --- | | `400` | `{"errors": {"detail": "Bad Request"}}` | Malformed ID or missing required wrapper key. | | `401` | `{"error": "unauthenticated"}`, `{"error": "invalid_token"}`, `{"error": "no_resource_found"}` | Missing, invalid, expired or revoked token. | | `401` | `{"error": "You are not authorized to …"}` | Not a member of the team, or your role can't do this. | | `401` | `{"error": "unauthorized"}` | A project key was used on a route that doesn't accept it. | | `402` | `{"error": "quota_exceeded", "metric": "…", "limit": 100, "used": 100, "plan": "free"}` | Plan limit reached. See [Billing](/docs/billing). | | `403` | `{"error": "Forbidden"}` | Role not allowed (project keys, billing, removing the owner). | | `404` | `{"error": "Not Found"}` or `{"errors": {"detail": "Not Found"}}` | Unknown resource or route. | | `422` | `{"errors": {"name": ["can't be blank"]}}` or `{"error": "…"}` | Validation failed. | | `500` | `{"errors": {"detail": "Internal Server Error"}}` | Server error. | Most permission failures return `401` with a message rather than `403`. Validation failures return `422` with an `errors` object keyed by field. ## Endpoints [#endpoints] | Area | Page | | --- | --- | | Deploy, run, schedule, cancel, list jobs and executions | [Jobs](/docs/api/jobs) | | Inbound triggers | [Triggers](/docs/api/triggers) | | Projects and project keys | [Projects](/docs/api/projects) | | Teams, members, invitations | [Teams](/docs/api/teams) | | Secrets | [Secrets](/docs/api/secrets) | | Personal API keys | [API keys](/docs/api/keys) | | Outbound webhooks | [Webhooks](/docs/api/webhooks) | | Stats and billing | [Stats and billing](/docs/api/stats-and-billing) | | Live execution updates | [Realtime](/docs/api/realtime) | # Jobs and executions (https://aperture-docs.mountaindev.com/docs/api/jobs) These are the only endpoints [project keys](/docs/concepts/authentication#project-key-scopes) can call (with the scope shown). Any team member can call them with a user token. ## Objects [#objects] ### Job [#job] ```json { "id": "6b1f…", "project_id": "c2a9…", "name": "nightly-report", "driver": "node", "cmd": "node dist/index.js", "install": "npm ci --omit=dev", "secrets": ["SLACK_WEBHOOK_URL"], "params": ["REPORT_DATE"], "schedule": "0 6 * * *", "inserted_at": "2026-11-20T10:00:00Z", "updated_at": "2026-11-23T09:12:44Z" } ``` `install`, `secrets`, `params` and `schedule` can be `null`. ### Execution [#execution] ```json { "id": "9f1c…", "status": "success", "source": "cron", "trigger_id": null, "error_code": null, "scheduled_time": "2026-11-23T06:00:00Z", "duration": 5234123, "log_url": "https://…", "inserted_at": "2026-11-22T06:00:04Z", "updated_at": "2026-11-23T06:00:09Z" } ``` - `status`: `scheduled`, `running`, `success`, `fail`, `cancelled`, `missed`. - `source`: `manual`, `cron` or `trigger`. - `error_code`: `missing_secrets`, `quota_exceeded`, `orphaned` or `null`. - `duration` is in microseconds. `log_url` expires 7 days after the run. See [Executions](/docs/concepts/executions). ## `POST /jobs/deploy` [#post-jobsdeploy] Scope: `deploy`. Creates or replaces a job. `multipart/form-data`: | Field | Required | Description | | --- | --- | --- | | `zip` | yes | The job's files as a zip archive. Its root becomes `/work`. | | `project_id` | yes | Project ID. | | `name` | yes | Job name. An existing name is replaced. | | `driver` | yes | `node`, `python` or `go`. | | `cmd` | yes | Command to run. | | `install` | no | Command run before `cmd`. | | `secrets[]` | no | Repeat for each declared secret name. | | `params[]` | no | Repeat for each declared param name. | | `schedule` | no | Cron expression (UTC). | ```sh curl -X POST "$API/jobs/deploy" -H "Authorization: Bearer $TOKEN" \ -F zip=@nightly-report.zip -F project_id=$PROJECT_ID -F name=nightly-report \ -F driver=node -F "cmd=node dist/index.js" -F "secrets[]=SLACK_WEBHOOK_URL" \ -F "schedule=0 6 * * *" ``` `201`, not wrapped in `data`: ```json { "status": "created", "job_id": 1234, "warnings": { "missing_secrets": ["SLACK_WEBHOOK_URL"] } } ``` `job_id` here is an internal ID for the background unpack task, not the job's UUID. `warnings` appears only when declared secrets aren't set. Files are unpacked asynchronously; listen for `job.deployment_succeeded` or `job.deployment_failed` [webhooks](/docs/webhooks). Errors: `400` missing zip, `422 {"error": "Invalid cron schedule."}`, `422 {"error": "Invalid job arguments."}` (missing field or reserved name). The zip and schedule are checked before anything is saved, so a rejected deploy leaves the existing job unchanged. ## `POST /jobs/run` [#post-jobsrun] Scope: `run`. Starts a run as soon as possible. ```json { "job": { "name": "nightly-report", "project_id": "c2a9…", "params": { "REPORT_DATE": "2026-11-22" } } } ``` `params` is optional. Values must be strings; names must match `^[A-Za-z_][A-Za-z0-9_]*$` and not start with `APERTURE_`. `200`: ```json { "data": { "name": "nightly-report", "execution_id": "9f1c…" } } ``` Errors: `402` quota exceeded, `404 {"error": "No such job"}`, `422` invalid params (with a `names` list). ## `POST /jobs/schedule` [#post-jobsschedule] Scope: `run`. Starts a run at a given time. ```json { "job": { "name": "nightly-report", "project_id": "c2a9…", "params": {} }, "run_at": "2026-11-24T06:00:00Z" } ``` `run_at` must be ISO 8601 **with** a UTC offset or `Z`; anything else returns `422`. `200`: ```json { "data": { "name": "nightly-report", "execution_id": "9f1c…", "run_at_local": "2026-11-24T06:00:00Z", "run_at_utc": "2026-11-24 06:00:00Z" } } ``` ## `PUT /jobs/{execution_id}/cancel` [#put-jobsexecution_idcancel] Scope: `run`. Cancels an execution that is still `scheduled`. Returns the updated execution in `data`. Any other status returns `404 {"error": "No such execution"}`. ## `GET /jobs/project/{project_id}` [#get-jobsprojectproject_id] Scope: `read`. Lists the project's jobs: `{"data": [Job, ...]}`. ## `GET /jobs/team/{team_id}` [#get-jobsteamteam_id] User tokens only. Lists jobs across all the team's projects. ## `GET /jobs/{id}/details` [#get-jobsiddetails] Scope: `read`. Returns a job with all its executions and the declared secrets that are missing from the project: ```json { "data": { "id": "6b1f…", "name": "nightly-report", "…": "…", "missing_secrets": [], "executions": [ { "id": "9f1c…", "status": "success", "…": "…" } ] } } ``` Executions aren't sorted; sort them by `scheduled_time` or `inserted_at`. # API keys (https://aperture-docs.mountaindev.com/docs/api/keys) Personal API keys act as you, with all your permissions, and last 52 weeks. These endpoints manage only your own keys and need a user token. For CI, prefer [project keys](/docs/api/projects#project-keys). ## Key object [#key-object] ```json { "id": "a7c3…", "name": "laptop script", "enabled": true, "last_used": "2026-11-23T09:12:44Z", "inserted_at": "…", "updated_at": "…" } ``` ## `GET /users/keys` [#get-userskeys] Lists your keys. ## `POST /users/keys` [#post-userskeys] ```json { "key": { "name": "laptop script" } } ``` `201` with the key plus `"token": "eyJ…"`, shown only now. Use it as `Authorization: Bearer `. ## `PUT /users/keys/{id}` [#put-userskeysid] ```json { "key": { "enabled": false } } ``` Renames, disables or re-enables a key. A disabled key stops working at once. ## `DELETE /users/keys/{id}` [#delete-userskeysid] `204`. # Projects (https://aperture-docs.mountaindev.com/docs/api/projects) User tokens only. Reads need team membership; writes need `owner` or `admin`. ## Project object [#project-object] ```json { "id": "c2a9…", "name": "Reports", "description": "Scheduled reporting jobs", "team_id": "8d41…" } ``` ## `GET /projects/{team_id}` [#get-projectsteam_id] Lists a team's projects. Note the path takes a **team** ID. ## `GET /projects/{id}/details` [#get-projectsiddetails] Returns one project. ## `POST /projects` [#post-projects] ```json { "project": { "team_id": "8d41…", "name": "Reports", "description": "…" } } ``` `201` with the project. Sends `project.created`. ## `PUT /projects/{id}` [#put-projectsid] ```json { "project": { "name": "Reporting", "description": "…" } } ``` Sends `project.updated`. ## `DELETE /projects/{id}` [#delete-projectsid] `204`. Sends `project.deleted`. ## Project keys [#project-keys] Project keys let CI deploy and run jobs; see [Authentication](/docs/concepts/authentication#project-key-scopes). Any member can list them; creating, rotating, updating and deleting needs `owner` or `admin` (others get `403`). ### Project key object [#project-key-object] ```json { "id": "e5d2…", "name": "github-actions", "token_prefix": "apk_Xy12ab", "scopes": ["deploy", "run"], "enabled": true, "last_used_at": "2026-11-23T09:12:44Z", "created_by": { "id": "…", "username": "you@example.com" }, "project_id": "c2a9…", "inserted_at": "2026-11-01T10:00:00Z", "updated_at": "2026-11-23T09:12:44Z" } ``` ### `GET /projects/{project_id}/keys` [#get-projectsproject_idkeys] Lists the project's keys, oldest first. Tokens aren't included. ### `POST /projects/{project_id}/keys` [#post-projectsproject_idkeys] ```json { "key": { "name": "github-actions", "scopes": ["deploy", "run"] } } ``` `name` is 1 to 100 characters, unique per project. `scopes` needs at least one of `deploy`, `run`, `read`. `201` with the key plus `"token": "apk_…"`, shown only now. ### `POST /projects/{project_id}/keys/{id}/rotate` [#post-projectsproject_idkeysidrotate] Issues a new token and invalidates the old one. `200` with the key and the new `token`. ### `PATCH /projects/{project_id}/keys/{id}` [#patch-projectsproject_idkeysid] ```json { "key": { "name": "ci", "enabled": false } } ``` Only `name` and `enabled` can change; scopes are fixed. ### `DELETE /projects/{project_id}/keys/{id}` [#delete-projectsproject_idkeysid] `204`. # Realtime (https://aperture-docs.mountaindev.com/docs/api/realtime) The dashboard gets live execution updates from a [Phoenix Channels](https://hexdocs.pm/phoenix/channels.html) websocket. You can subscribe from your own browser app with the `phoenix` npm package. ## Connect [#connect] - URL: `wss:///socket` (the transport path is `/socket/websocket`). - Authentication: a **login token** (from `/signin`). Personal API keys and project keys are refused. - Browsers can only connect from the dashboard's origin. ```ts import { Socket } from 'phoenix'; const socket = new Socket('wss://aperture-server.mountaindev.com/socket', { authToken: loginJwt, }); socket.connect(); ``` ## Subscribe to a job [#subscribe-to-a-job] Join `job_execution:`. Any member of the job's team can join; others get `{"reason": "unauthorized"}`. The channel only sends; it ignores messages from the client. ```ts const channel = socket.channel(`job_execution:${jobId}`); channel.on('scheduled', (execution) => console.log('new run', execution)); channel.on('updated', (change) => console.log('run changed', change)); channel.join(); ``` ## Events [#events] | Event | Payload | When | | --- | --- | --- | | `scheduled` | `id`, `status: "scheduled"`, `scheduled_time`, `log_url: null`, `duration: null`, `inserted_at`, `updated_at` | A run is created. | | `updated` | `id`, `name`, `status: "running"` | A run starts. | | `updated` | `id`, `name`, `status: "success" \| "fail"`, `error_code`, `log_url`, `duration` | A run finishes. | | `updated` | `id`, `status: "cancelled"` | A run is cancelled. | | `updated` | `id`, `name`, `status: "missed"` | A cron run was missed. | | `updated` | `id`, `name`, `status: "fail"`, `error_code: "orphaned"` | A run was orphaned. | `updated` payloads are partial: merge them into the execution with the same `id`. # Secrets (https://aperture-docs.mountaindev.com/docs/api/secrets) User tokens only; any team member can manage secrets. Jobs receive only the secrets their manifest declares. Keys are unique per project and can't start with `APERTURE_`. ## `GET /secrets/{project_id}` [#get-secretsproject_id] Lists the project's secrets with their **decrypted** values, and which jobs declare each one: ```json { "data": [ { "id": "f0a1…", "key": "SLACK_WEBHOOK_URL", "value": "https://hooks.slack.com/…", "project_id": "c2a9…", "used_by": ["nightly-report"] } ] } ``` ## `POST /secrets` [#post-secrets] ```json { "secret": { "project_id": "c2a9…", "key": "SLACK_WEBHOOK_URL", "value": "https://hooks.slack.com/…" } } ``` `201` with the secret, including the value you set. Sends `secret.created`. ## `PUT /secrets/{id}` [#put-secretsid] Updates the secret in the path. Send the fields to change: ```json { "secret": { "value": "https://hooks.slack.com/new" } } ``` `201` with the updated secret. Sends `secret.updated`. Invalid input (a missing or duplicate key, or one starting with `APERTURE_`) returns `422` with field errors. ## `DELETE /secrets/{id}` [#delete-secretsid] `204`. Sends `secret.deleted`. # Stats and billing (https://aperture-docs.mountaindev.com/docs/api/stats-and-billing) User tokens only. ## `GET /stats/{team_id}` [#get-statsteam_id] Any member. Counts for the current billing period, with a daily series: ```json { "data": { "projects_count": 3, "jobs_count": 12, "members_count": 4, "webhook_endpoints_count": 2, "job_successes_count": { "total": 120, "series": [{ "date": "2026-11-01", "value": 4 }] }, "job_failures_count": { "total": 3, "series": [] }, "job_cancelled_count": { "total": 1, "series": [] }, "webhook_delivery_successes_count": { "total": 240, "series": [] }, "webhook_delivery_failures_count": { "total": 2, "series": [] }, "billing_summary": { "plan": "pro", "…": "…" } } } ``` Series have one entry per day of the period, including zeros. ## `GET /teams/{team_id}/billing` [#get-teamsteam_idbilling] Any member. The team's plan and usage: ```json { "data": { "plan": "free", "status": "active", "billing_exempt": false, "can_manage_billing": true, "current_period_end": "2026-12-01T00:00:00Z", "usage": [ { "metric": "job_execution_minutes", "used": 42, "limit": 100, "percent": 42.0 }, { "metric": "webhook_deliveries", "used": 310, "limit": 1000, "percent": 31.0 } ] } } ``` On `premium`, `limit` is `null` and each metric adds `included`, `overage`, `estimated_overage_usd` and `percent_of_included`, with `estimated_overage_total_usd` and `base_price_usd` at the top level. ## `POST /teams/{team_id}/billing/checkout` [#post-teamsteam_idbillingcheckout] Owner or admin. Returns a Stripe Checkout URL to upgrade: ```json { "plan": "pro" } ``` ```json { "data": { "url": "https://checkout.stripe.com/…" } } ``` `plan` is `pro` or `premium`. ## `POST /teams/{team_id}/billing/portal` [#post-teamsteam_idbillingportal] Owner or admin. Returns a Stripe customer portal URL to manage the subscription. Teams with complimentary billing get `403` from checkout and portal. # Teams (https://aperture-docs.mountaindev.com/docs/api/teams) User tokens only. See [Teams and projects](/docs/concepts/projects-and-teams#roles) for what each role can do. ## Team object [#team-object] ```json { "id": "8d41…", "name": "Acme", "description": "…", "avatar_url": null } ``` ## `GET /teams` [#get-teams] Lists the teams you belong to. ## `GET /teams/{id}` [#get-teamsid] Returns a team you belong to. ## `POST /teams` [#post-teams] ```json { "team": { "name": "Acme", "description": "…" } } ``` `201`. You become the team's `owner`. ## `PUT /teams/{id}` [#put-teamsid] Owner or admin. Updates `name`, `description`, `avatar_url`. Sends `team.updated`. ## `DELETE /teams/{id}` [#delete-teamsid] Owner or admin. Deletes the team. `204`. ## Members [#members] ### `GET /teams/{id}/members` [#get-teamsidmembers] ```json { "data": [ { "id": "", "membership_id": "", "role": "owner", "name": "Ada", "username": "ada@example.com", "avatar_url": null, "member_since": "2026-01-01T00:00:00Z" } ] } ``` ### `DELETE /teams/{id}/members/{member_id}` [#delete-teamsidmembersmember_id] Owner or admin. Removes a member; `member_id` is either the `membership_id` or the user `id` from the members list. The owner can't be removed (`403`). ## Invitations [#invitations] ### `POST /teams/{id}/invite` [#post-teamsidinvite] Owner or admin. Emails an invitation. ```json { "invite": { "email": "new@example.com", "role": "member" } } ``` `role` is `admin` or `member`. `200`: ```json { "data": { "id": "…", "email": "new@example.com", "role": "member", "team_id": "8d41…" } } ``` ### `POST /teams/{id}/invite/{invite_id}/accept` [#post-teamsidinviteinvite_idaccept] Accepts an invitation as the signed-in user, whose email must match the invitation's (`403` otherwise). Returns the team. Sends `invite.accepted`. ### `DELETE /teams/{id}/invite/{invite_id}` [#delete-teamsidinviteinvite_id] Owner or admin. Revokes a pending invitation. `204`. # Triggers (https://aperture-docs.mountaindev.com/docs/api/triggers) See [Inbound triggers](/docs/triggers) for how triggers work. Management endpoints need a user token (login or personal API key); any team member can use them. `{job_name}` is the job's **name**. ## Trigger object [#trigger-object] ```json { "id": "3b0e…", "name": "budgets", "type": "sns", "enabled": true, "topic_arn": "arn:aws:sns:us-east-1:123456789012:budget-alerts", "last_fired_at": null, "url": "https://aperture-server.mountaindev.com/api/v1/triggers/3b0e…", "inserted_at": "2026-11-23T10:00:00Z", "updated_at": "2026-11-23T10:00:00Z" } ``` Create and rotate responses also contain the token, once: - generic: `"token": "trg_…"`, `"token_header": "X-Aperture-Trigger-Token"` - sns: `"token": "trg_…"`, `"subscription_url": "?token=trg_…"` ## `GET /projects/{project_id}/jobs/{job_name}/triggers` [#get-projectsproject_idjobsjob_nametriggers] Lists the job's triggers, oldest first. ## `POST /projects/{project_id}/jobs/{job_name}/triggers` [#post-projectsproject_idjobsjob_nametriggers] ```json { "trigger": { "name": "budgets", "type": "sns", "topic_arn": "arn:aws:sns:…", "enabled": true } } ``` | Field | Required | Notes | | --- | --- | --- | | `name` | yes | 1 to 100 characters, unique per job. | | `type` | yes | `generic` or `sns`. Can't be changed later. | | `topic_arn` | sns only | A valid SNS topic ARN. Not allowed on generic triggers. | | `enabled` | no | Defaults to `true`. | `201` with the trigger and its token. ## `POST /projects/{project_id}/jobs/{job_name}/triggers/{id}/rotate` [#post-projectsproject_idjobsjob_nametriggersidrotate] Issues a new token and invalidates the old one. `200` with the trigger and its new token. ## `PATCH /projects/{project_id}/jobs/{job_name}/triggers/{id}` [#patch-projectsproject_idjobsjob_nametriggersid] ```json { "trigger": { "enabled": false } } ``` Updates `name`, `enabled` or `topic_arn`. ## `DELETE /projects/{project_id}/jobs/{job_name}/triggers/{id}` [#delete-projectsproject_idjobsjob_nametriggersid] `204`. ## `POST /triggers/{trigger_id}` [#post-triggerstrigger_id] The public endpoint that starts a run. It uses the trigger's token instead of the `Authorization` header. See [Inbound triggers](/docs/triggers#responses) for the request format and every response. # Webhooks (https://aperture-docs.mountaindev.com/docs/api/webhooks) See [Outbound webhooks](/docs/webhooks) for events, payloads and signatures. User tokens only; any team member can manage endpoints. ## Endpoint object [#endpoint-object] ```json { "id": "4e7b…", "team_id": "8d41…", "url": "https://example.com/hooks/aperture", "description": "Ops alerts", "enabled": true, "events": ["execution.failed", "job.deployment_failed"], "project_ids": null, "schedule": null, "secret": "", "inserted_at": "…", "updated_at": "…", "deliveries": [ { "id": "…", "status": "success", "http_code": "200", "inserted_at": "…" } ] } ``` `deliveries` lists every attempt, newest first. The secret is never returned. ## `GET /webhooks/{team_id}` [#get-webhooksteam_id] Lists the team's endpoints with their deliveries. ## `POST /webhooks` [#post-webhooks] ```json { "webhook": { "team_id": "8d41…", "url": "https://example.com/hooks/aperture", "secret": "whsec_", "enabled": true, "events": ["execution.failed"], "project_ids": [], "description": "Ops alerts" } } ``` | Field | Required | Notes | | --- | --- | --- | | `team_id` | yes | | | `url` | yes | Must be `https://` on the hosted service. | | `secret` | yes | You generate it. Use `whsec_` followed by base64 of 32 random bytes. | | `enabled` | yes | | | `events` | yes | Event names; they aren't validated, so check spelling. | | `project_ids` | no | Empty or omitted for the whole team. | | `schedule` | with `cron.tick` | Cron expression (UTC). | | `description` | no | | `200` with the endpoint. When the endpoint is enabled, `cron.tick` and `schedule` must be set together, otherwise `400`. Generate a secret, for example: ```sh echo "whsec_$(openssl rand -base64 32)" ``` ## `PUT /webhooks/{id}` [#put-webhooksid] Same body as create, with only the fields to change. ## `DELETE /webhooks/{id}` [#delete-webhooksid] `204`. Also stops any scheduled `cron.tick` deliveries. # Plans and quotas (https://aperture-docs.mountaindev.com/docs/billing) Billing is per team. Owners and admins change the plan from the dashboard's **Billing** page, which uses Stripe Checkout and the Stripe customer portal. ## Plans [#plans] | Plan | Price | Execution minutes / month | Webhook deliveries / month | | --- | --- | --- | --- | | `free` | Free | 100 | 1,000 | | `pro` | $29 / month | 2,000 | 50,000 | | `premium` | $99 / month + usage | 10,000 included, then $0.008 / minute | 500,000 included, then $0.00008 / delivery | `free` and `pro` limits are hard caps. `premium` has no cap: usage above the included amount is billed. ## How usage is counted [#how-usage-is-counted] - **Execution minutes**: each run's duration, rounded **up** to whole minutes (a 5-second run counts as 1 minute). Runs refused because of the quota don't count. - **Webhook deliveries**: successful deliveries only. - Usage resets at the start of each calendar month (UTC). ## When a team hits its limit [#when-a-team-hits-its-limit] - Starting a run (CLI, API, dashboard, schedule or trigger) returns `402`: ```json { "error": "quota_exceeded", "metric": "job_execution_minutes", "limit": 100, "used": 100, "plan": "free" } ``` - A run already queued fails when it starts, with `error_code: "quota_exceeded"`. - Cron runs fail the same way until usage resets or the plan is upgraded. - Webhook events over the limit are dropped without retry. A team whose payment is `past_due` or `unpaid`, or whose subscription was cancelled and has ended, gets `free` limits. ## Complimentary teams [#complimentary-teams] Server administrators can mark a team as billing-exempt. Exempt teams have no limits and show **Complimentary** in the dashboard. A self-hosted server can also turn billing off entirely (`BILLING_ENABLED=false`), which makes every team exempt. See [Self-hosting](/docs/self-hosting/operations#billing-exempt-teams). # Deploying from CI (https://aperture-docs.mountaindev.com/docs/ci) Use a **project key** in CI rather than a personal token. It works only on one project, only for the actions you choose, and it isn't tied to a person. ## 1. Create a project key [#1-create-a-project-key] In the dashboard, open the project's settings and add a key under **CI Keys**. Pick its scopes: - `deploy` to deploy jobs, - `run` to run, schedule and cancel them, - `read` to list jobs and read executions. Copy the `apk_…` token; it's shown once. Creating keys needs the `owner` or `admin` role. You can also create keys with the [API](/docs/api/projects#project-keys). ## 2. Configure the pipeline [#2-configure-the-pipeline] Store the token and the project ID as CI secrets, then expose them as `APERTURE_AUTH_TOKEN` and `APERTURE_PROJECT_ID`. The CLI needs no login or config file. ```yaml title=".github/workflows/deploy-jobs.yml" name: Deploy jobs on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest env: APERTURE_AUTH_TOKEN: ${{ secrets.APERTURE_PROJECT_KEY }} APERTURE_PROJECT_ID: ${{ vars.APERTURE_PROJECT_ID }} # APERTURE_API_URL: https://aperture.example.com # self-hosted only steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1.24' - uses: actions/setup-node@v4 # if your jobs build with npm with: node-version: '22' - name: Install aperture-cli run: | # The CLI's source must be available to the pipeline, e.g. checked out # from the Aperture repository or vendored in yours. cd path/to/aperture/cli && go build -o /usr/local/bin/aperture-cli ./cmd/aperture-cli.go - run: aperture-cli deploy nightly-report - run: aperture-cli deploy weekly-digest ``` ## Calling the API directly [#calling-the-api-directly] Project keys work with plain HTTP too: ```sh curl -X POST "$APERTURE_API_URL/api/v1/jobs/run" \ -H "Authorization: Bearer $APERTURE_AUTH_TOKEN" \ -H "Content-Type: application/json" \ -d '{"job": {"name": "nightly-report", "project_id": "'"$APERTURE_PROJECT_ID"'", "params": {"DRY_RUN": "true"}}}' ``` ## Managing keys [#managing-keys] Owners and admins can rename, disable, **rotate** (issue a new token and invalidate the old one) or delete keys from the project settings. The key list shows each key's prefix and when it was last used. Project keys don't expire. # CLI (https://aperture-docs.mountaindev.com/docs/cli) `aperture-cli` deploys and runs jobs and manages inbound triggers and outbound webhooks. ## Install [#install] The CLI is a Go program in the `cli/` directory of the Aperture repository. With Go 1.24 or later: ```sh cd cli go build -o aperture-cli ./cmd/aperture-cli.go sudo mv aperture-cli /usr/local/bin/ ``` ## Usage [#usage] ```text aperture-cli [flags] [args...] ``` Flags can go before or after the arguments. | Flag | Default | Description | | --- | --- | --- | | `-P`, `--project` | `$APERTURE_PROJECT_ID` | Project ID. Required by `deploy`, `run` and `triggers`. | | `-p`, `--path` | `jobs` | Directory that holds job directories, relative to the current directory. | | `-s`, `--schedule` | | `run` only: run at this ISO 8601 time (with offset) instead of now. | | `-c`, `--config` | see [Configuration](#configuration) | Path to the config file. | | `-h`, `--help` | | Print usage and exit. `aperture-cli help` and running with no arguments do the same. | A job argument (``) is the **name of a directory** under `--path`, not a file path: `deploy hello` reads `./jobs/hello/job.json`. ## Commands [#commands] ### `login ` [#login-email] ```sh aperture-cli login you@example.com ``` Prompts for your password (it needs an interactive terminal), signs in, and saves the token to the config file. The token isn't printed. The token is valid for 52 weeks. To log in to a self-hosted server, set `APERTURE_API_URL` first; it's saved too. ### `deploy ` [#deploy-job] ```sh aperture-cli deploy nightly-report -P ``` Runs the manifest's `build` command, zips the `includes`, and uploads the job. Prints a warning if the job declares secrets the project doesn't have. See [Jobs](/docs/concepts/jobs#deploying). ### `run [NAME=value ...]` [#run-job-namevalue-] ```sh aperture-cli run nightly-report aperture-cli run nightly-report REPORT_DATE=2026-11-22 DRY_RUN=true aperture-cli run nightly-report --schedule 2026-11-24T06:00:00Z ``` Starts a run now, or at `--schedule`. Each `NAME=value` becomes an environment variable. Names must be valid environment variable names and can't start with `APERTURE_`. The command prints the execution ID and returns; it doesn't wait for the run. ### `triggers` [#triggers] Manage a job's [inbound triggers](/docs/triggers). ```text aperture-cli triggers [list] aperture-cli triggers create name= [type=generic|sns] [topic_arn=] aperture-cli triggers rotate aperture-cli triggers enable aperture-cli triggers disable aperture-cli triggers delete ``` `create` and `rotate` print the token **once**. `type=sns` requires `topic_arn`. ### `webhooks` [#webhooks] Manage the team's [outbound webhooks](/docs/webhooks). ```text aperture-cli webhooks [list] aperture-cli webhooks create team_id= url= events= [enabled=true] [description=] [project_ids=] [schedule=] aperture-cli webhooks delete ``` `create` generates a signing secret and prints it once. Endpoints are created **disabled** unless you pass `enabled=true`. `schedule` is required when `events` includes `cron.tick`. There's no update command; use the dashboard or the [API](/docs/api/webhooks). `triggers` and `webhooks` need a login token or personal API key; project keys can't use them. ## Configuration [#configuration] The CLI stores its settings in a JSON file: | OS | Default path | | --- | --- | | macOS | `~/Library/Application Support/aperture/config.json` | | Linux | `$XDG_CONFIG_HOME/aperture/config.json` or `~/.config/aperture/config.json` | | Windows | `%AppData%\aperture\config.json` | ```json { "ApiUrl": "https://aperture-server.mountaindev.com", "AuthToken": "eyJ..." } ``` The file holds your token, so the CLI writes it readable only by you (`0600`, in a `0700` directory). Environment variables override the file: | Variable | Description | | --- | --- | | `APERTURE_API_URL` | Server URL. Defaults to `https://aperture-server.mountaindev.com` when there's no config file. | | `APERTURE_AUTH_TOKEN` | Token to send. Any [token type](/docs/concepts/authentication) works. | | `APERTURE_PROJECT_ID` | Default for `--project`. | With `APERTURE_AUTH_TOKEN` and `APERTURE_PROJECT_ID` set, no config file or login is needed; this is how CI uses it. See [Deploying from CI](/docs/ci). ## Output and exit codes [#output-and-exit-codes] Progress and results are logged to stderr; trigger and webhook listings and newly issued credentials go to stdout. There's no JSON output mode. The CLI exits `0` on success (including `help`) and `1` on errors, including unknown commands. HTTP errors print the status code and the server's message. The CLI has no commands for cancelling runs, reading logs, or managing projects and secrets yet; use the dashboard or the [API](/docs/api). # Authentication (https://aperture-docs.mountaindev.com/docs/concepts/authentication) Every authenticated API request sends a token in the `Authorization` header: ```http Authorization: Bearer ``` Aperture accepts three kinds of token. | | Login token | Personal API key | Project key | | --- | --- | --- | --- | | Get it from | `aperture-cli login`, `POST /signin` | Dashboard **API Keys**, `POST /users/keys` | Project settings **CI Keys**, `POST /projects/{id}/keys` | | Looks like | JWT | JWT | `apk_…` | | Acts as | You | You | The project only | | Can do | Everything you can | Everything you can, except the websocket | Only its [scopes](#project-key-scopes) | | Expires | After 52 weeks | After 52 weeks | Never | | Revoke | Not possible | Disable or delete the key | Disable, rotate or delete the key | | Use for | The CLI on your machine, the dashboard | Scripts and integrations | CI/CD pipelines | Tokens are shown **once**, when they are created (and, for project keys, when rotated). Aperture stores only a hash. ## Project key scopes [#project-key-scopes] A project key works only on its own project, and only for the routes its scopes allow. Scopes are chosen when the key is created and can't be changed. | Scope | Allows | | --- | --- | | `deploy` | Deploying jobs (`POST /jobs/deploy`) | | `run` | Running, scheduling and cancelling (`POST /jobs/run`, `POST /jobs/schedule`, `PUT /jobs/{execution_id}/cancel`) | | `read` | Listing jobs and reading job details with executions (`GET /jobs/project/{project_id}`, `GET /jobs/{id}/details`) | Every other route rejects project keys with `401`, including trigger and webhook management. Creating, rotating and deleting project keys requires the `owner` or `admin` role. See [Deploying from CI](/docs/ci) for a full example. ## Inbound trigger tokens [#inbound-trigger-tokens] [Inbound triggers](/docs/triggers) use their own `trg_…` tokens, which can only start runs of one job. They aren't accepted anywhere else. # Executions (https://aperture-docs.mountaindev.com/docs/concepts/executions) Every run of a job is an **execution**. Executions start from one of three sources: `manual` (CLI, dashboard or API, including one-off schedules), `cron`, or `trigger`. ## Statuses [#statuses] | Status | Meaning | | --- | --- | | `scheduled` | Waiting to run, either as soon as possible or at a set time. | | `running` | The runner is executing the job. | | `success` | `install` (if any) and `cmd` both exited with code 0. | | `fail` | A command exited non-zero, or the run couldn't start. See `error_code`. | | `cancelled` | Cancelled while still `scheduled`. | | `missed` | A cron run that couldn't start within 5 minutes of its time. | ```text scheduled ──► running ──► success | fail │ ├──► cancelled (cancel request, or the cron schedule changed) └──► missed (cron only, more than 300 s late) ``` There is no separate "queued" status: `scheduled` covers both. ### Error codes [#error-codes] A failed execution may carry an `error_code`: | `error_code` | Cause | | --- | --- | | `missing_secrets` | The job declares secrets that aren't set in the project. The code never ran. | | `quota_exceeded` | The team was out of execution minutes when the run started. See [Billing](/docs/billing). | | `orphaned` | The worker running it stopped sending heartbeats for over 5 minutes (for example, the server restarted mid-run). | A plain non-zero exit leaves `error_code` empty; read the log. ## Logs [#logs] When a run finishes, its output is stored and exposed as `log_url` on the execution (in the dashboard's **View Logs** button, the API, and execution webhooks). - The log contains all of stdout (the `install` step, then `cmd`) followed by all of stderr. The two streams are **not interleaved** by time. - Logs are only available after the run ends; there is no live streaming. - `log_url` is a pre-signed link that **expires after 7 days**. ## Duration [#duration] `duration` is in **microseconds** and covers the whole run, including `install`. Billing rounds each run up to whole minutes. ## Cancelling [#cancelling] You can cancel an execution only while it is `scheduled`, from the dashboard or with `PUT /api/v1/jobs/{execution_id}/cancel`. A running execution can't be stopped. Cancelling a pending cron run skips that slot; the next one is scheduled within a minute. ## Retries [#retries] Aperture doesn't re-run failed executions. If you need retries, build them into your code or start a new run. ## Live updates [#live-updates] The dashboard updates executions in real time over a websocket. See [Realtime](/docs/api/realtime). # Jobs (https://aperture-docs.mountaindev.com/docs/concepts/jobs) A **job** is a named unit of code inside a project. It's defined by a directory containing your code and a [`job.json` manifest](/docs/job-manifest), and it's identified by its `name`, which is unique within the project. ## Deploying [#deploying] `aperture-cli deploy ` does the following: 1. Runs the manifest's `build` command locally, if it has one. 2. Zips the files listed in `includes`. 3. Uploads the zip and the manifest fields to `POST /api/v1/jobs/deploy`. The server saves the job definition right away and responds `201`. A background worker then unpacks the zip into a fresh directory and swaps it in atomically, so files you removed since the last deploy disappear. When unpacking finishes, Aperture sends a `job.deployment_succeeded` or `job.deployment_failed` [webhook](/docs/webhooks). The upload limit is **8 MB** for the whole request. ## Redeploying [#redeploying] Deploying a name that already exists in the project **replaces** that job. Every manifest field is overwritten, so removing a field from `job.json` and redeploying clears it, for example removing `schedule` stops the cron schedule. Runs always use the job definition that is current **when the run starts**, so a run queued before a redeploy uses the new `cmd`. The definition is updated before the new files are unpacked. A run that starts in the few seconds between the two can use the new command with the old files. ## Missing secrets [#missing-secrets] If the manifest declares secrets that aren't set in the project yet, the deploy still succeeds but returns a warning (the CLI prints it). Runs fail with `error_code: "missing_secrets"` until you add them. ## Updating and deleting [#updating-and-deleting] Jobs are created and changed **only by deploying**. There is currently no API, CLI command or dashboard action that deletes a job. See [Limitations](/docs/limitations). # Teams and projects (https://aperture-docs.mountaindev.com/docs/concepts/projects-and-teams) ## The hierarchy [#the-hierarchy] ```text Team ─┬─ Members (owner, admin, member) ├─ Outbound webhooks ├─ Billing plan and usage └─ Projects ─┬─ Jobs ── Executions ├─ Secrets ├─ Project keys └─ Inbound triggers (per job) ``` - A **team** is the unit of membership and billing. Every user can belong to several teams. - A **project** groups jobs that share secrets and CI keys. Job names are unique within a project. - A **job** is deployed code plus its manifest. See [Jobs](/docs/concepts/jobs). ## Roles [#roles] Each team member has one role. The user who creates a team becomes its `owner`; invitations grant `admin` or `member`. | Action | owner | admin | member | | --- | :-: | :-: | :-: | | View team, members, projects, jobs, executions, stats, billing | ✓ | ✓ | ✓ | | Deploy, run, schedule and cancel jobs | ✓ | ✓ | ✓ | | Manage secrets | ✓ | ✓ | ✓ | | Manage inbound triggers | ✓ | ✓ | ✓ | | Manage outbound webhooks | ✓ | ✓ | ✓ | | List project keys | ✓ | ✓ | ✓ | | Create, rotate, update, delete project keys | ✓ | ✓ | | | Create, update, delete projects | ✓ | ✓ | | | Update or delete the team | ✓ | ✓ | | | Invite and remove members | ✓ | ✓ | | | Change the billing plan | ✓ | ✓ | | The team owner can't be removed from the team. ## Invitations [#invitations] Owners and admins invite people by email with a role of `admin` or `member`. Aperture emails the invitation. The invited person accepts it while signed in with an account whose email matches the invitation (case-insensitive). Pending invitations can be revoked. ## Secrets [#secrets] Secrets are key/value pairs stored per project and encrypted at rest. A job only receives the secrets it **declares** in its manifest's `secrets` list; they arrive as environment variables. Secret names can't start with the reserved `APERTURE_` prefix. See [Writing jobs](/docs/writing-jobs#environment-variables). Anyone in the team can read secret values from the dashboard or the API. # Scheduling (https://aperture-docs.mountaindev.com/docs/concepts/scheduling) ## One-off runs at a time [#one-off-runs-at-a-time] Pass `--schedule` with an ISO 8601 timestamp **that includes a UTC offset**: ```sh aperture-cli run nightly-report REPORT_DATE=2026-11-22 --schedule 2026-11-24T06:00:00Z aperture-cli run nightly-report --schedule 2026-11-24T08:00:00+02:00 ``` Or call `POST /api/v1/jobs/schedule` (see [Jobs API](/docs/api/jobs)), or use **Schedule Execution** on the job's page in the dashboard. The execution is created with status `scheduled` and runs at that time. A time in the past runs immediately. You can cancel it until it starts. ## Cron schedules [#cron-schedules] Add a `schedule` to the [manifest](/docs/job-manifest) and deploy: ```json { "schedule": "0 6 * * 1-5" } ``` - Standard 5-field cron: minute, hour, day of month, month, day of week. Lists (`,`), ranges (`-`), steps (`/`) and names (`MON`, `JAN`) work. - Shortcuts: `@hourly`, `@daily`, `@midnight`, `@weekly`, `@monthly`, `@yearly`, `@annually`. Don't use `@reboot`. - Schedules are evaluated in **UTC**. - Cron runs receive **no params**. Give every param your code reads a default. ### How cron runs behave [#how-cron-runs-behave] - Each scheduled job always has exactly one upcoming `scheduled` execution, visible in the dashboard. - If a cron run can't start within **5 minutes** of its time (for example the server was down), it's marked `missed` and not run late. Slots missed during downtime are skipped, not backfilled. - Removing `schedule` and redeploying cancels the upcoming run. ## Scheduled webhooks [#scheduled-webhooks] Outbound webhooks can also fire on a cron schedule with the `cron.tick` event, without running any job. See [Webhooks](/docs/webhooks#scheduled-deliveries). # Introduction (https://aperture-docs.mountaindev.com/docs) Aperture is an asynchronous job execution engine, similar in spirit to AWS Lambda. You package a directory of code with a small `job.json` manifest, deploy it to a project, and Aperture runs it in an isolated container whenever you ask: - **On demand** from the CLI, the dashboard, or the REST API. - **At a specific time** with a one-off schedule. - **On a cron schedule** declared in the manifest. - **From an inbound trigger**: an HTTP endpoint that AWS EventBridge, SNS, or any other system can call. Each run is an **execution** with a status, a duration and a log. Aperture can notify your systems about executions, deployments and other changes with signed **outbound webhooks**. ## How the pieces fit [#how-the-pieces-fit] | Piece | What you use it for | | --- | --- | | [Dashboard](#dashboard) | Manage teams, projects, secrets, keys and webhooks; watch runs live. | | [`aperture-cli`](/docs/cli) | Deploy and run jobs; manage inbound triggers and webhooks. | | [REST API](/docs/api) | Everything the CLI and dashboard do, over HTTP. | | [`@acruxdynamics/aperture`](/docs/sdk) | Node SDK for job code: read params, secrets and trigger payloads; verify webhooks. | Jobs can be written in **Node.js**, **Python** or **Go**. See [Writing jobs](/docs/writing-jobs). ## Dashboard [#dashboard] The dashboard is the web UI for Aperture. From it you can: - see team-wide stats (successes, failures, webhook deliveries, usage), - browse jobs and their executions, with live status updates and logs, - create teams, invite members, and create projects, - manage project secrets, project keys (for CI) and your personal API keys, - configure outbound webhooks and see their deliveries, - manage the team's billing plan. ## Where to start [#where-to-start] # Job manifest (job.json) (https://aperture-docs.mountaindev.com/docs/job-manifest) Each job directory contains a `job.json` that describes how to package and run the job. ```json title="jobs/nightly-report/job.json" { "name": "nightly-report", "driver": "node", "build": "npm run build", "install": "npm ci --omit=dev", "cmd": "node dist/index.js", "includes": ["dist", "package.json", "package-lock.json"], "secrets": ["SLACK_WEBHOOK_URL"], "params": ["REPORT_DATE"], "schedule": "0 6 * * *" } ``` ## Fields [#fields] | Field | Type | Required | Description | | --- | --- | --- | --- | | `name` | string | yes | The job's name, unique within the project. Deploying an existing name replaces that job. Stick to letters, digits, `-` and `_`. | | `driver` | string | yes | The runtime: `node`, `python` or `go`. See [Writing jobs](/docs/writing-jobs#runtimes). | | `cmd` | string | yes | Shell command that runs the job, executed with `sh -c` in the job's directory. | | `install` | string | no | Shell command run before `cmd` on **every** run, for example `npm ci` or `pip install -r requirements.txt`. If it fails, `cmd` doesn't run. | | `build` | string | no | Shell command the **CLI** runs on your machine before packaging, for example `npm run build`. Not sent to the runner. | | `includes` | string[] | yes, in practice | The files and directories to upload. See [Packaging](#packaging). | | `secrets` | string[] | no | Names of project secrets to pass to the job as environment variables. Only declared secrets are passed. | | `params` | string[] | no | Names of the parameters the job accepts. Shown in the dashboard; not enforced (see below). | | `schedule` | string | no | Cron expression, evaluated in UTC. See [Scheduling](/docs/concepts/scheduling). | Notes: - Keys are matched case-insensitively. Unknown keys are ignored silently, so check spelling. - Names in `secrets` and `params` can't start with `APERTURE_`; that prefix is reserved for [platform variables](/docs/writing-jobs#environment-variables). - Omitted fields are cleared on redeploy. - `params` is informational. Runs may pass params that aren't declared, and declared params may be missing. Read them with a default in your code. ## Packaging [#packaging] The CLI walks the job directory and adds a file or directory to the zip when: - its **name** (not path) matches an entry in `includes`, at any depth, or - it is inside a directory that matched. | `includes` entry | What it adds | | --- | --- | | `"dist"` | The `dist/` directory and everything in it. | | `"main.py"` | Every file named `main.py`, at any depth. | | `"package.json"` | `./package.json`, **and** any nested `package.json`, including inside `node_modules` if it exists locally. | | `"src/index.ts"` | Nothing: entries containing `/` never match. | There are no globs and no default exclusions (`.gitignore` is ignored). `job.json` itself is only uploaded if you list it. If nothing matches, the deploy stops with `No files were included`. The archive's contents become the job's working directory, `/work`, at run time. ## Where the CLI looks for job.json [#where-the-cli-looks-for-jobjson] `aperture-cli deploy ` reads `/jobs//job.json`. Change the base directory with `--path`: ```sh aperture-cli deploy nightly-report # ./jobs/nightly-report/job.json aperture-cli deploy nightly-report --path . # ./nightly-report/job.json aperture-cli deploy nightly-report --path services/jobs ``` `run` and `triggers` also read the local `job.json` to get the job's name. # Current limitations (https://aperture-docs.mountaindev.com/docs/limitations) Aperture is under active development. This page lists behavior that commonly surprises people, so you can design around it. Linked issues are in the Aperture repository. ## Runs [#runs] | Limitation | Workaround | Tracking | | --- | --- | --- | | No execution timeout. A run that never exits keeps running. | Add your own timeout in code. | [#51](https://github.com/acrux-dynamics/aperture-server/issues/51), [#32](https://github.com/acrux-dynamics/aperture-server/issues/32) | | No per-job CPU or memory limits. | | [#32](https://github.com/acrux-dynamics/aperture-server/issues/32) | | Failed runs aren't retried. | Retry inside your code, or start a new run from a webhook. | [#32](https://github.com/acrux-dynamics/aperture-server/issues/32) | | A running execution can't be stopped; only `scheduled` ones can be cancelled. | | | | Runtime versions aren't pinned (`node:alpine`, `python:slim`, `golang:alpine`), and `install` runs on every run. | Bundle dependencies into the upload. | [#36](https://github.com/acrux-dynamics/aperture-server/issues/36) | | Logs are only available after a run ends, stdout and stderr aren't interleaved, and log links expire after 7 days. | Send important output to your own logging too. | [#39](https://github.com/acrux-dynamics/aperture-server/issues/39) | | Declared `params` aren't enforced and have no defaults. | Read params with a default in code. | [#46](https://github.com/acrux-dynamics/aperture-server/issues/46) | | Trigger payloads are limited to 100 KiB, passed in an environment variable. | Pass a reference (like an S3 key) instead of large data. | [#40](https://github.com/acrux-dynamics/aperture-server/issues/40) | ## Scheduling [#scheduling] | Limitation | Tracking | | --- | --- | | Cron schedules are always UTC, and a job has one schedule. | [#30](https://github.com/acrux-dynamics/aperture-server/issues/30) | | Cron schedules can't be paused; remove `schedule` and redeploy. | [#52](https://github.com/acrux-dynamics/aperture-server/issues/52) | | Cron runs receive no params. | [#46](https://github.com/acrux-dynamics/aperture-server/issues/46) | ## Jobs and deploys [#jobs-and-deploys] | Limitation | Tracking | | --- | --- | | Jobs can't be deleted, and there's no version history. | [#59](https://github.com/acrux-dynamics/aperture-server/issues/59), [#26](https://github.com/acrux-dynamics/aperture-server/issues/26) | | Job names aren't validated; use letters, digits, `-` and `_`. | [#58](https://github.com/acrux-dynamics/aperture-server/issues/58) | ## API, CLI and dashboard [#api-cli-and-dashboard] | Limitation | Tracking | | --- | --- | | The CLI can't cancel runs, read logs, or manage projects and secrets. | [#25](https://github.com/acrux-dynamics/aperture-server/issues/25) | | The dashboard has no screen for inbound triggers. | [#41](https://github.com/acrux-dynamics/aperture-server/issues/41) | | Inbound triggers have no rate limits. | [#42](https://github.com/acrux-dynamics/aperture-server/issues/42) | | List endpoints aren't paginated. | [#23](https://github.com/acrux-dynamics/aperture-server/issues/23) | | Webhook signature checks have no built-in replay window. | | # Quickstart (https://aperture-docs.mountaindev.com/docs/quickstart) This guide uses the hosted Aperture at `https://aperture-server.mountaindev.com`. If you run your own server, set `APERTURE_API_URL` to its URL before step 3 (see [Self-hosting](/docs/self-hosting)). ## 1. Create a team and a project [#1-create-a-team-and-a-project] Sign up in the dashboard, create a **team**, then create a **project** inside it. Copy the project's ID (a UUID) from the project page; the CLI needs it. ## 2. Install the CLI [#2-install-the-cli] The CLI is a Go program in the `cli/` directory of the Aperture repository. With Go 1.24 or later: ```sh cd cli go build -o aperture-cli ./cmd/aperture-cli.go sudo mv aperture-cli /usr/local/bin/ ``` ## 3. Log in [#3-log-in] ```sh aperture-cli login you@example.com ``` The CLI prompts for your password and saves a token (valid for 52 weeks) in its [config file](/docs/cli#configuration). ## 4. Write a job [#4-write-a-job] The CLI looks for jobs in a `jobs/` directory under your current directory, one sub-directory per job: ```text jobs/ └── hello/ ├── job.json └── index.js ``` `jobs/hello/index.js`: ```js const name = process.env.WHO ?? 'world'; console.log(`Hello, ${name}!`); ``` `jobs/hello/job.json`: ```json { "name": "hello", "driver": "node", "cmd": "node index.js", "includes": ["index.js"], "params": ["WHO"] } ``` `includes` lists what gets uploaded. Only listed files and directories are packaged; see [Job manifest](/docs/job-manifest). ## 5. Deploy [#5-deploy] ```sh export APERTURE_PROJECT_ID= aperture-cli deploy hello ``` Deploys are asynchronous: the server accepts the upload and unpacks it in the background, usually within seconds. ## 6. Run it [#6-run-it] ```sh aperture-cli run hello WHO=Aperture ``` The CLI prints the new execution's ID and returns immediately; it doesn't wait for the run. Open the job in the dashboard to watch the execution move from `scheduled` to `running` to `success`, and to read its log (`Hello, Aperture!`). ## Next steps [#next-steps] - Run the job on a schedule: add `"schedule": "0 6 * * *"` to `job.json` and deploy again. See [Scheduling](/docs/concepts/scheduling). - Use secrets: add them to the project, list them in `secrets`, and read them from environment variables. See [Writing jobs](/docs/writing-jobs). - Deploy from CI with a project key. See [Deploying from CI](/docs/ci). - Start the job from AWS or any HTTP client. See [Inbound triggers](/docs/triggers). # Node SDK (https://aperture-docs.mountaindev.com/docs/sdk) `@acruxdynamics/aperture` is a small, dependency-free helper library for Node.js (18 or later). It's ESM-only and ships TypeScript types. ```sh npm install @acruxdynamics/aperture ``` Using it is optional: everything it reads is a plain environment variable. ## Params and secrets [#params-and-secrets] ```ts import { getApertureParam, getApertureSecret } from '@acruxdynamics/aperture'; const date = getApertureParam('REPORT_DATE', new Date().toISOString().slice(0, 10)); const slackUrl = getApertureSecret('SLACK_WEBHOOK_URL'); ``` ### `getApertureParam(name, defaultValue?)` [#getapertureparamname-defaultvalue] Returns the value of the environment variable `name`. If it's unset or empty, returns `defaultValue`. If that's also missing or empty, throws `ApertureRuntime: Parameter is not set`. ### `getApertureSecret(name, defaultValue?)` [#getaperturesecretname-defaultvalue] Same behavior; the error is `ApertureRuntime: Secret is not set`. Remember to list the secret in the manifest's `secrets`. ## Trigger payloads [#trigger-payloads] ```ts import { getApertureTrigger, type EventBridgeEvent } from '@acruxdynamics/aperture'; const trigger = getApertureTrigger(); if (!trigger) { console.log('manual or scheduled run'); } else if (trigger.source === 'generic') { const event = trigger.json>(); console.log(event['detail-type'], event.detail.severity); } else { console.log(trigger.sns?.subject, trigger.payload); } ``` ### `getApertureTrigger()` [#getaperturetrigger] Returns `null` when the run wasn't started by a trigger. Otherwise returns an `ApertureTriggerEvent`: ```ts interface ApertureTriggerEvent { triggerId: string; source: 'generic' | 'sns'; payload: string; // raw body (generic) or SNS Message (sns) sns?: { subject?: string; messageId?: string; topicArn?: string }; json(): T; // JSON.parse(payload); throws if not JSON } ``` ### `requireApertureTrigger()` [#requireaperturetrigger] Like `getApertureTrigger()`, but throws when the run wasn't started by a trigger. ## Firing a trigger [#firing-a-trigger] Start a run of another job from code, through its **generic** trigger: ```ts import { fireApertureTrigger, ApertureTriggerError } from '@acruxdynamics/aperture'; try { const { executionId, duplicate } = await fireApertureTrigger({ url: 'https://aperture-server.mountaindev.com/api/v1/triggers/', token: process.env.REPORT_TRIGGER_TOKEN!, payload: { reportId: 42 }, // objects are sent as JSON, strings as text/plain }); console.log('started', executionId, duplicate ? '(duplicate)' : ''); } catch (err) { if (err instanceof ApertureTriggerError) console.error(err.status, err.body); throw err; } ``` Any response other than `202` throws an `ApertureTriggerError` with `status` and `body`. You can pass a custom `fetch` in the options. ## Verifying webhooks [#verifying-webhooks] `buildApertureWebhook` checks an [outbound webhook](/docs/webhooks)'s signature and returns the parsed event. Pass the **raw** request body, not re-serialized JSON. ```ts import express from 'express'; import { buildApertureWebhook } from '@acruxdynamics/aperture'; const app = express(); app.post('/hooks/aperture', express.raw({ type: 'application/json' }), (req, res) => { let event; try { event = buildApertureWebhook(process.env.APERTURE_WEBHOOK_SECRET!, { rawBody: req.body, headers: req.headers, // a plain object or a Fetch Headers instance }); } catch { return res.sendStatus(400); } if (event.type === 'execution.failed') { console.log('job failed', event.data.object); } res.sendStatus(200); }); ``` It throws when the `aperture-signature` header is missing or malformed, the signature doesn't match, the body isn't JSON, or the envelope's `api_version` isn't `2025-05-01`. It doesn't check the timestamp. To guard against replayed requests, reject events whose `created` time is too old, or remember the event `id`s you've processed. ## Exports [#exports] | Export | Kind | | --- | --- | | `getApertureParam`, `getApertureSecret` | functions | | `getApertureTrigger`, `requireApertureTrigger` | functions | | `fireApertureTrigger`, `ApertureTriggerError` | function, error class | | `buildApertureWebhook` | function | | `ApertureTriggerEvent`, `ApertureTriggerSource`, `ApertureSnsMetadata`, `EventBridgeEvent` | types | | `FireApertureTriggerOptions`, `FireApertureTriggerResult` | types | | `ApertureWebhookData`, `ApertureWebhookEnvelope`, `ApertureApiVersion` | types | ## TypeScript config [#typescript-config] `@acruxdynamics/tsconfig` is a shared base config (ES2023, ESNext modules, bundler resolution, strict). It expects `@types/node`: ```json title="tsconfig.json" { "extends": "@acruxdynamics/tsconfig/tsconfig.json", "compilerOptions": { "outDir": "dist" }, "include": ["src"] } ``` # Configuration (https://aperture-docs.mountaindev.com/docs/self-hosting/configuration) All services read `.env` in the repository root (start from `.env.example`). ## Server [#server] Variables marked **required** stop the server from starting when missing. ### Core [#core] | Variable | Required | Default | Description | | --- | --- | --- | --- | | `SECRET_KEY_BASE` | yes | | Phoenix secret. Generate with `./run secret`. | | `GUARDIAN_SECRET_KEY` | yes | | Signs login tokens and API keys. Changing it invalidates every token. | | `ENCRYPTION_KEY` | yes | | Encrypts secrets (AES-256). Must be **base64 of 32 bytes** (`openssl rand -base64 32`); the server refuses to start otherwise. Don't change it once secrets exist. | | `URL_HOST` | yes | | Public host of the API, used in generated URLs such as trigger URLs. | | `URL_SCHEME` | | `https` | Scheme for generated URLs. | | `URL_PORT` | | `443` | Port for generated URLs. | | `PORT` | | `4000` | Port the server listens on. | | `DASHBOARD_URL` | | `http://localhost:5173` | Dashboard URL, used in invitation emails and Stripe redirects. Also the only browser origin allowed on the websocket. | | `REGISTRATIONS_ENABLED` | | off | Set to `true` to allow sign-ups from the dashboard and API. Admin tasks and seeds ignore it. | | `BILLING_ENABLED` | | `true` | Set to `false` to run without Stripe: the `STRIPE_*` variables become optional, every team is billing-exempt, and the Stripe webhook endpoint returns `404`. | | `RUNNER_URL` | | `http://runner:5000` | Runner service URL. Read when the server is **built**, not at start-up. | | `MIX_ENV` | | `prod` | `dev` or `prod`. Also selects the Docker build targets. | ### Database [#database] | Variable | Default | Description | | --- | --- | --- | | `DATABASE_URL` | | Optional Ecto URL; the variables below fill in anything it omits. | | `POSTGRES_HOST` | `postgres` | | | `POSTGRES_PORT` | `5432` | | | `POSTGRES_USER` | `aperture` | | | `POSTGRES_PASSWORD` | `password` | | | `POSTGRES_DB` | value of `POSTGRES_USER` | | | `POSTGRES_POOL` | `15` | Connection pool size. | ### Log storage (S3) [#log-storage-s3] All required. | Variable | Description | | --- | --- | | `S3_BUCKET` | Bucket for execution logs (default `aperture`). | | `S3_REGION` | Region. | | `S3_HOST`, `S3_PORT` | Endpoint host and port. HTTPS is always used. | | `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY` | Credentials. | Log links are pre-signed against `S3_HOST`, so it must be reachable from the browsers that open logs. ### Email [#email] Invitations are sent by email. | Variable | Description | | --- | --- | | `EMAIL_PROVIDER` | `resend`, `aws` (SES), or anything else to not send email (dev). | | `RESEND_API_KEY` | For `resend`. | | `AWS_SES_REGION`, `AWS_SES_ACCESS_KEY_ID`, `AWS_SES_SECRET_ACCESS_KEY` | For `aws`. | | `EMAIL_FROM_NAME`, `EMAIL_FROM_ADDRESS` | Sender. Set both. | In development, unsent emails can be viewed at `http://localhost:4000/dev/mailbox`. ### Stripe [#stripe] Required unless `BILLING_ENABLED=false`: `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, `STRIPE_PRODUCT_ID`, `STRIPE_PRICE_PRO`, `STRIPE_PRICE_PREMIUM_BASE`, `STRIPE_PRICE_PREMIUM_JOB_MINUTES`, `STRIPE_PRICE_PREMIUM_WEBHOOK_DELIVERIES`, `STRIPE_METER_JOB_EXECUTION_MINUTES`, `STRIPE_METER_WEBHOOK_DELIVERIES`, `STRIPE_SUCCESS_URL`, `STRIPE_CANCEL_URL`. Point Stripe's webhooks at `https:///api/v1/webhooks/stripe`. ### Clustering [#clustering] | Variable | Description | | --- | --- | | `DNS_CLUSTER_QUERY` | DNS name that resolves to the other server nodes, to cluster them. | ## Dashboard (build time) [#dashboard-build-time] Baked in when the dashboard is built. | Variable | Default | Description | | --- | --- | --- | | `VITE_API_URL` | `/api` | API base **including** `/api`, e.g. `https://api.example.com/api`. | | `VITE_API_VERSION` | `1` | API version number (not `v1`). | | `VITE_SOCKET_URL` | `/socket` in the Docker image | Websocket URL. The image's nginx proxies `/socket` to the API. | | `VITE_DOCS_URL` | `https://aperture-docs.mountaindev.com` | Target of the sidebar's **Documentation** link. | | `VITE_APP_NAME` | `Aperture` | Name in the page title. | The dashboard image also reads one variable at **run** time: | Variable | Default | Description | | --- | --- | --- | | `API_UPSTREAM` | `https://aperture-server.mountaindev.com` | Where nginx proxies `/api/` and `/socket`. | ## Docs site (build time) [#docs-site-build-time] | Variable | Default | Description | | --- | --- | --- | | `DOCS_URL` | `https://aperture-docs.mountaindev.com` | Public origin of the docs, used for canonical links and the URLs in `llms.txt`. Passed to the image as `VITE_DOCS_URL`. | ## Compose [#compose] | Variable | Default | Description | | --- | --- | --- | | `COMPOSE_PROFILES` | | Services to start: any of `postgres`, `web`, `runner`, `dashboard`, `docs`. | | `DOCKER_WEB_PORT_FORWARD` | `127.0.0.1:4000` | Host binding for the API. | | `DOCKER_DASHBOARD_PORT_FORWARD` | `127.0.0.1:3000` | Host binding for the dashboard. | | `DOCKER_DOCS_PORT_FORWARD` | `127.0.0.1:3001` | Host binding for the docs. | | `DOCKER_RESTART_POLICY` | `unless-stopped` | Restart policy. | | `DOCKER_WEB_CPUS`, `DOCKER_WEB_MEMORY`, `DOCKER_DASHBOARD_CPUS`, `DOCKER_DASHBOARD_MEMORY`, `DOCKER_POSTGRES_CPUS`, `DOCKER_POSTGRES_MEMORY` | `0` (no limit) | Container resource limits. | | `DOCKER_WEB_HEALTHCHECK_TEST`, `DOCKER_DASHBOARD_HEALTHCHECK_TEST`, `DOCKER_DOCS_HEALTHCHECK_TEST` | `curl …` | Health check commands. | | `MINIO_ROOT_USER`, `MINIO_ROOT_PASSWORD` | `minioadmin` | Local MinIO credentials. | | `UID`, `GID` | `1000` | User IDs for the server image. | # Self-hosting (https://aperture-docs.mountaindev.com/docs/self-hosting) Aperture ships as a set of Docker Compose services in the repository root. ## Services [#services] | Service | Compose profile | Port | What it is | | --- | --- | --- | --- | | `aperture-server` | `web` | 4000 | The Phoenix API server, job queue and scheduler. | | `runner` | `runner` | internal 5000 | Runs jobs in gVisor-sandboxed containers. Privileged (Docker-in-Docker). | | `aperture-dashboard` | `dashboard` | 3000 → 80 | The web dashboard (nginx in prod, Vite dev server in dev). | | `aperture-docs` | `docs` | 3001 → 80 | This documentation site (static, nginx). | | `postgres` | `postgres` | internal 5432 | Database. | | `minio`, `create-bucket` | always on | 9000, 9001 | S3-compatible storage for execution logs. Replace with real S3 in production. | `COMPOSE_PROFILES` in `.env` chooses which services start. The server and the runner share the `code-share` volume, where deployed job code lives. ## Requirements [#requirements] - Docker with Compose v2. - A Linux host that can run a **privileged** container with gVisor (`runsc`); the runner needs it to sandbox jobs. - Optionally, a Stripe account for paid plans. Set `BILLING_ENABLED=false` to run without Stripe: every team is then unlimited and free. - S3 or an S3-compatible store for logs. ## First start [#first-start] ```sh cp .env.example .env # Edit .env: see Configuration. At minimum set SECRET_KEY_BASE, GUARDIAN_SECRET_KEY, # ENCRYPTION_KEY, URL_HOST and the S3_* values, and either the STRIPE_* values or # BILLING_ENABLED=false. ./run up:detach # start the services in COMPOSE_PROFILES ./run setup # install deps, create and migrate the database, run seeds ``` The seeds create a sample team, project and users. Then: 1. Create your account: `./run mix aperture.admin `, or register in the dashboard (needs `REGISTRATIONS_ENABLED=true`). 2. Create a team; you become its owner. 3. With billing on, optionally make the team billing-exempt. 4. Point the CLI at your server with `APERTURE_API_URL=https://`. Set `REGISTRATIONS_ENABLED=false` afterwards if you don't want open sign-ups. ## Production [#production] - Build images with `MIX_ENV=prod docker compose build`. The server image is an Elixir release; the dashboard and docs are static sites behind nginx. - Run migrations with `./run prod:migrate` once the server container is up. - Put the API, dashboard and docs behind HTTPS. Outbound webhooks to non-HTTPS URLs are refused in production. - The dashboard's nginx proxies `/api/` and the `/socket` websocket to `API_UPSTREAM`, which defaults to the hosted server. Set it on the dashboard container to your API, for example `API_UPSTREAM=http://aperture-server:4000`. The upstream must resolve when nginx starts. - Set `DASHBOARD_URL` on the server to the dashboard's public URL; it's the only browser origin allowed on the websocket. - `VITE_*` values are baked into the dashboard and docs at **build** time. Next: [Configuration](/docs/self-hosting/configuration) and [Operations](/docs/self-hosting/operations). # Operations (https://aperture-docs.mountaindev.com/docs/self-hosting/operations) ## The `./run` script [#the-run-script] `./run` in the repository root wraps Docker Compose. Run `./run help` for the full list. The ones operators use most: | Command | Does | | --- | --- | | `./run up` / `./run up:detach` | Start the services (with file watching / in the background). | | `./run up:build` | Rebuild and start. | | `./run down` | Stop everything. | | `./run setup` | Install deps, create and migrate the database, run seeds. | | `./run migrate` | Run database migrations (dev image). | | `./run prod:migrate` | Run migrations in a production release container. | | `./run prod:remote` | Open a remote console on a production release. | | `./run iex` | Elixir console in the dev server container. | | `./run mix ` | Run a mix task in the server container. | | `./run psql` | Open `psql` against the database. | | `./run secret` | Generate a value for `SECRET_KEY_BASE`. | | `./run webhook:test ` | Send a signed test webhook. | | `./run cli:install` | Build and install `aperture-cli`. | Elixir tooling runs inside the server container; always call it through `./run` rather than `mix` on the host. ## Admin tasks [#admin-tasks] These mix tasks run in the dev image (`./run mix …`). In a production release, use `./run prod:remote` and call the equivalent function shown. ### Create a user [#create-a-user] ```sh ./run mix aperture.admin admin@example.com 'a-strong-password' ``` Works even when `REGISTRATIONS_ENABLED` is off, and prints validation errors (for example a duplicate email) instead of creating nothing. The user has no special privileges and belongs to no team; they create or join one from the dashboard. In a release: `Aperture.UserManager.insert_user(%{username: ..., password: ...})`. ### Billing-exempt teams [#billing-exempt-teams] With `BILLING_ENABLED=false`, every team is exempt and this isn't needed. With billing on, give a single team unlimited, free usage: ```sh ./run mix aperture.billing.exempt --reason "internal" ./run mix aperture.billing.exempt --revoke ``` In a release: `Aperture.Billing.Subscriptions.set_billing_exempt(team_id, "internal")` and `Aperture.Billing.Subscriptions.revoke_billing_exempt(team_id)`. ### Run a scheduled execution now [#run-a-scheduled-execution-now] ```sh ./run mix aperture.exec ``` Moves a `scheduled` execution's start time to now. ## Background processing [#background-processing] The server uses [Oban](https://hexdocs.pm/oban) on Postgres for background work: | Queue | Concurrency (per node) | Work | | --- | --- | --- | | `default` | 20 | Running jobs, unpacking deploys. | | `webhooks` | 50 | Webhook deliveries. | | `scheduler` | 1 | Scheduling. | Periodic tasks: - Every minute: keep each cron job's next run scheduled, mark late cron runs `missed`, and fail runs whose heartbeat stopped (`orphaned`). - Every hour: delete leftover deploy staging directories older than an hour. - Finished background job records are pruned after 7 days. Execution records are kept. ## Health and monitoring [#health-and-monitoring] - `GET /api/v1/health` returns `200 {"status": "ok"}`; Compose uses it as the server's health check. - The runner has its own health check binary. - Execution logs live in S3 under `logs///`. Aperture doesn't delete them; set a bucket lifecycle rule if you want retention. # Inbound triggers (https://aperture-docs.mountaindev.com/docs/triggers) An **inbound trigger** is an HTTP endpoint that starts a run of one job. Use it to react to events from other systems without giving them an Aperture account. There are two types: | Type | For | Token goes in | | --- | --- | --- | | `generic` | EventBridge API destinations, webhooks from other services, `curl`, other jobs | `X-Aperture-Trigger-Token` header | | `sns` | An Amazon SNS HTTPS subscription | `?token=` query parameter | Triggers are managed from the CLI or the [API](/docs/api/triggers); the dashboard doesn't have a triggers screen yet. Any team member can manage them. ## Create a trigger [#create-a-trigger] ```sh aperture-cli triggers create nightly-report name=on-demand ``` ```text URL: https://aperture-server.mountaindev.com/api/v1/triggers/3b0e… Header: X-Aperture-Trigger-Token: trg_… Store the token now: it is not shown again. ``` Names are 1 to 100 characters and unique per job. ## Fire a generic trigger [#fire-a-generic-trigger] ```sh curl -X POST "https://aperture-server.mountaindev.com/api/v1/triggers/" \ -H "X-Aperture-Trigger-Token: trg_…" \ -H "Content-Type: application/json" \ -d '{"reportId": 42}' ``` ```json { "execution_id": "9f1c…" } ``` - Any body and content type is accepted, up to **100 KiB**. The job receives the raw body in `APERTURE_TRIGGER_PAYLOAD`. - The response is `202` once the run is queued, not when it finishes. - From Node, use [`fireApertureTrigger`](/docs/sdk#firing-a-trigger). ### EventBridge [#eventbridge] Create an EventBridge **API destination** pointing at the trigger URL, with a connection that sends the `X-Aperture-Trigger-Token` header (API key authorization). EventBridge events are deduplicated: if the same event `id` arrives again within 10 minutes, no new run starts and the response includes `"duplicate": true`. ## SNS triggers [#sns-triggers] ```sh aperture-cli triggers create nightly-report name=budgets type=sns \ topic_arn=arn:aws:sns:us-east-1:123456789012:budget-alerts ``` The CLI prints a **subscription URL** that already includes the token. Create an HTTPS subscription on the topic with that URL. Aperture: - confirms the subscription automatically (no run starts), - verifies every message's SNS signature and that it comes from the configured topic, - starts a run for each `Notification`, with the SNS `Message` in `APERTURE_TRIGGER_PAYLOAD` and the subject, message ID and topic in `APERTURE_TRIGGER_SNS_*` variables, - ignores repeated deliveries of the same `MessageId` within 10 minutes. ## Rotate, disable and delete [#rotate-disable-and-delete] ```sh aperture-cli triggers rotate nightly-report # new token; the old one stops working aperture-cli triggers disable nightly-report # calls now return 404 aperture-cli triggers enable nightly-report aperture-cli triggers delete nightly-report ``` ## Responses [#responses] | Status | Body | Meaning | | --- | --- | --- | | `202` | `{"execution_id": "…"}` | Run queued. Adds `"duplicate": true` for a deduplicated event. | | `200` | `{"status": "subscription_confirmed"}` | SNS subscription confirmed. | | `400` | `{"error": "Not a valid SNS message."}` | SNS trigger received something that isn't an SNS message. | | `401` | `{"error": "Invalid trigger token."}` | Wrong or missing token, or an invalid SNS signature. | | `402` | `{"error": "quota_exceeded", …}` | The team is out of execution minutes. See [Billing](/docs/billing). | | `403` | `{"error": "Topic not allowed for this trigger."}` | SNS message from a different topic. | | `404` | `{"error": "Not Found"}` | Unknown or disabled trigger. | | `413` | `{"error": "Payload exceeds 102400 bytes."}` | Body over 100 KiB. | ## Reading the payload in your job [#reading-the-payload-in-your-job] ```ts import { requireApertureTrigger } from '@acruxdynamics/aperture'; const trigger = requireApertureTrigger(); const body = trigger.json<{ reportId: number }>(); ``` See [Writing jobs](/docs/writing-jobs#platform-variables) for the variables. # Outbound webhooks (https://aperture-docs.mountaindev.com/docs/webhooks) Outbound webhooks send an HTTP `POST` to your URL when something happens in a team. Each **endpoint** subscribes to a list of events and can be limited to some projects. Create endpoints in the dashboard (**Webhooks**), with the [CLI](/docs/cli#webhooks), or through the [API](/docs/api/webhooks). Any team member can manage them. The signing secret is shown once when it's generated. ## Events [#events] | Event | Sent when | | --- | --- | | `execution.scheduled` | A run is created (manual, cron, trigger or one-off schedule). | | `execution.running` | A run starts. | | `execution.succeeded` | A run finishes with exit code 0. | | `execution.failed` | A run fails, including `missing_secrets`, `quota_exceeded` and `orphaned` failures. | | `execution.cancelled` | A scheduled run is cancelled. | | `execution.missed` | A cron run couldn't start on time. | | `job.deployment_queued` | A deploy was accepted. | | `job.deployment_succeeded` | A deploy's files were unpacked and are live. | | `job.deployment_failed` | A deploy's files couldn't be unpacked. | | `project.created`, `project.updated`, `project.deleted` | Project changes. | | `secret.created`, `secret.updated`, `secret.deleted` | Secret changes. | | `team.updated` | The team's details changed. | | `invite.created`, `invite.accepted`, `invite.deleted` | Invitation changes. | | `cron.tick` | The endpoint's own cron schedule fired. See [Scheduled deliveries](#scheduled-deliveries). | `job.updated` and `job.deleted` exist in the event list but aren't sent yet. ### Project filter [#project-filter] An endpoint with no projects selected receives events from the whole team. An endpoint limited to some projects receives events from those projects only, and doesn't receive team-level events (`team.*`, `invite.*`, `cron.tick`). ## Request format [#request-format] ```http POST /your/endpoint HTTP/1.1 Content-Type: application/json User-Agent: Aperture-Webhooks Aperture-Signature: t=1763899200,v1=5b2c… ``` ```json { "id": "0b8c6a6e-5f0e-4c3a-9a63-2f7f1d3c9b11", "object": "event", "api_version": "2025-05-01", "created": 1763899200, "type": "execution.succeeded", "livemode": true, "data": { "object": { "job_id": "…", "job_name": "nightly-report", "job_project_id": "…", "execution_id": "…", "log_url": "https://…", "duration": 5234123 } } } ``` - `id` is the same for every endpoint that receives the event; use it to deduplicate. - `created` is a Unix timestamp in seconds. ### Payloads [#payloads] | Event | `data.object` fields | | --- | --- | | `execution.scheduled` | `team_id`, `job_id`, `project_id`, `name`, `execution_id`, `scheduled_time` | | `execution.running` | `job_id`, `job_name`, `job_project_id`, `execution_id` | | `execution.succeeded` | `job_id`, `job_name`, `job_project_id`, `execution_id`, `log_url`, `duration` (µs) | | `execution.failed` | as `succeeded`, plus `error` when there's an error code: `{"code": "missing_secrets", "secrets": [...]}`, `{"code": "quota_exceeded"}` or `{"code": "orphaned"}` | | `execution.cancelled` | `team_id`, `job_id`, `project_id`, `name`, `execution_id` | | `execution.missed` | `team_id`, `job_id`, `project_id`, `name`, `execution_id`, `scheduled_time`, `next_scheduled_time` | | `job.deployment_queued`, `job.deployment_succeeded` | `job_id`, `job_name`, `job_project_id` | | `job.deployment_failed` | as above, plus `error: {"code": "extract_failed" \| "filesystem_error"}` | | `project.*` | `team_id`, `project_id`, `name` | | `secret.created`, `secret.updated` | `team_id`, `project_id`, `secret_id`, `key` (never the value) | | `secret.deleted` | `team_id`, `project_id`, `secret_id` | | `team.updated` | `team_id` | | `invite.*` | `team_id`, `invite_id` | | `cron.tick` | `team_id`, `project_ids`, `webhook_endpoint_id`, `scheduled_at` | Field names differ between events (`name` vs `job_name`, `project_id` vs `job_project_id`), so read the table for each event you handle. ## Verifying signatures [#verifying-signatures] The `Aperture-Signature` header has a timestamp `t` and one or more `v1` signatures. Each `v1` is a hex HMAC-SHA256 of `"."`. The HMAC key is derived from your secret: for secrets that start with `whsec_` (all secrets the dashboard and CLI generate), it's the **base64-decoded bytes after `whsec_`**. Accept the request if any `v1` matches. In Node, use [`buildApertureWebhook`](/docs/sdk#verifying-webhooks). In other languages: ```python import base64, hashlib, hmac def verify(secret: str, header: str, raw_body: bytes) -> bool: parts = [p.split("=", 1) for p in header.split(",")] t = next(v for k, v in parts if k == "t") sigs = [v for k, v in parts if k == "v1"] key = base64.b64decode(secret[len("whsec_"):]) if secret.startswith("whsec_") else secret.encode() expected = hmac.new(key, f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return any(hmac.compare_digest(expected, s) for s in sigs) ``` Aperture doesn't enforce a time window. Reject old `t` values yourself if you need replay protection. ## Delivery and retries [#delivery-and-retries] - Respond with any `2xx` status to acknowledge. - `408`, `425`, `429`, `5xx` and network errors are retried, up to **8 attempts** over about 6 minutes. - Other `4xx` responses aren't retried. - On the hosted service, endpoint URLs must use `https://`. - Every attempt is recorded and shown with the endpoint in the dashboard (status and HTTP code). - Successful deliveries count toward the team's webhook quota. Over the quota, events are dropped. See [Billing](/docs/billing). ## Scheduled deliveries [#scheduled-deliveries] An endpoint subscribed to `cron.tick` with a `schedule` (cron, UTC) receives a `cron.tick` event on that schedule. Use it to drive your own periodic work. The endpoint must be enabled, and `schedule` and `cron.tick` must be set together. ## Testing an endpoint [#testing-an-endpoint] The repository includes a script that sends a correctly signed request: ```sh ./run webhook:test https://example.com/hooks whsec_… --event execution.succeeded --payload '{"job_name":"demo"}' ``` Add `--dry-run` to print the request without sending it. # Writing jobs (https://aperture-docs.mountaindev.com/docs/writing-jobs) ## How a run works [#how-a-run-works] 1. Aperture copies the job's deployed files into a fresh, empty working directory, `/work`. Files a run creates are discarded afterwards; nothing is shared between runs. 2. If the manifest has an `install` command, it runs in a container for the job's runtime with `sh -c ""`. 3. `cmd` runs in a new container on the same `/work`, so anything `install` produced (like `node_modules`) is there. 4. If both exit with code `0`, the execution is `success`; otherwise `fail`. Containers are sandboxed with [gVisor](https://gvisor.dev) and have network access. ## Runtimes [#runtimes] | `driver` | Image | Notes | | --- | --- | --- | | `node` | `node:alpine` | Latest Node.js on Alpine Linux. | | `python` | `python:slim` | Latest Python on Debian slim. | | `go` | `golang:alpine` | Latest Go on Alpine Linux. | Images aren't pinned, so the language version is whatever the latest image was when the runner started. You can't choose a version per job yet. Alpine images use musl and `sh` (no `bash`); native modules compiled on macOS or glibc won't load. ## Environment variables [#environment-variables] Jobs get all their input through **environment variables**: no arguments, stdin or files. A run's environment is built from, in order of precedence (later wins): 1. **Params** passed to the run (`aperture-cli run job NAME=value`, the API, or the dashboard). Values are strings. Cron runs have no params. 2. **Secrets** the manifest declares in `secrets`, decrypted from the project. A secret overrides a param with the same name. 3. **Platform variables**, prefixed with `APERTURE_`. They can't be set or overridden by params or secrets. ### Platform variables [#platform-variables] Set only on runs started by an [inbound trigger](/docs/triggers): | Variable | Value | | --- | --- | | `APERTURE_TRIGGER_ID` | The trigger's ID. | | `APERTURE_TRIGGER_SOURCE` | `generic` or `sns`. | | `APERTURE_TRIGGER_PAYLOAD` | The request body (generic) or the SNS `Message` (sns), up to 100 KiB. | | `APERTURE_TRIGGER_SNS_SUBJECT` | SNS only: the message subject, if any. | | `APERTURE_TRIGGER_SNS_MESSAGE_ID` | SNS only: the message ID. | | `APERTURE_TRIGGER_SNS_TOPIC_ARN` | SNS only: the topic ARN. | The execution ID, job name and project ID are **not** exposed to the job. ## Output and exit codes [#output-and-exit-codes] - Write logs to stdout and stderr. The output is stored when the run ends; see [Logs](/docs/concepts/executions#logs). - Exit `0` for success and non-zero for failure. Throwing an uncaught error in Node or Python exits non-zero. - Don't print secret values: logs are visible to everyone in the team. ## Limits [#limits] - **No timeout**: a run can go on indefinitely. Make sure your code exits. - **No CPU or memory limits** per job. - `install` runs on **every** run with no cache. To speed runs up, bundle your dependencies into the upload (for example with a bundler, or by including a Linux-built `node_modules`). See [Limitations](/docs/limitations) for what's planned. ## Examples [#examples] ### Node.js [#nodejs] ```json title="job.json" { "name": "hello-node", "driver": "node", "build": "npm run build", "install": "npm ci --omit=dev", "cmd": "node dist/index.js", "includes": ["dist", "package.json", "package-lock.json"], "secrets": ["API_TOKEN"], "params": ["TARGET"] } ``` ```ts title="src/index.ts" import { getApertureParam, getApertureSecret } from '@acruxdynamics/aperture'; const target = getApertureParam('TARGET', 'staging'); const token = getApertureSecret('API_TOKEN'); const res = await fetch(`https://api.example.com/${target}/sync`, { method: 'POST', headers: { authorization: `Bearer ${token}` }, }); if (!res.ok) throw new Error(`sync failed: ${res.status}`); console.log('sync done'); ``` The [Node SDK](/docs/sdk) is optional; reading `process.env` works too. ### Python [#python] ```json title="job.json" { "name": "hello-python", "driver": "python", "install": "pip install -r requirements.txt", "cmd": "python main.py", "includes": ["main.py", "requirements.txt"], "params": ["TARGET"] } ``` ```python title="main.py" import os import sys target = os.environ.get("TARGET", "staging") print(f"syncing {target}") if target not in ("staging", "production"): sys.exit(f"unknown target: {target}") ``` ### Go [#go] ```json title="job.json" { "name": "hello-go", "driver": "go", "cmd": "go run .", "includes": ["go.mod", "go.sum", "main.go"] } ``` ```go title="main.go" package main import ( "fmt" "os" ) func main() { name := os.Getenv("WHO") if name == "" { name = "world" } fmt.Printf("Hello, %s!\n", name) } ``` `go run` compiles on every run. To skip that, cross-compile on your machine in `build` (`GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o app .`, with `GOARCH` matching the runner host), include `app`, and set `cmd` to `./app`.