# Contracts

> Contracts for deals (D695): read with customers:read, with their signers in order; never a signer's email or the words.

| Operation | Method and path | Scope |
|---|---|---|
| [List contracts](https://docs.kaizenaflow.com/reference/admin-api/contracts#contracts-list) | `GET /contracts` | [`customers:read`](https://docs.kaizenaflow.com/reference/scopes#customers-read) |
| [Get a contract](https://docs.kaizenaflow.com/reference/admin-api/contracts#contracts-get) | `GET /contracts/{id}` | [`customers:read`](https://docs.kaizenaflow.com/reference/scopes#customers-read) |

## List contracts {#contracts-list}

`GET https://kaizenaflow.com/api/admin/v1/contracts`

The store's contracts for deals (D695), newest first, with their signers in order: whose turn it is, who signed and when.

- **Operation:** `contracts.list`
- **Scope:** [`customers:read`](https://docs.kaizenaflow.com/reference/scopes#customers-read), or [`customers:write`](https://docs.kaizenaflow.com/reference/scopes#customers-write), which reads too
- **Answers:** `200`, a page: the rows under `data`, and `next` for the page after.
- **Pages:** at most 100 rows, 50 when `limit` is left out; give an answer's `next` as `?after=` for the page after.

### Query parameters {#contracts-list-query}

| Name | Type | Required | Description |
|---|---|---|---|
| `limit` | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
| `after` | string, at most 200 characters | no | The `next` cursor of the page before; the first page when left out. |
| `updated_after` | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |
| `status` | one of `draft`, `sent`, `signed`, `declined`, `expired`, `cancelled` | no | Only contracts in this status. |
| `deal_id` | string (uuid) | no | Only this deal's contracts. |

### Answer {#contracts-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].title` | string |   |
| `data[].status` | one of `draft`, `sent`, `signed`, `declined`, `expired`, `cancelled` | draft: not sent yet. sent: out for signing. signed: by everyone (the deal is won). declined, expired or cancelled: ended. |
| `data[].language` | string | The language it is written and signed in (nb, en). |
| `data[].deal_id` | string (uuid) or null | The deal it is for; null only for a signed contract whose deal was deleted. |
| `data[].template` | string or null | The name of the template it was made from. |
| `data[].signers` | list of objects | In the order they sign. Never their email or the reason a signer gave for declining. |
| `data[].signers[].role` | one of `store`, `customer`, `other` |   |
| `data[].signers[].name` | string |   |
| `data[].signers[].viewed_at` | string (date-time) or null | When they first opened the signing page. |
| `data[].signers[].signed_at` | string (date-time) or null |   |
| `data[].signers[].declined_at` | string (date-time) or null |   |
| `data[].sent_at` | string (date-time) or null |   |
| `data[].expires_at` | string (date-time) or null | The last moment it can be signed, while it is out for signing. |
| `data[].completed_at` | string (date-time) or null | When the last signer signed, or a signer declined. |
| `data[].signed_pdf` | boolean | Whether the sealed PDF of a signed contract is made (within minutes of the last signature). |
| `data[].created_at` | string (date-time) |   |
| `data[].updated_at` | string (date-time) |   |
| `data[].admin_url` | string | The contract's page in the admin, where it is read, sent and its PDF downloaded. |
| `next` | string or null | The cursor of the next page, given as `?after=`; null on the last page. |

### Errors {#contracts-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#contracts-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/contracts' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/contracts", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/contracts",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Get a contract {#contracts-get}

`GET https://kaizenaflow.com/api/admin/v1/contracts/{id}`

One contract with its signers. Its words and PDF are read on its page in the admin.

- **Operation:** `contracts.get`
- **Scope:** [`customers:read`](https://docs.kaizenaflow.com/reference/scopes#customers-read), or [`customers:write`](https://docs.kaizenaflow.com/reference/scopes#customers-write), which reads too
- **Answers:** `200`, the answer under `data`.

### Path parameters {#contracts-get-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#contracts-get-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.title` | string |   |
| `data.status` | one of `draft`, `sent`, `signed`, `declined`, `expired`, `cancelled` | draft: not sent yet. sent: out for signing. signed: by everyone (the deal is won). declined, expired or cancelled: ended. |
| `data.language` | string | The language it is written and signed in (nb, en). |
| `data.deal_id` | string (uuid) or null | The deal it is for; null only for a signed contract whose deal was deleted. |
| `data.template` | string or null | The name of the template it was made from. |
| `data.signers` | list of objects | In the order they sign. Never their email or the reason a signer gave for declining. |
| `data.signers[].role` | one of `store`, `customer`, `other` |   |
| `data.signers[].name` | string |   |
| `data.signers[].viewed_at` | string (date-time) or null | When they first opened the signing page. |
| `data.signers[].signed_at` | string (date-time) or null |   |
| `data.signers[].declined_at` | string (date-time) or null |   |
| `data.sent_at` | string (date-time) or null |   |
| `data.expires_at` | string (date-time) or null | The last moment it can be signed, while it is out for signing. |
| `data.completed_at` | string (date-time) or null | When the last signer signed, or a signer declined. |
| `data.signed_pdf` | boolean | Whether the sealed PDF of a signed contract is made (within minutes of the last signature). |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |
| `data.admin_url` | string | The contract's page in the admin, where it is read, sent and its PDF downloaded. |

### Errors {#contracts-get-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#contracts-get-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/contracts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/contracts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/contracts/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/contracts · made from the API contract 1.57
