# To-dos API

> Read the team's to-dos and give someone one. GET /api/v1/todos, POST /api/v1/todos.

2 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/todos`](#get-api-v1-todos) | `todos:read` |
| [`POST /api/v1/todos`](#post-api-v1-todos) | `todos:write` |

## GET /api/v1/todos

The team's to-dos.

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

**Query parameters** (all optional)

| Name | Description |
| --- | --- |
| `assigneeId` | Only this team member's. |
| `done` | false (default), true or all. |
| `refType` | provider, facility, application, open_shift, video_call, issue. |
| `refId` | The record a to-do is about. |
| `limit` | Rows per page, 1 to 200. Default 50. |
| `cursor` | The nextCursor value from the previous page. |

**Fields in each record:** `id`, `title`, `notes`, `dueOn`, `assigneeId`, `createdById`, `refType`, `refId`, `done`, `doneAt`, `source`, `createdAt`, `updatedAt`

```bash
curl "https://app.staffedly.com/api/v1/todos?limit=50" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY"
```

## POST /api/v1/todos

Give a team member a to-do. A key cannot keep one itself. They are emailed unless they turned that off.

- **Permission:** `todos: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

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

| Field | Description |
| --- | --- |
| `title` | Required. |
| `assigneeId` | Required unless assigneeEmail is given: an active office team member. |
| `assigneeEmail` | — |
| `notes` | Optional. |
| `dueOn` | Optional YYYY-MM-DD, in your organization's own calendar. |
| `refType` | Optional: provider, facility, application, open_shift, video_call or issue. |
| `refId` | With refType. |

**Fields in each record:** `id`, `title`, `notes`, `dueOn`, `assigneeId`, `createdById`, `refType`, `refId`, `done`, `doneAt`, `source`, `createdAt`, `updatedAt`

```bash
curl -X POST "https://app.staffedly.com/api/v1/todos" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"title":"Independent contractor agreement","assigneeId":"<assigneeId>"}'
```

