> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heysaturn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Document Endpoints

Manage and retrieve meeting notes and document data using the following endpoints.

## Full Endpoint URL

```
https://secure.heysaturn.com/api/external/v1/document/
```

## `GET /list/`

This endpoint retrieves a list of documents filtered by `since`, `account_id`, and `crm`. Only documents in the "Reviewed" status will be returned.

#### Query Parameters

| Parameter    | Type   | Required | Description                                                                                                      |
| ------------ | ------ | -------- | ---------------------------------------------------------------------------------------------------------------- |
| `crm`        | string | Yes      | The CRM source. Must be a valid CRM (`curo`, `xplan`, `plannr`, `intelliflo`).                                   |
| `since`      | string | No       | Return documents created or updated since this datetime (ISO 8601 format).                                       |
| `account_id` | string | No       | Filter documents associated with the given account ID. At least one of `since` or `account_id` must be provided. |
| `limit`      | int    | No       | Number of documents to return (default: 2, maximum: 20).                                                         |
| `offset`     | int    | No       | Starting point for the query (default: 0).                                                                       |

#### Request Example

```http theme={null}
GET /api/external/v1/document/list/?crm=curo&since=2023-01-01T00:00:00Z&limit=5&offset=0
Authorization: Api-Key <your_api_key>
```

### Response Example

```json theme={null}
{
    "count": 2,
    "limit": 5,
    "offset": 0,
    "results": [
        {
            "document_id": "12345",
            "document_name": "Meeting Notes for Client ABC",
            "curo_advisor_id": "external-advisor-id-123",
            "advisor_id": "internal-advisor-id-1",
            "curo_account_id": "external-account-id-456",
            "client_ids": ["1001", "1002"],
            "curo_client_ids": ["external-client-id-789", "external-client-id-790"]
        }
    ]
}
```

#### Result Fields Description

Each object in the `results` array contains the following fields:

| **Field**         | **Description**                                                                                                               |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `document_id`     | The unique identifier for the document associated with the meeting notes within Saturn.                                       |
| `document_name`   | The name of the document, typically describing the purpose or content of the document (e.g., "Meeting Notes for Client ABC"). |
| `advisor_id`      | The internal ID of the advisor in Saturn associated with this document.                                                       |
| `curo_advisor_id` | The external ID of the advisor in the CRM (e.g., `curo`, `xplan`, etc.) that the advisor was sourced from.                    |
| `curo_account_id` | The external account ID in the CRM where the document or the associated data was originally linked.                           |
| `client_ids`      | A list of internal IDs in Saturn for the clients associated with this document.                                               |
| `curo_client_ids` | A list of external client IDs in the CRM (e.g., `curo`, `xplan`, etc.) for the clients linked to this document.               |

### Error Responses

* **403 Bad Request**: Invalid or missing query parameters.
* **404 Not Found**: No documents match the given filters.
* **500 Internal Server Error**: Unexpected error during processing.

## `GET /download/`

Only documents in the `Reviewed` status can be downloaded. If the document is not in Reviewed status, an error message is returned, indicating the document’s current status.

#### Query Parameters

| Parameter    | Type   | Required | Description                                                     |
| ------------ | ------ | -------- | --------------------------------------------------------------- |
| document\_id | string | Yes      | The unique ID (saturn id) of the document you want to download. |

#### Request Example

```http theme={null}
GET /api/external/v1/document/download/?document_id=34
Authorization: Api-Key <your_api_key>
```

***

#### Response Example

When the document is successfully retrieved and eligible for download, a word file `.docx` is returned as the response. The content of the file will include the meeting notes structured and formatted for readability.

### Response Type

| Header                | Value                                                                     |
| --------------------- | ------------------------------------------------------------------------- |
| `Content-Type`        | `application/vnd.openxmlformats-officedocument.wordprocessingml.document` |
| `Content-Disposition` | `attachment; filename=document_name.docx`                                 |

### Example File Content

Below is an example of the content generated in the `.docx` file:

<img src="https://mintcdn.com/saturn-899dbd9c/mYXk5ovfKkfTcqgJ/images/example-meeting-note-doc.png?fit=max&auto=format&n=mYXk5ovfKkfTcqgJ&q=85&s=cb09899bf68646e228a6a17bc15d5aad" alt="Example Meeting Notes" width="1434" height="1856" data-path="images/example-meeting-note-doc.png" />
