# ovok_sdk.resources.chat

Canonical page: https://docs.ovok.com/python-sdk/reference/resources/chat

The `ovok.chat` namespace: chat between patients and their care team.

## ChatThreadsResource [#chatthreadsresource]

```python
ChatThreadsResource(chat: HttpClient)
```

Threads the signed-in person takes part in; access it as `ovok.chat.threads`.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `chat` | `HttpClient` |  | The HTTP client scoped to the chat routes. |

### open() [#open]

```python
open(body: JsonObject, *, options: RequestOptions | None = None) -> Any
```

Open a thread about a patient, or return the open one with the same people.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `body` | `JsonObject` |  | `patient` and `participants` as references, and an optional `title`. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Any`: The thread.

### list() [#list]

```python
list(
    params: JsonObject | None = None,
    *,
    options: RequestOptions | None = None,
) -> Page[Any]
```

List threads, most recently active first.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `params` | `JsonObject \| None` | `None` | Optional `patient` reference, `updatedSince` (ISO time) and `limit`. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Page[Any]`: A page of threads that loads later pages on demand.

### retrieve() [#retrieve]

```python
retrieve(thread_id: str, *, options: RequestOptions | None = None) -> Any
```

Read one thread.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `thread_id` | `str` |  | The thread ID. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Any`: The thread, with its last message and unread count.

## ChatThreadMessagesResource [#chatthreadmessagesresource]

```python
ChatThreadMessagesResource(chat: HttpClient)
```

Messages in a thread; access it as `ovok.chat.messages`.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `chat` | `HttpClient` |  | The HTTP client scoped to the chat routes. |

### list() [#list-1]

```python
list(
    thread_id: str,
    params: JsonObject | None = None,
    *,
    options: RequestOptions | None = None,
) -> Page[Any]
```

List a thread's messages, newest first.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `thread_id` | `str` |  | The thread ID. |
| `params` | `JsonObject \| None` | `None` | Optional `since` (ISO time) and `limit`. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Page[Any]`: A page of messages that loads older pages on demand.

### send() [#send]

```python
send(thread_id: str, body: JsonObject, *, options: RequestOptions | None = None) -> Any
```

Send a message; a retry with the same `clientId` answers the message already sent.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `thread_id` | `str` |  | The thread ID. |
| `body` | `JsonObject` |  | `text`, optional `attachments` (IDs from `ovok.chat.attachments.upload`), `replyTo` and `clientId`; a random `clientId` is added when there is none. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Any`: The message.

### attachment_link() [#attachment_link]

```python
attachment_link(
    thread_id: str,
    message_id: str,
    attachment_id: str,
    *,
    options: RequestOptions | None = None,
) -> Any
```

Get a link that downloads a message's attachment.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `thread_id` | `str` |  | The thread ID. |
| `message_id` | `str` |  | The message ID. |
| `attachment_id` | `str` |  | The attachment ID. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Any`: `url`, usable without a bearer, and `expiresAt`.

## ChatAttachmentsResource [#chatattachmentsresource]

```python
ChatAttachmentsResource(chat: HttpClient, settings: OvokSettings)
```

Files to send in chat messages; access it as `ovok.chat.attachments`.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `chat` | `HttpClient` |  | The HTTP client scoped to the chat routes. |
| `settings` | `OvokSettings` |  | The client's settings; the file goes to the store through its transport. |

### upload() [#upload]

```python
upload(
    *,
    file: bytes,
    file_name: str,
    content_type: str,
    options: RequestOptions | None = None,
) -> Any
```

Upload a file to send with a message.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `file` | `bytes` |  | The file's content. |
| `file_name` | `str` |  | The file's name. |
| `content_type` | `str` |  | `application/pdf`, `image/png`, `image/jpeg` or `image/webp`. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Any`: The attachment: `id`, `title` and `contentType`. Send its `id` in a message's `attachments`.

**Raises**

- `OvokConnectionError`: The file store could not be reached.
- `OvokServiceError`: The file store refused the file.

### link() [#link]

```python
link(attachment_id: str, *, options: RequestOptions | None = None) -> Any
```

Get a link that downloads an attachment you uploaded.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `attachment_id` | `str` |  | The attachment ID. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |

**Returns**

- `Any`: `url`, usable without a bearer, and `expiresAt`.

## ChatResource [#chatresource]

```python
ChatResource(http: HttpClient, settings: OvokSettings)
```

Chat between patients and their care team.

Created by `Ovok`; access it as `ovok.chat`.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `http` | `HttpClient` |  | The client's HTTP client. |
| `settings` | `OvokSettings` |  | The client's settings. |

### read() [#read]

```python
read(
    thread_id: str,
    body: JsonObject | None = None,
    *,
    options: RequestOptions | None = None,
) -> None
```

Mark a thread read for the signed-in person.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `thread_id` | `str` |  | The thread ID. |
| `body` | `JsonObject \| None` | `None` | Optional `readAt` (ISO time); defaults to now. |
| `options` | `RequestOptions \| None` | `None` | Per-request options; `timeout` overrides the client's. |
