> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptguard.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Approvals

> How an agent's risky change waits for your approval, and how an agent asks

# Approvals

An agent can do with the API what its key can do. A change to what protects a project does not run on the agent's word alone: the API refuses it, you approve that exact request in the dashboard, and the agent sends it again. It runs once.

## Which credentials wait

* A **CLI sign-in**, the credential `promptguard login` holds. A coding agent in your terminal can use it, so it is always treated as an agent's.
* An **API key marked for an agent**: tick **For an agent: risky changes wait for your approval** when you create it, or send `"for_agent": true` to [create it over the API](https://docs.promptguard.co/api-reference/api-keys.md#create-api-key). Every key it creates is marked too, and so is its replacement when you rotate it.

Any other key behaves as before, so a deployment pipeline does not stop for a person.

An agent's credential cannot delete or switch another API key, whatever its scopes: it is refused with [`agent_key_change_refused`](https://docs.promptguard.co/production/error-handling). It may end itself.

## Which changes wait

| Request | Waits when it |
| - | - |
| `PUT /projects/{project_id}/guardrails` | Switches a guardrail off, lowers a level, raises a threshold, or makes any other change that looks for or blocks less than what is in force |
| `POST /overlays/apply` | Weakens protection, with `acknowledge_loosening: true` |
| `DELETE /projects/{project_id}` | Always |
| The [configuration](https://docs.promptguard.co/api-reference/configuration.md#the-key-it-needs) endpoints | Creates, changes or deletes a policy, changes a setting, creates a suppression, sets or removes the webhook, or dismisses an alert before its email is sent |

A request that changes nothing runs at once, and so does a guardrail or overlay change that tightens protection. One the API cannot place, such as another way of masking personal data, waits.

## Ask, approve, retry

**1. The agent asks.** The request is refused, and nothing has changed:

```json theme={"system"}
{
  "error": {
    "code": "approval_required",
    "type": "approval_required",
    "message": "This change waits for your user's approval. Ask them to open approval_url, then send the same request again with the header PromptGuard-Approval: 0f8c2c1e-6f0b-4a6e-9b1d-3a1f7c9d2e54",
    "doc_url": "https://docs.promptguard.co/production/error-handling#approval_required",
    "approval_id": "0f8c2c1e-6f0b-4a6e-9b1d-3a1f7c9d2e54",
    "approval_url": "https://app.promptguard.co/approvals/0f8c2c1e-6f0b-4a6e-9b1d-3a1f7c9d2e54",
    "expires_at": "2026-11-30T12:30:00+00:00"
  }
}
```

**2. You decide.** Open `approval_url`, signed in as yourself. The page shows the change in full, who asked, and the organization and project. A change too large to show is refused with [`approval_change_too_large`](https://docs.promptguard.co/production/error-handling). Characters that cannot be seen, and spaces a page would collapse, are spelled out, and text that is not ASCII is followed by its escapes. Only the person the key belongs to can decide, in their own dashboard session, with the role the same change takes there and whatever two-step verification the organization requires. You have 30 minutes.

**3. The agent sends the same request again**, with the same method, path, query and body, within ten minutes of your approval:

```bash theme={"system"}
curl -X PUT "https://api.promptguard.co/api/v1/projects/$PROJECT_ID/guardrails" \
  -H "X-API-Key: $PROMPTGUARD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "PromptGuard-Approval: 0f8c2c1e-6f0b-4a6e-9b1d-3a1f7c9d2e54" \
  -d @guardrails.json
```

Everything is checked again: scopes, role and plan. An approval is used up by the request it allows, whether or not that request succeeds. A retry that changed, or an approval that was declined, cancelled, used or has expired, is refused with [`approval_invalid`](https://docs.promptguard.co/production/error-handling). So is a retry when anything it would change is not as it was when the agent asked: an approval never undoes what you changed since. Asking for the same change while it waits gives the same approval, and you can have ten waiting at once in an organization. An approval can be read for seven days.

Asking, deciding and running are each recorded in the [audit log](https://docs.promptguard.co/platform/audit-logs.md).

## Endpoints

Both answer the API key that asked, whatever its scopes. To any other key, the approval does not exist (`404 approval_not_found`).

### Get an approval

```http theme={"system"}
GET /api/v1/approvals/{approval_id}
```

**Response (200 OK)**

```json theme={"system"}
{
  "id": "0f8c2c1e-6f0b-4a6e-9b1d-3a1f7c9d2e54",
  "status": "pending",
  "change": {
    "title": "Loosen a project's guardrails",
    "details": ["Project \"support-chatbot\" (a name an agent may have written)", "Prompt Injection: turned off"]
  },
  "approval_url": "https://app.promptguard.co/approvals/0f8c2c1e-6f0b-4a6e-9b1d-3a1f7c9d2e54",
  "expires_at": "2026-11-30T12:30:00Z"
}
```

`status` is `pending`, `approved`, `declined`, `cancelled`, `used` or `expired`. While it is `pending`, wait the seconds in the `Retry-After` header before asking again. `expires_at` is when your time to decide runs out, and once approved, when the agent's time to use it does.

### Cancel an approval

```http theme={"system"}
POST /api/v1/approvals/{approval_id}/cancel
```

Withdraws one that is still waiting, and answers with it. Any other is refused with `409 approval_not_pending`.

## Without a dashboard

A self-hosted data plane has no dashboard to approve in, so it refuses such a change with [`approval_unavailable`](https://docs.promptguard.co/production/error-handling). Make it in the dashboard that manages the data plane.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.