# prov.authorize.network.requestGrant

prov.authorize.network.requestGrant in Node SDK. Ask a person for a network mandate for one of your verified agents.

## Signature

```ts
prov.authorize.network.requestGrant(params: { agentId: string; proposed: NetworkConstraints; returnUrl?: string; /** #180: how far above your ask a person may raise (never below `proposed`); leave out for no ceiling. */ hardMax?: Partial<GrantHardMax>; /** #180: this grant's near-limit channels, overriding your setting. */ limitNoticeChannels?: Partial<LimitNoticeChannels>; }): Promise<NetworkGrantRequest>
```

## Parameters

- `params` ({ agentId: string; proposed: NetworkConstraints; returnUrl?: string; /** #180: how far above your ask a person may raise (never below `proposed`); leave out for no ceiling. */ hardMax?: Partial<GrantHardMax>; /** #180: this grant's near-limit channels, overriding your setting. */ limitNoticeChannels?: Partial<LimitNoticeChannels>; })

## Returns

`Promise<NetworkGrantRequest>`

## HTTP operation

[`POST /v1/mandate/grant_requests`](https://provenanceauth.com/docs/api/network.md#post-v1-mandate-grant-requests): Ask a person for a network mandate

## Errors

- [`network_agent_unverified`](https://provenanceauth.com/docs/platform/errors.md#network_agent_unverified)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

## Example

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/agents`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "cartwise", "category": "shopping_agent" }),
})).json();
const agentId = step1.id;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/agents/${agentId}/signing_keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "jwk": {
      "kty": "OKP",
      "crv": "Ed25519",
      "x": "G_STrQBvTD7Bi8OjlNnLcKPPiPp03Vh0sJKTMG7QzFY"
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/grant_requests`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "agent_id": agentId,
    "proposed": {
      "max_amount": 50,
      "budget_amount": 200,
      "budget_window": "month",
      "currency": "USD",
      "expires_at": "2027-06-30T00:00:00Z"
    },
    "return_url": "https://cartwise.example/connected",
    "hard_max": {
      "max_amount": 100,
      "budget_amount": 400
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/mandate/agents", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "name": "cartwise",
    "category": "shopping_agent"
}).json()
agent_id = step1["id"]
step2 = httpx.post(f"{api}/v1/identify/agents/{agent_id}/signing_keys", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "jwk": {
        "kty": "OKP",
        "crv": "Ed25519",
        "x": "G_STrQBvTD7Bi8OjlNnLcKPPiPp03Vh0sJKTMG7QzFY"
    }
}).json()
data = httpx.post(f"{api}/v1/mandate/grant_requests", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "agent_id": agent_id,
    "proposed": {
        "max_amount": 50,
        "budget_amount": 200,
        "budget_window": "month",
        "currency": "USD",
        "expires_at": "2027-06-30T00:00:00Z"
    },
    "return_url": "https://cartwise.example/connected",
    "hard_max": {
        "max_amount": 100,
        "budget_amount": 400
    }
}).json()
```
