# Notes and email history API

> Read and add notes, and read the email conversation, on a facility, provider or applicant record. GET /api/v1/records/{type}/{id}/notes, POST /api/v1/records/{type}/{id}/notes, GET /api/v1/records/{type}/{id}/thread.

3 operations. Each needs an API key with the permission shown; see [API keys and permissions](https://staffedly.com/docs/developers/api-keys).

| Operation | Permission |
| --- | --- |
| [`GET /api/v1/records/{type}/{id}/notes`](#get-api-v1-records-type-id-notes) | `relationships:read` |
| [`POST /api/v1/records/{type}/{id}/notes`](#post-api-v1-records-type-id-notes) | `relationships:write` |
| [`GET /api/v1/records/{type}/{id}/thread`](#get-api-v1-records-type-id-thread) | `relationships:read` |

## GET /api/v1/records/{type}/{id}/notes

Notes and history on a facility, provider or applicant record (type: facility, provider, application). An applicant's also needs Recruiting: read.

- **Permission:** `relationships:read`
- **Returns:** a page of records: `{ data, hasMore, nextCursor }`, status 200

**Path**

| Name | Description |
| --- | --- |
| `id` | The record's id. |
| `type` | One of `facility`, `provider`, `application`. |

**Query parameters** (all optional)

| Name | Description |
| --- | --- |
| `limit` | Rows per page, 1 to 200. Default 50. |
| `cursor` | The nextCursor value from the previous page. |

**Fields in each record:** `id`, `recordType`, `recordId`, `kind`, `body`, `by`, `createdAt`

```bash
curl "https://app.staffedly.com/api/v1/records/facility/<id>/notes?limit=50" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY"
```

## POST /api/v1/records/{type}/{id}/notes

Add a note to a record, in the key's name. An applicant's also needs Recruiting: write.

- **Permission:** `relationships:write`
- **Returns:** one record: `{ data }`, status 201
- **Safe retry:** send an `Idempotency-Key` header (8 to 128 characters); the same key with the same request returns the first answer again

**Path**

| Name | Description |
| --- | --- |
| `id` | The record's id. |
| `type` | One of `facility`, `provider`, `application`. |

**Body fields** (JSON; a field the API does not know is refused)

| Field | Description |
| --- | --- |
| `body` | Required. Up to 4,000 characters. |

**Fields in each record:** `id`, `recordType`, `recordId`, `kind`, `body`, `by`, `createdAt`

```bash
curl -X POST "https://app.staffedly.com/api/v1/records/facility/<id>/notes" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"body":"Spoke to the nurse manager about January nights."}'
```

## GET /api/v1/records/{type}/{id}/thread

The email conversation on a facility, provider or applicant record, both directions, oldest first. An applicant's also needs Recruiting: read.

- **Permission:** `relationships:read`
- **Returns:** a page of records: `{ data, hasMore, nextCursor }`, status 200

**Path**

| Name | Description |
| --- | --- |
| `id` | The record's id. |
| `type` | One of `facility`, `provider`, `application`. |

**Query parameters** (all optional)

| Name | Description |
| --- | --- |
| `limit` | Rows per page, 1 to 200. Default 50. |
| `cursor` | The nextCursor value from the previous page. |

**Fields in each record:** `id`, `recordType`, `recordId`, `direction`, `from`, `fromName`, `to`, `subject`, `body`, `status`, `at`

```bash
curl "https://app.staffedly.com/api/v1/records/facility/<id>/thread?limit=50" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY"
```

