Optimly Developer Documentation

Agent API

Optimly Agent API

In short

Connect a custom agent harness to Optimly's versioned, brand-scoped API.

The Optimly Agent API is the versioned interface for custom agent harnesses. It exposes the same brand-scoped evidence and governed actions as Optimly MCP without requiring an MCP client.

Base URL

https://app.optimly.ai/api/v1/agent

The API is available only to eligible paid accounts. Keys are scoped to one organization and brand; free accounts cannot generate or use Agent API or MCP credentials.

Authenticate

Send the selected brand's osk_ key in the X-API-Key header:

X-API-Key: osk_your_brand_scoped_key

Store the key in an encrypted secret manager or managed egress gateway. Never print, inspect, log, or place it in browser code. A worker that serves multiple clients must resolve the credential from the active client context, not from a shared core-worker slot.

Discover capabilities first

Every run begins with capability discovery:

curl https://app.optimly.ai/api/v1/agent/capabilities \
  -H "X-API-Key: $OPTIMLY_API_KEY"

Confirm the returned organization and brand before continuing. Treat the returned capability, method, and endpoint records as the contract for that credential. Do not hard-code an operation that is not advertised and do not switch to another client's credential after a denial.

Capabilities can include:

CapabilityPurpose
brand.readRead the authorized Business Profile and verified brand facts
reports.readRead available reports and measured evidence
evidence.readRead citations and supporting evidence
website.readRead authorized website context and activity
work.manageRead or maintain recommendations, drafts, feedback, and checklist work
actions.readRead action, approval, and execution state
actions.proposeCreate an immutable proposed action
approvals.requestRequest approval for an exact action payload
approvals.decideRecord an authorized approver's explicit decision
brand.correctExecute an approved Business Profile correction
brand.publishExecute an approved BrandVault publish
coverage.manageMaintain supported off-site coverage work

The actual /capabilities response is authoritative. Availability varies by plan, permissions, and brand configuration.

Read safely

Choose an advertised operation with no side effect and call the returned method and path. Reads remain constrained to the organization and brand resolved from the credential. Never accept a caller-supplied tenant identifier as a way to escape that scope.

Handle failures

StatusMeaningRequired behavior
401Missing, invalid, expired, or revoked keyStop and repair the selected client's credential
403Plan, permission, approval, or mutation envelope is insufficientDo not bypass governance or retry as another client
409Action state or idempotency conflictRead the existing action and reconcile before retrying
429Request limit reachedHonor retry guidance and back off

Do not fall back to MCP when an Agent API capability is absent. Failing clearly preserves the credential, capability, and governance boundaries the caller expects.

Execute mutations through governance

A correction, publish, website update, or off-site action requires an immutable proposal, explicit approval, a complete mutation envelope, and a stable idempotency key. Authentication by itself never authorizes a mutation.

Follow the governed Agent Actions workflow