Skip to main content
The Forge REST API exposes the same organization-scoped capabilities used by Forge CLI and Forge MCP. The reference is generated from the public OpenAPI contract and documents the method, path, scopes, permission, risk tier, request schema, and response schema for every operation. The console calls the device-management surface Devices. The REST API retains /fleet paths and fleet.* capability identifiers; use those contract names exactly as documented in the generated reference.

Endpoint

All organization data routes include /organizations/{organizationId}. A credential cannot use that path parameter to cross organization boundaries.

Authentication

Send a Forge service-account token or delegated OAuth access token as an HTTP Bearer token:
The organization capabilities response is the authoritative way to determine what the current credential can call. Each capability includes its required scope, permission, risk tier, supported surfaces, stability, and authorization result. Use whoami first when wiring new automation. It confirms the token audience, principal type, organization access, role, and scopes without mutating data.
REST API and MCP access tokens have different audiences. Do not send an MCP OAuth token to the REST API.

Requests

JSON request bodies use Content-Type: application/json. Timestamps are RFC 3339 UTC unless an operation states otherwise. Unknown request properties are rejected where the operation schema sets additionalProperties: false.

Pagination

Pagination is defined per operation:
  • Cursor-based operations accept cursor and return the continuation cursor described by their response schema.
  • Offset-based searches accept offset and limit.
  • Bounded queries cap limit. Clients should stay within the documented maximum and must use the effective limit and continuation fields returned by the response. Some beta operations clamp an oversized value to their maximum instead of rejecting it.
Do not infer one pagination model for every endpoint. Use the parameters and response schema on the operation page.

Activity totals and Gateway usage

The activity aggregate endpoint returns server-computed totals for a selected time range and filters. The LLM Gateway usage endpoint returns bounded usage, token, cost, model, provider, and policy-outcome breakdowns for traffic observed by Forge LLM Gateway. Neither endpoint represents traffic that bypassed Forge. Use the generated reference for the available filters, dimensions, and limits. For example, use activity aggregates to calculate the total sessions and active identities for a reporting period, then request a bounded breakdown by product or risk. Use LLM Gateway usage to report tokens and cost for the same period with breakdowns by model, provider, or policy outcome. Continue from the returned pagination fields when a related search is needed to inspect the individual sessions or findings behind a total.

Long-running operations

Deployment, device-management, collection, and analysis operations can be accepted before their work is complete. An accepted response includes the resource or operation identifier used to read current status. Poll that status at a bounded interval until it reaches a terminal state, and present partial per-target results when the operation provides them. Do not interpret request acceptance as successful delivery or endpoint readback.

Guarded writes

Mutating operations declare their safeguards in the OpenAPI reference. Depending on the capability, the request can require: When both body and header forms are supported, keep their values consistent. Reuse an idempotency key when retrying the same logical operation. Use a new key only for a new intended change.

Policy Automation

Use Terraform for long-lived policy lifecycle management. It gives reviewable source, saved plans, drift detection, revision checks, and exclusive ownership. Use the REST API around Terraform for discovery, verification, reporting, and workflow automation.

Verify a Terraform-managed policy

After terraform apply, read the policy from Forge and check its authority, manager, revision, and definition:
The response includes the immutable current revision, complete definition, definition digest, management mode, and Terraform manager values. For a Terraform-owned policy, managementMode should be terraform. Resource Policy lifecycle requests use the same organization-scoped pattern:
Set the plan-validation family to resource. Resource definitions accept authenticated user, group, service-account, device, and Resource scope; enforce or monitor; Resource conditions or a package forge.resource module; exceptions; allow, flag_for_review, block, redact, filter, or require_approval; and an optional block or approval message. Redaction and filtering require dataTarget plus the shared redaction or filter object. Approval requires { "mode": "admin_approval" } or { "mode": "self_serve" }. Resource definitions do not accept Access enforcement surfaces or Content evaluation checkpoints. This separate route does not represent a separate policy engine. Resource Policies use the same condition operators and nesting, named exceptions, outcome handling, messages, revisions, Rego compilation, backtests, plan validation, and ownership contract as the other families. Protocol fields and actions are validated against selected Resource capabilities. Valid data targets are http_request_body, http_response_body, postgres_result, and mysql_result. HTTP request bodies support redaction; HTTP response bodies and PostgreSQL or MySQL results support redaction and filtering. Redis supports connection and command decisions but not result transformation. Native Resource conditions may use prior-event, sequence, count, and distinct-value forms. Their history is a bounded ordered set of safe facts from the same authenticated Resource connection. Clients must not treat these forms as cross-connection or organization-wide rate limiting. Resource approval uses the existing governance decision and grant APIs rather than a Resource-specific workflow service. The first operation returns a bounded policy error and approval reference without forwarding. Approval issues a ten-minute, one-use grant; only an exact retry with the same identity, Resource, operation, and policy revisions can consume it. Mutating approval requests require the normal idempotency and audit-reason headers. Resource Activity and backtest responses expose only safe metadata: target, paths or columns, applied or removed counts, intended and effective outcomes, and approval linkage when present. HTTP body values, PostgreSQL or MySQL row values, Redis arguments and replies, raw operation bytes, and private operation digests are never returned.

Inspect policy-as-code capability

Automation should check its authorized capabilities before attempting writes:
For Terraform policy management, the token must be authorized for policy read-as-code and manage-as-code capabilities. Missing authorization is a token, role, scope, or organization-policy issue; do not retry it as a transient failure.

Validate the policy contract

The Terraform provider negotiates the policy contract before it plans a write. This call is useful in CI preflight checks and support diagnostics:
The response identifies the policy schema version, Rego language version, Terraform policy protocol, Terraform gateway protocol, ownership binding, and compiler fingerprint supported by the target Forge environment.

Terraform plan validation API

The provider sends the desired policy definition to Forge for authoritative validation before apply. Forge returns a short-lived validation token bound to the exact definition, expected revision, service-account principal, manager, manager instance, reference bindings, schema, and compiler fingerprint.
Direct API clients normally do not need to call this endpoint themselves. Use the Terraform provider for create, update, import, drift repair, and destroy so the validation token, retries, readable references, and Terraform state stay consistent. For a Resource transformation, send the same validation request with family: "resource" and a Resource definition such as:
The returned validation token is required for the corresponding Terraform mutation and is bound to this exact definition.

Supported operational automations

Errors

Non-2xx JSON responses always include a human-readable message:
Some operations also return code and requestId in the body. Capture the X-Request-ID response header for every failed request; it is the reliable correlation value even when the body contains only message. Forge does not define one universal request quota across every capability. Treat operation-specific limits in the reference and any returned Retry-After header as authoritative. Store X-Request-ID (and a body requestId when present) with automation logs and support cases. Never log bearer tokens, one-time service-account secrets, or upstream provider credentials.

Runnable approval and audit workflow

The repository includes a curl and jq example that exercises a complete, auditable automation lifecycle:
  1. Verify the credential’s runtime capabilities.
  2. Read two bounded policy-search pages.
  3. Create an MCP approval request with required safety fields.
  4. Retry the create with the same idempotency key and verify the same approval is returned.
  5. Read and deny the disposable request.
  6. Find the corresponding create and deny events in the audit log.
The example never prints the token and uses a unique run ID by default. Its proposed MCP server uses the reserved .invalid domain and the scanner is not started, so no upstream connection is attempted. The terminal approval is retained as an audit record; there is intentionally no delete operation.

Policy automation boundary

Use the documented headless policy-family routes for policy lifecycle automation and the Forge Terraform provider for reviewable desired state, saved plans, drift detection, and exclusive ownership. Use the Console for interactive authoring. Do not build a REST client around undocumented /api/v1 Console routes.

Compatibility

The route prefix carries the API major version. Additive response fields may be introduced without changing that version, so clients should ignore unknown response properties. Operation-level x-forge-stability identifies beta and stable contracts; capability discovery exposes the same stability metadata at runtime. The generated endpoint reference below is the source of truth for operation schemas and authorization requirements.

CLI

Use the same contracts from shell scripts and CI.

Roles

Map roles, permissions, and service-account scopes.