# Asking your user

Link your identity to your user. Send a request for a specific detail and purpose, then check their decision before using it.

## Link to your user

```sh
asecret link
asecret me
```

Give your user the address and code from `link`. They sign in, check that the code matches and approve the connection. The code stays valid for 15 minutes if the CLI stops waiting.

Set a recognizable name with `asecret connect --name` or `asecret link --name`. The default identifies the runtime and computer so your user can tell which agent is asking.

Your user can see your requests and secret count, pause requests, remove secrets or unlink the identity. They can reveal names and values with [agent recovery](https://asecret.sh/docs/security#recovery) enabled. After they enable it at [asecret.sh/recovery](https://asecret.sh/recovery), your next command shares a sealed copy of your key. Run `asecret me` to check status or `asecret unlink` to end the link.

## Request that your user save a detail

```sh
asecret ask postal_address
asecret ask setup
```

Send the review link from `ask` to your user. They choose or create an entry in their browser. You receive a saved status. With `ask setup`, you receive a readiness status for several details.

The kinds of detail an agent can ask you to save: `postal_address`, `email`, `phone`, `membership`, `secure_note`, `api_key`, `password`, `id_number` and `document`.

Before the agent is linked, even before it connects, `asecret ask <type>` prints a public save link at once. That one isn't tracked.

## Use a detail

```sh
asecret ask postal_address --use --for "fill in the checkout at shop.example"
asecret run --secret POSTAL_ADDRESS -- node checkout.js
```

Pass `--use` and explain the purpose in `--for`. Your user chooses an entry in their browser. If approved, the browser encrypts it to the key you created for this request.

The agent keeps it as one of its secrets, `POSTAL_ADDRESS` unless `--as NAME` says otherwise, and `asecret run` gives a command the whole detail and each part: `POSTAL_ADDRESS_STREET`, `POSTAL_ADDRESS_CITY`, `POSTAL_ADDRESS_REGION`, `POSTAL_ADDRESS_POSTAL_CODE` and `POSTAL_ADDRESS_COUNTRY`. It never shows in the chat unless the agent prints it. You can delete it on the agent's page at asecret.sh.

A script like this one fills in the form, and reads the address only from its environment:

```js
// checkout.js
const { chromium } = await import("playwright");
const env = process.env;

const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto("https://shop.example/checkout");
await page.fill("#street", env.POSTAL_ADDRESS_STREET);
await page.fill("#city", env.POSTAL_ADDRESS_CITY);
await page.fill("#region", env.POSTAL_ADDRESS_REGION ?? "");
await page.fill("#postcode", env.POSTAL_ADDRESS_POSTAL_CODE ?? "");
await page.selectOption("#country", env.POSTAL_ADDRESS_COUNTRY);
await page.click("text=Continue to payment");
await browser.close();
```

An agent can ask to use `postal_address`, `email`, `phone`, `membership`, `secure_note`, `api_key`, `password`, `id_number` or `card`. Not a document.

### Pay for one purchase

For a purchase your user requested, name the merchant, item and amount. Your user selects the card in My details and approves this purchase.

```sh
asecret ask card --use --for "pay for order 1846 at shop.example, $42.00"
asecret run --secret CARD -- node pay.js
```

After approval, your payment script receives CARD_NAME, CARD_NUMBER, CARD_EXPIRY, CARD_CVC and CARD_POSTAL_CODE. Your script submits the payment to the merchant. aSecret deletes the shared card after that one command.

If you have not linked yet, your user approves the link and reviews the request on the same page. Use `asecret check <ask> --wait` to resume waiting and collect an approved entry.

## Check where it stands

```sh
asecret asks
asecret check <ask>
asecret check <ask> --wait
asecret cancel <ask>
```

`asks` lists what this agent asked and where each stands. `check` reads one; `--wait` checks until you decide. An ask waits 15 minutes. Wait for `confirmed` before going on: a declined, expired or canceled ask ends that step. `cancel` stops an ask that still waits.

Your user can inspect each request, decision and receipt under Activity at asecret.sh.

## Pause an agent

Under Agents, Pause stops an agent from asking you for anything, and cancels what it asked that still waits. Its secrets stay as they are. Resume lets it ask again. A paused agent's asks fail with `access_paused`.

## Use details for the approved purpose

A saved status tells you the detail is available. A use approval grants access to one entry for the stated purpose. An approved delivery address does not authorize a payment.

Your script fills the form with the approved detail. To deliver addresses or use payment methods with participating merchants, connect to your user’s own server. See [Self-hosting](https://asecret.sh/docs/self-hosting).
