# prov.mandate.approvals.link

prov.mandate.approvals.link in Node SDK. Slice 7 (the agent relay): a fresh single-use link to a pending approval, for your agent to pass on to the person itself (a text, an email, a code on a screen).

## Signature

```ts
prov.mandate.approvals.link(id: string): Promise<ApprovalLink>
```

## Parameters

- `id` (string)

## Returns

`Promise<ApprovalLink>`

## HTTP operation

[`POST /v1/mandate/approvals/{id}/link`](https://provenanceauth.com/docs/api/approvals.md#post-v1-mandate-approvals-id-link): Get a link to an approval

## Errors

- [`approval_already_decided`](https://provenanceauth.com/docs/platform/errors.md#approval_already_decided)
- [`approval_routed_to_approver`](https://provenanceauth.com/docs/platform/errors.md#approval_routed_to_approver)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)

## Example

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "wires need a person",
    "document": {
      "rules": [
        {
          "id": "wire-needs-approval",
          "when": [
            {
              "fact": "action_type",
              "op": "eq",
              "value": "wire"
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/intents`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "action_description": "Wire $12,000 to Acme Corp for PO-7781",
    "agent_session_id": "sess_treasury_1",
    "device_id": "dev_00000000000000000000000000000001"
  }),
})).json();
const intentToken = step2.intent_token;
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/assessments`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "intent_token": intentToken,
    "action_description": "Wire $12,000 to Acme Corp for PO-7781",
    "context": {
      "action_type": "wire"
    }
  }),
})).json();
const approvalId = step3.approval_id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/approvals/${approvalId}/link`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/mandate/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "wires need a person",
    "document": {
        "rules": [
            {
                "id": "wire-needs-approval",
                "when": [
                    {
                        "fact": "action_type",
                        "op": "eq",
                        "value": "wire"
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
step2 = httpx.post(f"{api}/v1/mandate/intents", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "action_description": "Wire $12,000 to Acme Corp for PO-7781",
    "agent_session_id": "sess_treasury_1",
    "device_id": "dev_00000000000000000000000000000001"
}).json()
intent_token = step2["intent_token"]
step3 = httpx.post(f"{api}/v1/mandate/assessments", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "intent_token": intent_token,
    "action_description": "Wire $12,000 to Acme Corp for PO-7781",
    "context": {
        "action_type": "wire"
    }
}).json()
approval_id = step3["approval_id"]
data = httpx.post(f"{api}/v1/mandate/approvals/{approval_id}/link", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```
