# Prepare a workspace for API runs

A checklist for your workspace admin: store the model key, activate an agent and create an API key, so a developer can run it over the API.

The [Quickstart](https://centerofagentic.com/docs/quickstart#before-you-start) assumes a model key, an activated agent and an API key. A person signed in to the web workspace sets up all three; an API key cannot. Hand this checklist to your workspace admin. It ends with a check you run yourself.

## 1. Who can do this

A **workspace admin** stores the model key, approves and activates agents, creates API keys, sets budgets and pauses or revokes agents. Other members can build an agent and submit it for review, unless their access profile is **Business Owner**. Roles are managed in the **Team** card and access profiles in the **App access profiles** card, both under **Settings → Team & access**.

## 2. Add the model key

Runs call models through the workspace's own OpenRouter account. Without a stored key a run returns `400 no_model_key`.

- Open **Settings → Models**. In the **Bring your own model** card, paste the key into **OpenRouter API key** and select **Save key**. The key is checked with OpenRouter first, and a rejected key is not stored.

- The card now shows **Key set**. **Test** validates the stored key with OpenRouter again, without calling a model.

- Optionally choose a **Default model**, used for any agent that does not name its own.

The key is not shown again

The key is stored encrypted and is never returned: the web workspace and the API report only whether a key is set and its last four characters. To replace it, select **Remove** and save the new key.

## 3. Get an agent to an active version

A new agent runs only from a version that a workspace admin has reviewed and activated. In **Agent Catalog**, select **New agent**, or **Edit** on an existing agent. The builder has six steps: **Define**, **Knowledge**, **Runtime**, **Skills**, **Review & Test** and **Govern & Publish**.

- **Configure.** In **Define**, describe the outcome and set the **Model**, then complete the other steps.

- **Submit.** On **Review & Test**, select **Submit for review**.

- **Approve.** On **Govern & Publish**, a workspace admin leaves **Approve** selected under **Reviewer decision** and selects **Approve agent**. The agent cannot run yet.

- **Capture.** The **Active version and draft** card now appears on the same step. Select **Prepare current draft for review**. This captures the draft's behavior, permissions, connections and model as a candidate.

- **Review.** Check the candidate under **Review this exact candidate**. **Models** must name a model: the capture takes the agent's own, or the workspace default when the agent names none. If it reads `None`, set one and prepare the draft again. The **Connections** line ends with the number of write grants, and a first capture has none. If the agent must create or change records in a connected system, open **Propose connection write access**, tick the connection, which is listed by its id, and select **Prepare current draft for review** again. Without a write grant the version can only read from its connections: a write is refused, never held for approval.

- **Activate.** Under **Finite retention policy**, a workspace admin fills in **Inactive payload retention (days, 1–365)** and **Purpose for retaining these records**, then selects **Activate reviewed version**.

Approval and activation each run the required containment checks; a failed check refuses the change. If the draft, or a workspace setting such as the default model, changes after **Capture**, activation is refused: prepare the draft again.

Later edits to the draft do not change the active version: repeat **Capture**, **Review** and **Activate** to put them into effect. A new version keeps the earlier limits on authority, data classes, local access and connections unless **Prepare a replacement restriction ceiling from this draft** is ticked before the draft is prepared again.

### What the API reports

`GET /api/agents` shows where each agent stands. Of these stages, only the last can run.

| Stage | `status` | `grantLifecycle` | `activeGrant.state` |
| --- | --- | --- | --- |
| Draft | `draft` | `managed` | `not_active` |
| Submitted for review | `in_review` | `managed` | `not_active` |
| Approved | `approved` | `managed` | `not_active` |
| Activated | `published` | `managed` | `available` |

## 4. Adopt agents created before activation

An agent created before managed activation reports `grantLifecycle` as `legacy_unadopted` and has no `activeGrant` field. **Agent Catalog** marks it **Legacy · adoption needed**. Until it is adopted it runs with a plain `POST /api/run`, without a launch ticket.

To adopt it, a workspace admin opens its **Govern & Publish** step and does **Capture**, **Review** and **Activate** as in [section 3](https://centerofagentic.com/docs/guides/prepare-an-agent#activate-an-agent); a legacy draft goes through **Submit** and **Approve** first. Before activating, the admin also ticks the confirmation that legacy traffic has stopped and its in-flight runs and approvals are reconciled. Adoption is refused while background runs of the agent are in progress or held for approval, or earlier operations of it are unresolved.

Adoption changes how the agent is called

An adopted agent reports `managed`, and every run then needs a launch ticket and the `X-CoA-Agent-Protocol` header; a plain `POST /api/run` gets `426 agent_protocol_required`. Before adoption, a request with that header gets `409 agent_adoption_required`. So stop the old client, adopt, then start the updated one; see [Run an agent](https://centerofagentic.com/docs/guides/run-an-agent#choose-agent-and-key).

An admin can also require activated agents for the whole workspace: in the **Active version and draft** card, open **Workspace adoption and final enforcement** and select **Review workspace inventory**. Once no legacy agents, ongoing legacy runs or unresolved legacy outcomes remain, tick the confirmation and select **Enforce managed-only execution**. `GET /api/tenant/config` then reports the key `agentGrants.enforceManaged` as `true`. The web workspace cannot switch this off again.

## 5. Create the API key and hand it over

- Open **Settings → API access**. In the **API keys** card, enter a **Name** that says where the key will run.

- Under **Scopes**, tick `run`. It includes `read`, which is all the Quickstart needs. Leave `admin` unticked.

- Select **Create key**, then **Copy**. The key starts with `ak_` and is shown only once. Select **Done** when it is stored.

- Create one key for each developer or service, and pass it on through a secret manager or a CI secret store, not by email or chat.

- A key depends on the admin who created it and stops working when that person leaves the workspace.

- The admin who creates a key cannot approve the tool calls that jobs started with that key hold for review. If the key will run [background jobs](https://centerofagentic.com/docs/guides/run-examples#held-for-approval) that need approval, a second workspace admin has to create the key or do the approving.

- If a key may have leaked, select **Revoke** in the same card. Revocation applies from the next request and cannot be undone.

The developer exports the key. [Authentication](https://centerofagentic.com/docs/authentication#good-practice) covers key handling in full.

```bash
export COA_API_KEY="ak_..."
```

## 6. Optional: set a spend budget

Under **Settings → Budgets**, the **Monthly spend budget** card takes a **Monthly cap (USD)** for the workspace and optional **Per-authority-tier caps (USD/month)**; select **Save**. A cap can be saved only while receipt retention is unset or at least 32 days. With no cap, nothing is enforced.

A run that would take this month's recorded spend past a cap is refused before the model is called: HTTP `200`, `decision` is `deny`, `reasonCode` is `SPEND_OVER_BUDGET`, and a receipt records the refusal. The check uses recorded spend and an estimate, so it is not a hard ceiling. See [Budgets and spend refusals](https://centerofagentic.com/docs/guides/run-an-agent#budgets).

## 7. Pause or revoke an agent

These controls are on the agent's **Govern & Publish** step and need a workspace admin.

| Control | Effect | `GET /api/agents` reports |
| --- | --- | --- |
| **Pause new execution** | Stops runs until an admin selects **Make available**. | `activeGrant.state` is `paused`. |
| **Revoke active grants** | Withdraws the active version. Running again takes a new capture, review and activation. | `activeGrant.state` is `revoked`; `status` stays `published`. |
| **Revoke package**, under **Package actions** | Does the same and also marks the agent as revoked. | `status` and `activeGrant.state` are both `revoked`. |

API callers see the same in all three cases: a launch ticket request is refused with `409 agent_admission_unavailable`, a ticket issued earlier no longer starts a run, and a background job in progress does not continue past its next call. A revoked legacy agent, which uses no ticket, returns HTTP `200`: `decision` is `deny`, `reasonCode` is `PKG_REVOKED`.

## Verify from the developer's side

These calls confirm the checklist. They only read, need `curl` and `jq`, and work with the `read` scope.

```bash
# 1. The key works and belongs to the expected workspace.
curl -sS https://centerofagentic.com/api/me \
  -H "Authorization: Bearer $COA_API_KEY" \
  | jq 'if .error then . else {userId, workspace: .tenant.slug} end'

# 2. A model key is stored.
curl -sS https://centerofagentic.com/api/tenant/settings \
  -H "Authorization: Bearer $COA_API_KEY" \
  | jq 'if .error then . else {hasOpenRouterKey, defaultModel} end'

# 3. Agents that can run now.
curl -sS https://centerofagentic.com/api/agents \
  -H "Authorization: Bearer $COA_API_KEY" \
  | jq 'if .error then . else [.agents[] | select(.activeGrant.state == "available")
         | {id, name, status, grantLifecycle}] end'

# 4. The active version of one of them. Use an id from call 3.
AGENT_ID="3f1c2a9e-0b7d-4e55-9a51-6f2f1c0e8d11"
curl -sS "https://centerofagentic.com/api/agents/$AGENT_ID/grants" \
  -H "Authorization: Bearer $COA_API_KEY" \
  | jq 'if .error then . else {lifecycle, paused, revoked,
         models: .active.capture.behavior.modelPolicy.allowedModelIds} end'
```

| Call | Ready when |
| --- | --- |
| 1 | `userId` starts with `api-key:` and `workspace` is yours, for example `example-workspace`. |
| 2 | `hasOpenRouterKey` is `true`. |
| 3 | The list is not empty. |
| 4 | `paused` and `revoked` are `false`, and `models` names a model id. |

If a call prints an object with `error`, the call itself failed: see [Troubleshooting](https://centerofagentic.com/docs/guides/troubleshooting#authenticating). If a check fails, point your admin to the matching section. Otherwise continue with the [Quickstart](https://centerofagentic.com/docs/quickstart#list-agents).

## Next steps

- [**Quickstart** Run the activated agent and read its receipt.](https://centerofagentic.com/docs/quickstart)

- [**Run an agent** Requests, launch tickets, outcomes and budgets in detail.](https://centerofagentic.com/docs/guides/run-an-agent)

- [**Troubleshooting** Start from the status and error code you see.](https://centerofagentic.com/docs/guides/troubleshooting)

Source: https://centerofagentic.com/docs/guides/prepare-an-agent

## Related pages

- [Quickstart](https://centerofagentic.com/docs/quickstart#before-you-start)
- [section 3](https://centerofagentic.com/docs/guides/prepare-an-agent#activate-an-agent)
- [Run an agent](https://centerofagentic.com/docs/guides/run-an-agent#choose-agent-and-key)
- [background jobs](https://centerofagentic.com/docs/guides/run-examples#held-for-approval)
- [Authentication](https://centerofagentic.com/docs/authentication#good-practice)
- [Budgets and spend refusals](https://centerofagentic.com/docs/guides/run-an-agent#budgets)
- [Troubleshooting](https://centerofagentic.com/docs/guides/troubleshooting#authenticating)
- [Quickstart](https://centerofagentic.com/docs/quickstart#list-agents)
- [Quickstart Run the activated agent and read its receipt.](https://centerofagentic.com/docs/quickstart)
- [Run an agent Requests, launch tickets, outcomes and budgets in detail.](https://centerofagentic.com/docs/guides/run-an-agent)
- [Troubleshooting Start from the status and error code you see.](https://centerofagentic.com/docs/guides/troubleshooting)
