# prov.mandate.runs.create

prov.mandate.runs.create in Node SDK. Start a run, optionally rooted at the person's mandate (its budget feeds the guard's budget pressure).

## Signature

```ts
prov.mandate.runs.create(params?: { name?: string; rootGrantId?: string }): Promise<Run>
```

## Parameters

- `params` ({ name?: string; rootGrantId?: string }, optional)

## Returns

`Promise<Run>`

## HTTP operation

[`POST /v1/mandate/runs`](https://provenanceauth.com/docs/api/runs.md#post-v1-mandate-runs): Start a run

## 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)
- [`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/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",
      "expires_at": "2027-12-31T23:59:59Z"
    }
  }),
})).json();
const mandateId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/runs`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Restock printer paper", "root_grant_id": mandateId }),
})).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",
        "expires_at": "2027-12-31T23:59:59Z"
    }
}).json()
mandate_id = step1["id"]
data = httpx.post(f"{api}/v1/mandate/runs", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "name": "Restock printer paper",
    "root_grant_id": mandate_id
}).json()
```
