---
name: manage-decoy-access
description: Handle denied, expired or revoked Decoy access and help the user revoke an agent connection.
---

# Handle Decoy access errors

Follow the [whole-journey conversation contract](https://www.decoys.me/agent-experience.md). Handle eligible refresh and safe retries quietly. When owner action is necessary, explain the task impact and one next step; do not recite error codes or restart onboarding. Additional access needs a short explanation of the new action and resource, including any bundled sensitive actions, followed by the documented approval. Respect denial and continue independent allowed work.

Use the structured error returned by the current API or MCP bridge. Older deployments may return only `Unauthorized`: check missing or invalid client credentials first and do not infer revocation or automatically re-pair. Consult the [error reference](https://www.decoys.me/documentation.md) and the [OpenAPI schema](https://www.decoys.me/openapi.json) instead of treating every failure as a reconnect request.

- Any refusal for access you did not expect (`403 INSUFFICIENT_GRANT`, `GRANT_EXPIRED` or `SCOPE_MISSING`): read `access` on GET `/api/agent/policies` (`my_permissions` with the MCP bridge) before anything else. It states what the connection can do now; `scopes` does not list memory access, and what you saved at pairing may be out of date. If `access` says no, do not retry the call: ask on the connection ([how to read it](https://www.decoys.me/docs/access.md#what-you-can-do-now)).
- `TOKEN_MISSING` or `TOKEN_INVALID` / `repair_credentials`: repair the client credential configuration; do not automatically re-pair.
- `TOKEN_EXPIRED` or `TOKEN_REPLACED` with `recovery: "refresh"`: use the latest securely stored refresh token as documented in [connection recovery](https://www.decoys.me/agent-recipes.md#7-reuse-the-connection), serialize refreshes, replace both returned tokens securely, and compare the returned `access_version` with the one in your notes; if it differs, read `access` again. Resume the authorized task without a new approval. Follow the returned recovery rather than guessing from the status code alone.
- `TOKEN_REVOKED` / `re_pair`: stop protected calls. Revoked access cannot be restored through refresh or reconnect. Start a new pairing only when the owner wants to connect again; never silently generate a link.
- If the actual response requires owner approval instead of refresh, explain that action once and follow the supported recovery. An approved reconnect to an active connection can preserve its active grants and creation provenance; a brand-new pairing cannot. Start one by requesting approval again with the connection's original `client_id` and the same access as its first pairing; a reconnect keeps the connection's current access, so ask for more on the connection afterwards. Missing keys and expired grants are not fixed by refreshing a token; a lost key is replaced through that reconnect, after which earlier content answers `preparing` while Decoy asks the owner's phone to share it to the new key, for up to 7 days, then `failed` with `recovery: "stopped_asking"`. The MCP bridge never makes a new key: it reconnects with the one it has (`npx decoy-mcp-server --reconnect`), and a lost key file means a new connection ([what to keep and how to recover](https://www.decoys.me/agent-recipes.md#keep-your-connection-across-sessions)).
- `INSUFFICIENT_GRANT`, `GRANT_EXPIRED` or `SCOPE_MISSING` (every refusal you can ask about carries `permission_request`): keep the existing token, send `permission_request` unchanged to `POST /api/agent/grant-request` (`request_access` with the MCP bridge), tell the owner once to approve it in the Decoy app, poll `GET /api/agent/grant-request?id=<request_id>`, then retry. Ignore `remediation`. Do not ask for `everything` as a shortcut, and do not silently re-pair.
- `can_request: false` (`ALERTS_OWNER_ONLY`, `PASSKEYS_OWNER_ONLY`, `ACCOUNT_EMAIL_GOES_WITH_ACCOUNT`): nothing can be asked; tell the owner what `message` says.
- Access that ends soon: in the last 7 days before it ends, send the same permissions again, on the selection `policies` shows for that grant (its `account_id`, also after a `domain` ask). It answers `pending` with `renewal: true` and `ends_at`, and the owner is asked to keep it; a repeat answers the same body with `200`, so wait on it. Earlier, the same ask answers `already_granted` and reaches no one. After it ends, `GRANT_EXPIRED` carries the `permission_request` to send.
- Pending approval: respect the server's polling interval. On denial or expiration, stop polling. After a denial, say so briefly and start another request only when the owner asks. After an expired pairing link, send a fresh one without comment when the owner still wants the task. Do not repeatedly ask for access. A declined additional-access request does not itself revoke existing grants.
- Rate limiting: respect `Retry-After` when present and use bounded retries.
- Transient failure: retry read-only calls cautiously. Do not blindly retry sends, deletions or writes whose completion is uncertain.

To revoke a connection, direct the user to the existing Connected Agents controls in Decoy, or use the advertised OAuth revocation endpoint when the integrating client owns the token and the user requests revocation. Never revoke a real user's connection as a smoke test.

Revocation prevents future access. It cannot erase a password already received by an agent or undo an action already performed on another website.
