# List, Fetch, and Download Documents

Once a briefing document has been generated successfully, you can manage it through the dedicated `/documents` endpoints.

## 1. List Documents

```bash
curl -X GET "https://api.autocontentapi.com/documents/get?page=1&pageSize=20" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Example response:

```json
{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": "briefing_doc",
      "format": "pdf",
      "title": "Briefing Document: AI Procurement in Healthcare",
      "createdOn": "2026-03-11T19:12:00Z",
      "status": 100
    }
  ],
  "totalCount": 1,
  "page": 1,
  "pageSize": 20,
  "totalPages": 1
}
```

## 2. Fetch One Document

```bash
curl -X GET "https://api.autocontentapi.com/documents/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

For `format: "pdf"`, the response includes `url`. For `format: "text"` or `format: "html"`, the response includes `content`.

## 3. Download the Stored Result

```bash
curl -L "https://api.autocontentapi.com/documents/550e8400-e29b-41d4-a716-446655440000/download" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -o briefing-document.pdf
```

The download endpoint returns the stored result using the correct file extension and content type.

## 4. Poll with `/content/Status/{id}` While Waiting

`/documents/{id}` only returns a result after the document has been generated successfully. While the request is still running, use `/content/Status/{id}`:

```bash
curl -X GET "https://api.autocontentapi.com/content/Status/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

**Tips**

* Treat `/content/Status/{id}` as the job-status API.
* Treat `/documents/get` and `/documents/{id}` as the document library API.
* For `pdf`, you can either read `document_url` from the status response or `url` from `/documents/{id}`.

## Try it in code

* [C#](https://docs.autocontentapi.com/code-samples/documents/csharp/retrieve-and-download)
* [Node.js](https://docs.autocontentapi.com/code-samples/documents/nodejs/retrieve-and-download)
* [Java](https://docs.autocontentapi.com/code-samples/documents/java/retrieve-and-download)
* [PHP](https://docs.autocontentapi.com/code-samples/documents/php/retrieve-and-download)
* [Python](https://docs.autocontentapi.com/code-samples/documents/python/retrieve-and-download)
