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

# Introduction

> Upload, extract, and query PDF documents via the Okra API.

## Base URL

All API requests use the following base URL:

```
https://api.okra.app
```

## Authentication

Include your API key in every request:

```bash theme={null}
# Bearer token (recommended)
Authorization: Bearer okra_YOUR_KEY

# Header
x-api-key: okra_YOUR_KEY
```

Get your API key at [app.okrapdf.com/settings/api-keys](https://app.okrapdf.com/settings/api-keys).

## Quick example

```bash theme={null}
# 1. Upload a PDF
curl -X POST https://api.okra.app/v1/documents \
  -H "Authorization: Bearer okra_YOUR_KEY" \
  -F file=@report.pdf

# Response: {"id": "doc-abc123", "status": "queued"}

# 2. Check status
curl https://api.okra.app/v1/documents/doc-abc123 \
  -H "Authorization: Bearer okra_YOUR_KEY"

# 3. Get full markdown
curl https://api.okra.app/v1/documents/doc-abc123/full.md

# 4. Chat with the document
curl -X POST https://api.okra.app/v1/documents/doc-abc123/chat/completions \
  -H "Authorization: Bearer okra_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Summarize this document"}]}'
```

## Core endpoints

| Method | Path                                     | Description                   |
| ------ | ---------------------------------------- | ----------------------------- |
| POST   | `/v1/documents`                          | Upload a document (multipart) |
| POST   | `/v1/documents/{id}/upload-url`          | Upload from a URL             |
| GET    | `/v1/documents/{id}`                     | Get document status           |
| GET    | `/v1/documents/{id}/full.md`             | Full document as markdown     |
| GET    | `/v1/documents/{id}/full.json`           | Full document as JSON         |
| GET    | `/v1/documents/{id}/pages/{n}`           | Get page content              |
| GET    | `/v1/documents/{id}/pages/{n}/image.png` | Get page image                |
| GET    | `/v1/documents/{id}/entities/tables`     | List extracted tables         |
| POST   | `/v1/documents/{id}/structured-output`   | Extract structured data       |
| POST   | `/v1/documents/{id}/chat/completions`    | Chat with a document          |
| DELETE | `/v1/documents/{id}`                     | Delete a document             |
| GET    | `/v1/documents/{id}/original.pdf`        | Download original PDF         |
| GET    | `/exports/{id}/{format}`                 | Export as markdown/xlsx/docx  |

## Collections

| Method | Path                          | Description            |
| ------ | ----------------------------- | ---------------------- |
| GET    | `/v1/collections`             | List collections       |
| POST   | `/v1/collections`             | Create a collection    |
| POST   | `/v1/collections/{id}/query`  | Query across documents |
| GET    | `/v1/collections/{id}/export` | Export collection      |

## Data API (public, no auth)

| Method | Path                                     | Description           |
| ------ | ---------------------------------------- | --------------------- |
| GET    | `/v1/filings`                            | List public filings   |
| GET    | `/v1/filings/{exchange}/{ticker}/{slug}` | Get a specific filing |
| GET    | `/v1/companies`                          | List companies        |
| GET    | `/v1/companies/{exchange}/{ticker}`      | Get company details   |

## Response format

All responses return JSON with consistent error formatting:

```json theme={null}
// Success
{
  "id": "doc-abc123",
  "status": "completed",
  ...
}

// Error
{
  "error": {
    "code": "BAD_REQUEST",
    "message": "Human-readable description of the problem"
  }
}
```
