# prov.mandate.grants.delegate_as_holder

prov.mandate.grants.delegate_as_holder in Python SDK. Delegate as the agent that holds the mandate, with no account key (holder proof).

## Signature

```python
prov.mandate.grants.delegate_as_holder(mandate_id: str, parent_token: str, private_jwk: Mapping[str, Any], directory_url: str, agent_session_id: str, purpose: str, purpose_tags: Optional[list] = …, agent_id: Optional[str] = …, constraints: Optional[dict] = …, max_depth: Optional[int] = …, run_id: Optional[str] = …, budget: Optional[dict] = …, keyid: Optional[str] = …) -> Any
```

## Parameters

- `mandate_id` (str)
- `parent_token` (str)
- `private_jwk` (Mapping[str, Any])
- `directory_url` (str)
- `agent_session_id` (str)
- `purpose` (str)
- `purpose_tags` (Optional[list], optional)
- `agent_id` (Optional[str], optional)
- `constraints` (Optional[dict], optional)
- `max_depth` (Optional[int], optional)
- `run_id` (Optional[str], optional)
- `budget` (Optional[dict], optional)
- `keyid` (Optional[str], optional)

## Returns

`Any`

## HTTP operation

[`POST /v1/mandate/grants/{id}/delegate`](https://provenanceauth.com/docs/api/grants.md#post-v1-mandate-grants-id-delegate): Delegate a mandate to a subagent

## Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`usage_limit_reached`](https://provenanceauth.com/docs/platform/errors.md#usage_limit_reached)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`grant_invalid`](https://provenanceauth.com/docs/platform/errors.md#grant_invalid)
- [`agent_suspended`](https://provenanceauth.com/docs/platform/errors.md#agent_suspended)
- [`purpose_required`](https://provenanceauth.com/docs/platform/errors.md#purpose_required)
- [`purpose_tags_exceed_parent`](https://provenanceauth.com/docs/platform/errors.md#purpose_tags_exceed_parent)
- [`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)
- [`external_delegation_refused`](https://provenanceauth.com/docs/platform/errors.md#external_delegation_refused)
- [`external_delegation_declined`](https://provenanceauth.com/docs/platform/errors.md#external_delegation_declined)
- [`external_delegation_used`](https://provenanceauth.com/docs/platform/errors.md#external_delegation_used)
- [`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/grants`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "device_id": "dev_00000000000000000000000000000001",
    "purpose": "Restock printer paper for the office",
    "constraints": {
      "max_amount": 80,
      "budget_amount": 200,
      "budget_window": "month",
      "currency": "USD",
      "allowed_action_types": [
        "quote",
        "purchase"
      ],
      "allowed_counterparties": [
        "paper.example",
        "office.example"
      ],
      "allowed_mcc": [
        {
          "group": "office_supplies"
        }
      ],
      "blocked_mcc": [
        {
          "group": "cash_like"
        }
      ],
      "expires_at": "2027-12-31T23:59:59Z"
    }
  }),
})).json();
const mandateId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/grants/${mandateId}/delegate`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "agent_session_id": "sess_paperfinder_1",
    "purpose": "Find A4 paper prices at three stores",
    "purpose_tags": [
      "quote"
    ],
    "budget": {
      "allocation": "reserved",
      "at_limit": "ask",
      "ask_up_to": {
        "percent": 10
      }
    },
    "constraints": {
      "max_amount": 40,
      "budget_amount": 60,
      "allowed_action_types": [
        "quote"
      ],
      "blocked_counterparties": [
        "pawn.example"
      ]
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/mandate/grants", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "device_id": "dev_00000000000000000000000000000001",
    "purpose": "Restock printer paper for the office",
    "constraints": {
        "max_amount": 80,
        "budget_amount": 200,
        "budget_window": "month",
        "currency": "USD",
        "allowed_action_types": [
            "quote",
            "purchase"
        ],
        "allowed_counterparties": [
            "paper.example",
            "office.example"
        ],
        "allowed_mcc": [
            {
                "group": "office_supplies"
            }
        ],
        "blocked_mcc": [
            {
                "group": "cash_like"
            }
        ],
        "expires_at": "2027-12-31T23:59:59Z"
    }
}).json()
mandate_id = step1["id"]
data = httpx.post(f"{api}/v1/mandate/grants/{mandate_id}/delegate", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "agent_session_id": "sess_paperfinder_1",
    "purpose": "Find A4 paper prices at three stores",
    "purpose_tags": [
        "quote"
    ],
    "budget": {
        "allocation": "reserved",
        "at_limit": "ask",
        "ask_up_to": {
            "percent": 10
        }
    },
    "constraints": {
        "max_amount": 40,
        "budget_amount": 60,
        "allowed_action_types": [
            "quote"
        ],
        "blocked_counterparties": [
            "pawn.example"
        ]
    }
}).json()
```
