# request_access

Source: https://botpassword.com/docs/intents/request_access

Built. request_access asks the person for a grant on one credential, with the intents, scope, lifetime and a one-line reason.

**Status: Built.** Built for `run_with`, `http_request` and `rotate` grants, approved in the desktop app's Ledger or with `bpw access approve`. Approval on your phone is planned, not built yet, and so is asking for a `cli_login`, `sign_in` or `fill_totp` grant this way (you add those with `bpw grant add`).

## At a glance

| Property | Value |
|---|---|
| MCP tool | `request_access` ("Request access") |
| CLI | `bpw agent request_access` |
| Default friction | One approval by the person, with their master password, in BotPassword on the desktop or with `bpw access approve`. Nothing changes until they decide. |
| Delivery | No value is involved. The grant it asks for is sealed unless `disclose` is true: a sealed `run_with` ask must name `hosts`, and the command gets a placeholder. |
| MCP hints | `readOnlyHint`: false, `destructiveHint`: false, `idempotentHint`: false, `openWorldHint`: false |

## Parameters

*Status: `rotate` is partly built.*

No parameter is required by the schema. Unknown arguments are refused. The descriptions are the tool's own, as `bpw mcp` serves them.

| Name | Type | Required? | Description |
|---|---|---|---|
| `credential` | string | optional | A credential reference (item ID), as list_credentials returns it. Not a secret value. Not empty. |
| `looking_for` | string | optional | In place of credential, when you do not know the item's reference: one line saying what you need, such as the site or host and what it is for ("the API key for api.example.com, to deploy"). The person reads it, chooses the item in BotPassword or declines. It is not a search: the reply is the same whether or not anything matches, and names the item only once approved. 1 to 200 bytes. |
| `environment` | string | optional | Environment reference as ORG:ENV or ORG/ENV (ADR 0063 section 7). In run_with, replaces env, files and sealed; in request_access, replaces credential and looking_for. 1 to 121 bytes. |
| `only` | array of string | optional | With environment: restrict to these variable names. Under a sealed environment grant, pass only sealable variable names to omit unsealable ones. 1 to 256 items, each once. |
| `intents` | array of string | optional | The intents to ask for on the credential: run_with and/or http_request, or rotate alone. One of `run_with`, `http_request`, `rotate` (partly built). |
| `reason` | string | optional | Why you need it, in one line. The person sees it labelled as your unverified words. 1 to 500 bytes. |
| `ttl_seconds` | integer | optional | How long the grant should last (default 3600). The person may shorten it. 60 to 604800. |
| `disclose` | boolean | optional | run_with: let the command read the value. Without it a run_with ask is sealed and must name hosts. |
| `hosts` | array of string | optional | http_request, sealed run_with: hosts (host or host:port, exact, each once) the value may be sent to. On run_with, the command gets a placeholder and a proxy for the run swaps in the value only on requests to these hosts. 1 to 16 items. |
| `paths` | array of string | optional | http_request, sealed run_with: paths, /exact or /prefix/* (default /*). 1 to 16 items. |
| `methods` | array of string | optional | http_request, sealed run_with: methods (default GET). 1 to 16 items. |
| `header` | string | optional | http_request, sealed run_with: the header the value goes in (default authorization). request_access takes only headers that carry an API credential: authorization, x-api-key, api-key, apikey, x-auth-token, x-goog-api-key, private-token. 1 to 64 bytes. |
| `prefix` | string | optional | http_request, sealed run_with: text before the value in that header (default "Bearer "). 0 to 64 bytes. |
| `commands` | array of string | optional | run_with: executables it may start with any arguments, by absolute path or name. 0 to 16 items. |
| `argv` | array of string | optional | run_with: argv rules, the program then exact arguments, optionally ending in *, for example "npm publish --access public". 0 to 16 items. |
| `max_uses` | integer | optional | Optional lifetime use-count limit for the requested grant. The person may tighten it. 1 to 100000. |
| `rate` | string | optional | Optional rate limit for the requested grant, as N/WINDOW (for example "5/60s", "10/1m", "100/1h"). The person may tighten it. 3 to 32 bytes. |
| `request` | string | optional | Check a request made earlier: its request ID. Give nothing else but wait_seconds. 1 to 64 bytes. |
| `wait_seconds` | integer | optional | With request: wait up to this long for the person's decision. 1 to 30. |

*Status: `rotate` is partly built.*

## Example

A `tools/call` request, with placeholder references (use the `id` that `list_credentials` returns):

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "request_access",
    "arguments": {
      "credential": "ITEM-EXAMPLE-01",
      "intents": [
        "http_request"
      ],
      "hosts": [
        "api.example.com"
      ],
      "paths": [
        "/v1/*"
      ],
      "methods": [
        "GET"
      ],
      "reason": "Read the deploy status for this project",
      "ttl_seconds": 3600
    }
  }
}
```

The result. The same JSON is also sent as text in `content[0].text`; `isError` is false for `approval_required`.

```json
{
  "structuredContent": {
    "outcome": "approval_required",
    "detail": "REQ-EXAMPLE-01",
    "request": "REQ-EXAMPLE-01",
    "state": "pending",
    "credential": "ITEM-EXAMPLE-01",
    "intents": [
      "http_request"
    ],
    "ttl_seconds": 3600,
    "disclose": false,
    "decide_by": 1767225600
  },
  "isError": false
}
```

Then check with `{ "request": "REQ-EXAMPLE-01", "wait_seconds": 30 }`. Once approved the receipt says `state: approved` and carries `grant` with its `id`, `expires_at`, `project_root` and `hosts`.

## From the command line

```sh
bpw agent request_access --credential ITEM-EXAMPLE-01 --intent http_request --host api.example.com --path '/v1/*' --reason 'Read the deploy status for this project'
```

`bpw agent <intent>` sends the same request as the MCP tool, through the same policy. Every intent except `status` needs a live agent session, or the answer is `session_required`. Run the harness with `bpw agent run -- <harness>`. On macOS and Linux, an enrolled harness started normally can also be approved in the desktop app or with `bpw session approve`.

## Result fields

Every result is one JSON object. Only `outcome` is always present.

| Field | Type | Meaning |
|---|---|---|
| `outcome` | string | The [typed outcome](/docs/outcomes) code. Always present. |
| `detail` | string | The request ID, rotation step, revision or reason, for the outcomes that carry one. |
| `intent` | string | With `not_implemented`: the intent this build cannot carry out. |
| `reason` | string | With `rejected`: why the call was refused. |
| `message` | string | With `rejected` or `daemon_unavailable`: what was wrong. Never quotes an argument value. |
| `next_step` | string | On a result that is not a plain success: one sentence on what to do now. Fixed text chosen by the outcome code; it never asks for a password or secret and never says to get around a refusal. |
| `request` | string | The request ID. Pass it back as `request` to check the decision. |
| `state` | string | Where the request stands. One of `pending`, `approved`, `denied`, `expired`. |
| `credential` | string | The credential the result is about. For a request made with `looking_for`, absent until the request is approved. |
| `looking_for` | string | For a request made by description: the description, as sent. The item the person chose is named only once the request is approved. |
| `environment` | string | For an environment access request: the target `ORG:ENV` scope (IDs only, never values). |
| `only` | array | For an environment access request: the restricted list of variable names asked for or granted (names only, never values). |
| `intents` | array | The intents asked for, or granted. |
| `ttl_seconds` | integer | The grant's lifetime in seconds: as asked while pending, as granted once approved. |
| `disclose` | boolean | Whether the grant lets code the agent runs read the value. |
| `decide_by` | integer | Unix time after which a pending request expires. |
| `grant` | object | Once approved: the grant's `id`, `expires_at` (Unix time), `project_root` and the `hosts` it names. |

## Outcomes it can return

- [`approval_required`](/docs/outcomes/approval_required): `request_access` recorded the ask and is waiting for the person.
- [`approved`](/docs/outcomes/approved): The person approved the ask.
- [`denied`](/docs/outcomes/denied): The person declined the ask.
- [`expired`](/docs/outcomes/expired): The ask waited 10 minutes without a decision and lapsed.
- [`request_limited`](/docs/outcomes/request_limited): `request_access` is rate limited per client, per session and per daemon, and after three denials in a session every ask answers this.
- [`scope_denied`](/docs/outcomes/scope_denied): The most common refusal.
- [`session_required`](/docs/outcomes/session_required): The call did not come from inside a live agent session: none was presented, it expired, or it is malformed.
- [`vault_locked`](/docs/outcomes/vault_locked): BotPassword on this device is locked, so no credential can be used.
- [`rejected`](/docs/outcomes/rejected): The request was malformed before policy saw it.
- [`daemon_unavailable`](/docs/outcomes/daemon_unavailable): `bpw mcp` or `bpw agent` could not reach `botpasswordd`, the desktop daemon that holds the keys.

See the [outcome reference](/docs/outcomes) for what each one means and what to do next.

## Limits

- The person may shorten the lifetime, drop hosts or take disclosure off; the receipt says what was granted. A new grant replaces any grant the credential already has.
- Lifetimes run from 60 seconds to 7 days (default one hour). Longer grants are made by the person with `bpw grant add`.
- Too many asks answer `request_limited`, and after three denials in one session every ask does.
- An ask is refused for a login password to a host outside its saved site, for a TOTP or passkey item to any host, and for a header APIs do not read credentials from.

## Tool description

*Status: `rotate` is partly built.*

What the MCP tool tells the agent, verbatim from `bpw mcp`:

> Asks the person, in BotPassword's own app, for a grant on one credential, named by its reference (credential) or, when you have none, described in one line (looking_for) so that the person chooses the item: the intents (run_with and/or http_request, or rotate alone), the scope the grant needs (hosts, paths and methods for http_request; commands or argv rules for run_with, with hosts for a sealed run, or disclose to let the command read the value), a lifetime and a one-line reason. An agent cannot grant access itself. The result is a receipt: approval_required with a request ID while the person decides, then the decision in state: the grant (its ID, expiry, project root and hosts), a denial, or expiry. Check it later with request (and wait_seconds to wait up to 30 seconds). The grant is bound to this session's project, may be shorter than asked, may name fewer hosts or take disclosure off (the receipt says what was granted), and replaces any grant the credential has. A described ask's receipt names the item (credential) only once the grant is made; list_credentials then shows it. Too many asks answer request_limited, and after three denials in a session every ask does. This tool never accepts or returns secret values. The result is a typed outcome such as success, vault_locked or scope_denied.

*Status: `rotate` is partly built.*

## Related

*Status: `rotate` is partly built.*

- [`list_credentials`](/docs/intents/list_credentials): lists the credentials this agent client holds grants for, with each one's reference, kind, title, site and the intents its grant allows.
- [`run_with`](/docs/intents/run_with): runs a command with granted credentials injected by BotPassword and returns the exit status and output.
- [`http_request`](/docs/intents/http_request): sends one HTTPS request with a granted credential injected by BotPassword, after checking the origin, path and method against the grant.
- [`rotate`](/docs/intents/rotate) (partly built): rotates a granted credential at its provider and stores the new revision: create a new key, store it as pending, verify it, promote it, then revoke the old one after a grace period.
- [Intent catalog](/docs/intents), [MCP server](/docs/mcp-server), [Grants and approvals](/docs/grants-and-approvals)

*Status: `rotate` is partly built.*
