# Threads API

> Every /v1/threads endpoint: list the Threads of this Project, read one Thread by its key.

Base URL: `https://api.nibify.app`.

## List the Threads of this Project

`GET /v1/threads`

Every conversation this key can see, the one that last spoke first. Metadata only: `lastMessage` is the notification block of the newest Message, never anything read out of a surface. One-shot Requests are Threads of one and are listed too — their `threadKey` is null. The list is scoped to the half of the Project the key belongs to: a `sk_test_…` never sees a live conversation.

**Headers**

| Field | Type | Description |
| --- | --- | --- |
| `Authorization` | string, required | `Bearer sk_test_…`: an API key of your project. |

**Query parameters**

| Field | Type | Description |
| --- | --- | --- |
| `limit` | integer | How many Threads a page holds. Between 1 and 100. Defaults to `30`. |
| `cursor` | string | The `nextCursor` of the previous page. Omit it for the first page. Not empty. |

**Responses**

| Status | Description |
| --- | --- |
| `200` | One page, newest activity first, and the cursor for the next one. |
| `401` | [`unauthorized`](https://nibify.app/docs/errors-and-rate-limits#unauthorized) for a missing or unusable key, [`api_key_revoked`](https://nibify.app/docs/errors-and-rate-limits#api_key_revoked) for a revoked one. |
| `422` | [`invalid_request_body`](https://nibify.app/docs/errors-and-rate-limits#invalid_request_body). `limit` must be between 1 and 100; `cursor` must be a `nextCursor` this endpoint returned. |
| `429` | [`rate_limited`](https://nibify.app/docs/errors-and-rate-limits#rate_limited). This project is over its requests-per-second ceiling or its daily volume in the environment this key speaks for; the message says which of the two it was. The budget is the project’s and not the key’s, so another API key of the same project shares it — the `test` and `live` halves are counted apart. Nothing was created and nothing was counted: retrying after `Retry-After` is safe. Header `Retry-After`: how many seconds to wait before retrying. Always a whole number, never below 1. |

**Response body, 200**

| Field | Type | Description |
| --- | --- | --- |
| `items` | array of objects, required | The Threads of this page, the one that last spoke first. |
| `items[].threadId` | string, required | The Thread’s id. |
| `items[].threadKey` | string or null, required | The key the Thread was named with, or null for a one-shot Request’s own. |
| `items[].environment` | string, required | The Environment the Thread belongs to. One of `test`, `live`. |
| `items[].messageCount` | integer, required | How many Messages the Thread holds. |
| `items[].createdAt` | string, required | When the Thread was created, by its first Message. An RFC 3339 timestamp. |
| `items[].lastMessage` | object, required | A Message of a Thread: what the push said and its receipts, never its Surface. |
| `items[].lastMessage.messageId` | string, required | The Message’s id. For a Request, the same as its `requestId`. |
| `items[].lastMessage.sequence` | integer, required | The Message’s position in its Thread, starting at 1. |
| `items[].lastMessage.interactionType` | string, required | What the Message asks for: `informational` nothing, `action` an answer, `conversation` the next turn of the exchange. One of `informational`, `action`, `conversation`. |
| `items[].lastMessage.status` | string or null, required | The Request’s status, or null for a Notification, which has none. One of `pending`, `answered`, `expired`, `dismissed`, `cancelled`. |
| `items[].lastMessage.sender` | object, required | Who the Message was sent as. |
| `items[].lastMessage.sender.name` | string, required | The name the person sees. |
| `items[].lastMessage.sender.icon` | string or null, required | The icon it was sent with, or null. |
| `items[].lastMessage.notification` | object, required | What the push said. Empty once the person has deleted the content. |
| `items[].lastMessage.notification.title` | string, required | The title of the push and of its Inbox row. |
| `items[].lastMessage.notification.body` | string, required | The text of the push and of its Inbox row. |
| `items[].lastMessage.notification.quickActions` | array of objects, required | The buttons on the push, empty when it had none. |
| `items[].lastMessage.notification.quickActions[].name` | string, required | The action the button dispatches. |
| `items[].lastMessage.notification.quickActions[].label` | string, required | The button’s text on the notification. |
| `items[].lastMessage.minCatalogVersion` | integer or null, required | The lowest catalog version that can draw its Surface. Null when it has none, or once the content is deleted. |
| `items[].lastMessage.createdAt` | string, required | When the Message was sent. An RFC 3339 timestamp. |
| `items[].lastMessage.expiresAt` | string or null, required | When the Request expires, or null if it never does. An RFC 3339 timestamp. |
| `items[].lastMessage.deliveredAt` | string or null, required | When a phone of the recipient first confirmed the push arrived. Null means not confirmed yet, not that it was not sent. An RFC 3339 timestamp. |
| `items[].lastMessage.readAt` | string or null, required | When the person first opened it, or null. Never set while `deliveredAt` is not. An RFC 3339 timestamp. |
| `items[].lastMessage.contentDeletedAt` | string or null, required | When the person deleted what was said in this Message, or null. The Message stays in the Thread, emptied. An RFC 3339 timestamp. |
| `nextCursor` | string or null, required | The `cursor` of the next page, or null on the last one. |

## Read one Thread by its key

`GET /v1/threads/{key}`

The conversation the agent named, and its history in order — oldest first, mixed: the notification of a plain Request and the metadata of an interactive card read the same way, told apart by `interactionType`. Page forward with `after`, which is the `sequence` of the last Message you hold; `nextAfter` is null when the page reached the end. A one-shot Thread has no key and is not reachable here — read its Request with `GET /v1/requests/{id}`.

**Headers**

| Field | Type | Description |
| --- | --- | --- |
| `Authorization` | string, required | `Bearer sk_test_…`: an API key of your project. |

**Path parameters**

| Field | Type | Description |
| --- | --- | --- |
| `key` | string, required | The `threadKey` sent with the Requests of this conversation. URL-encode it: it is the agent’s own string and this API never parses it. |

**Query parameters**

| Field | Type | Description |
| --- | --- | --- |
| `after` | integer | The `sequence` of the last Message you hold: the page starts after it. `0` reads from the beginning. At least 0. Defaults to `0`. |
| `limit` | integer | How many Messages a page holds. Between 1 and 100. Defaults to `30`. |

**Responses**

| Status | Description |
| --- | --- |
| `200` | The Thread and one page of its Messages. |
| `401` | [`unauthorized`](https://nibify.app/docs/errors-and-rate-limits#unauthorized) for a missing or unusable key, [`api_key_revoked`](https://nibify.app/docs/errors-and-rate-limits#api_key_revoked) for a revoked one. |
| `404` | [`thread_not_found`](https://nibify.app/docs/errors-and-rate-limits#thread_not_found). A Thread of another Project — or of the other half of this one — answers the same way as a key nobody has used. |
| `422` | [`invalid_request_body`](https://nibify.app/docs/errors-and-rate-limits#invalid_request_body). `after` must be a whole number; `limit` 1 to 100. |
| `429` | [`rate_limited`](https://nibify.app/docs/errors-and-rate-limits#rate_limited). This project is over its requests-per-second ceiling or its daily volume in the environment this key speaks for; the message says which of the two it was. The budget is the project’s and not the key’s, so another API key of the same project shares it — the `test` and `live` halves are counted apart. Nothing was created and nothing was counted: retrying after `Retry-After` is safe. Header `Retry-After`: how many seconds to wait before retrying. Always a whole number, never below 1. |

**Response body, 200**

| Field | Type | Description |
| --- | --- | --- |
| `threadId` | string, required | The Thread’s id. |
| `threadKey` | string or null, required | The key the Thread was named with, or null for a one-shot Request’s own. |
| `environment` | string, required | The Environment the Thread belongs to. One of `test`, `live`. |
| `messageCount` | integer, required | How many Messages the Thread holds. |
| `createdAt` | string, required | When the Thread was created, by its first Message. An RFC 3339 timestamp. |
| `lastMessage` | object, required | A Message of a Thread: what the push said and its receipts, never its Surface. |
| `lastMessage.messageId` | string, required | The Message’s id. For a Request, the same as its `requestId`. |
| `lastMessage.sequence` | integer, required | The Message’s position in its Thread, starting at 1. |
| `lastMessage.interactionType` | string, required | What the Message asks for: `informational` nothing, `action` an answer, `conversation` the next turn of the exchange. One of `informational`, `action`, `conversation`. |
| `lastMessage.status` | string or null, required | The Request’s status, or null for a Notification, which has none. One of `pending`, `answered`, `expired`, `dismissed`, `cancelled`. |
| `lastMessage.sender` | object, required | Who the Message was sent as. |
| `lastMessage.sender.name` | string, required | The name the person sees. |
| `lastMessage.sender.icon` | string or null, required | The icon it was sent with, or null. |
| `lastMessage.notification` | object, required | What the push said. Empty once the person has deleted the content. |
| `lastMessage.notification.title` | string, required | The title of the push and of its Inbox row. |
| `lastMessage.notification.body` | string, required | The text of the push and of its Inbox row. |
| `lastMessage.notification.quickActions` | array of objects, required | The buttons on the push, empty when it had none. |
| `lastMessage.notification.quickActions[].name` | string, required | The action the button dispatches. |
| `lastMessage.notification.quickActions[].label` | string, required | The button’s text on the notification. |
| `lastMessage.minCatalogVersion` | integer or null, required | The lowest catalog version that can draw its Surface. Null when it has none, or once the content is deleted. |
| `lastMessage.createdAt` | string, required | When the Message was sent. An RFC 3339 timestamp. |
| `lastMessage.expiresAt` | string or null, required | When the Request expires, or null if it never does. An RFC 3339 timestamp. |
| `lastMessage.deliveredAt` | string or null, required | When a phone of the recipient first confirmed the push arrived. Null means not confirmed yet, not that it was not sent. An RFC 3339 timestamp. |
| `lastMessage.readAt` | string or null, required | When the person first opened it, or null. Never set while `deliveredAt` is not. An RFC 3339 timestamp. |
| `lastMessage.contentDeletedAt` | string or null, required | When the person deleted what was said in this Message, or null. The Message stays in the Thread, emptied. An RFC 3339 timestamp. |
| `messages` | object, required | One page of the Thread’s Messages, oldest first. |
| `messages.items` | array of objects, required | The Messages of this page, oldest first. |
| `messages.items[].messageId` | string, required | The Message’s id. For a Request, the same as its `requestId`. |
| `messages.items[].sequence` | integer, required | The Message’s position in its Thread, starting at 1. |
| `messages.items[].interactionType` | string, required | What the Message asks for: `informational` nothing, `action` an answer, `conversation` the next turn of the exchange. One of `informational`, `action`, `conversation`. |
| `messages.items[].status` | string or null, required | The Request’s status, or null for a Notification, which has none. One of `pending`, `answered`, `expired`, `dismissed`, `cancelled`. |
| `messages.items[].sender` | object, required | Who the Message was sent as. |
| `messages.items[].sender.name` | string, required | The name the person sees. |
| `messages.items[].sender.icon` | string or null, required | The icon it was sent with, or null. |
| `messages.items[].notification` | object, required | What the push said. Empty once the person has deleted the content. |
| `messages.items[].notification.title` | string, required | The title of the push and of its Inbox row. |
| `messages.items[].notification.body` | string, required | The text of the push and of its Inbox row. |
| `messages.items[].notification.quickActions` | array of objects, required | The buttons on the push, empty when it had none. |
| `messages.items[].notification.quickActions[].name` | string, required | The action the button dispatches. |
| `messages.items[].notification.quickActions[].label` | string, required | The button’s text on the notification. |
| `messages.items[].minCatalogVersion` | integer or null, required | The lowest catalog version that can draw its Surface. Null when it has none, or once the content is deleted. |
| `messages.items[].createdAt` | string, required | When the Message was sent. An RFC 3339 timestamp. |
| `messages.items[].expiresAt` | string or null, required | When the Request expires, or null if it never does. An RFC 3339 timestamp. |
| `messages.items[].deliveredAt` | string or null, required | When a phone of the recipient first confirmed the push arrived. Null means not confirmed yet, not that it was not sent. An RFC 3339 timestamp. |
| `messages.items[].readAt` | string or null, required | When the person first opened it, or null. Never set while `deliveredAt` is not. An RFC 3339 timestamp. |
| `messages.items[].contentDeletedAt` | string or null, required | When the person deleted what was said in this Message, or null. The Message stays in the Thread, emptied. An RFC 3339 timestamp. |
| `messages.nextAfter` | integer or null, required | The `after` of the next page, or null when this page reached the end of the Thread. |
