# prov.mandate.grants.propose

prov.mandate.grants.propose in Node SDK. Propose a delegation structure under a mandate you hold.

## Signature

```ts
prov.mandate.grants.propose(mandateId: string, params: ProposeDelegationParams): Promise<DelegationProposalCreated>
```

## Parameters

- `mandateId` (string)
- `params` (ProposeDelegationParams)

## Returns

`Promise<DelegationProposalCreated>`

## HTTP operation

[`POST /v1/mandate/grants/{id}/delegation_proposals`](https://provenanceauth.com/docs/api/grants.md#post-v1-mandate-grants-id-delegation-proposals): Propose a delegation structure

## Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`holder_proof_invalid`](https://provenanceauth.com/docs/platform/errors.md#holder_proof_invalid)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`delegation_exceeds_parent`](https://provenanceauth.com/docs/platform/errors.md#delegation_exceeds_parent)
- [`delegation_depth_exceeded`](https://provenanceauth.com/docs/platform/errors.md#delegation_depth_exceeded)
- [`delegation_limit_reached`](https://provenanceauth.com/docs/platform/errors.md#delegation_limit_reached)
- [`mandate_limits_cap_exceeded`](https://provenanceauth.com/docs/platform/errors.md#mandate_limits_cap_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`purpose_tags_exceed_parent`](https://provenanceauth.com/docs/platform/errors.md#purpose_tags_exceed_parent)
- [`grant_invalid`](https://provenanceauth.com/docs/platform/errors.md#grant_invalid)
- [`proposal_closed`](https://provenanceauth.com/docs/platform/errors.md#proposal_closed)
- [`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/agents`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Scout Flights", "category": "shopping_agent" }),
})).json();
const flightsId = step1.id;
const step2 = 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": "Scout Stays", "category": "shopping_agent" }),
})).json();
const staysId = step2.id;
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/grants`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "device_id": "dev_00000000000000000000000000000001",
    "purpose": "Book Maya's Lisbon trip, 12 to 16 March",
    "constraints": {
      "max_amount": 1300,
      "budget_amount": 2400,
      "budget_window": "month",
      "currency": "USD",
      "allowed_mcc": [
        {
          "group": "airlines"
        },
        {
          "group": "lodging"
        }
      ],
      "expires_at": "2027-12-31T23:59:59Z"
    }
  }),
})).json();
const mandateId = step3.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/grants/${mandateId}/delegation_proposals`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "notify": false,
    "approver": {
      "name": "Maya Chen"
    },
    "children": [
      {
        "agent_id": flightsId,
        "purpose": "Book the flights",
        "budget": {
          "allocation": "shared",
          "at_limit": "continue"
        },
        "constraints": {
          "budget_amount": 900,
          "allowed_mcc": [
            {
              "group": "airlines"
            }
          ]
        }
      },
      {
        "agent_id": staysId,
        "purpose": "Book the stay",
        "budget": {
          "allocation": "reserved",
          "at_limit": "stop"
        },
        "constraints": {
          "budget_amount": 1100,
          "allowed_mcc": [
            {
              "group": "lodging"
            }
          ],
          "allowed_counterparties": [
            "casamarlinde.example"
          ]
        }
      }
    ]
  }),
})).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": "Scout Flights",
    "category": "shopping_agent"
}).json()
flights_id = step1["id"]
step2 = httpx.post(f"{api}/v1/mandate/agents", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "name": "Scout Stays",
    "category": "shopping_agent"
}).json()
stays_id = step2["id"]
step3 = httpx.post(f"{api}/v1/mandate/grants", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "device_id": "dev_00000000000000000000000000000001",
    "purpose": "Book Maya's Lisbon trip, 12 to 16 March",
    "constraints": {
        "max_amount": 1300,
        "budget_amount": 2400,
        "budget_window": "month",
        "currency": "USD",
        "allowed_mcc": [
            {
                "group": "airlines"
            },
            {
                "group": "lodging"
            }
        ],
        "expires_at": "2027-12-31T23:59:59Z"
    }
}).json()
mandate_id = step3["id"]
data = httpx.post(f"{api}/v1/mandate/grants/{mandate_id}/delegation_proposals", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "notify": False,
    "approver": {
        "name": "Maya Chen"
    },
    "children": [
        {
            "agent_id": flights_id,
            "purpose": "Book the flights",
            "budget": {
                "allocation": "shared",
                "at_limit": "continue"
            },
            "constraints": {
                "budget_amount": 900,
                "allowed_mcc": [
                    {
                        "group": "airlines"
                    }
                ]
            }
        },
        {
            "agent_id": stays_id,
            "purpose": "Book the stay",
            "budget": {
                "allocation": "reserved",
                "at_limit": "stop"
            },
            "constraints": {
                "budget_amount": 1100,
                "allowed_mcc": [
                    {
                        "group": "lodging"
                    }
                ],
                "allowed_counterparties": [
                    "casamarlinde.example"
                ]
            }
        }
    ]
}).json()
```
