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

# API Reference

> Complete API reference for Agent Office - AI-powered document editing API

## Welcome to Agent Office API

Agent Office API allows you to programmatically edit Microsoft Word and PDF documents using AI. Upload documents, apply edits via natural language instructions, and download the modified files.

### Base URL

All API requests should be made to:

```
https://api.agentoffice.dev
```

## Authentication

All API endpoints require authentication using a Bearer token. You can generate API keys from your [Agent Office Dashboard](https://agentoffice.dev/dashboard).

<Note>
  Keep your API keys secure and never share them publicly. API keys should be
  stored as environment variables.
</Note>

### Using Your API Key

Include your API key in the `Authorization` header of every request:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

### Example Authentication

<CodeGroup>
  ```javascript JavaScript (Fetch) theme={null}
  const response = await fetch("https://api.agentoffice.dev/v1/documents/", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "multipart/form-data",
    },
    body: formData,
  });
  ```

  ```python Python (Requests) theme={null}
  import requests

  headers = {
      'Authorization': 'Bearer YOUR_API_KEY'
  }

  response = requests.post(
      'https://api.agentoffice.dev/v1/documents/',
      headers=headers,
      files=files
  )
  ```

  ```python Python SDK theme={null}
  from agent_office import AgentOffice

  client = AgentOffice(api_key="YOUR_API_KEY")

  # All API calls are automatically authenticated
  doc = client.documents.create(file="document.docx")
  ```
</CodeGroup>

## Request Latency

Most document edits complete in under 5 seconds. Response times vary based on document complexity and edit instructions.

<Tip>
  **Pro and Enterprise users** benefit from dedicated infrastructure with faster
  request processing and priority queue handling for optimal performance.
</Tip>

You can monitor your request performance under [usage](https://agentoffice.dev/dashboard/usage).

## Error Handling

The API uses standard HTTP status codes:

| Status Code | Description                                       |
| ----------- | ------------------------------------------------- |
| 200         | Success                                           |
| 400         | Bad Request - Check your request parameters       |
| 401         | Unauthorized - Invalid or missing API key         |
| 403         | Forbidden - API key doesn't have access           |
| 404         | Not Found - Resource doesn't exist                |
| 422         | Validation Error - Request body validation failed |
| 500         | Server Error - Something went wrong on our end    |

## API Workflow

1. **Upload Document** - Upload a Word (.docx) or PDF file to create a document
2. **Apply Edits** - Send natural language instructions to edit the document
3. **Download Result** - Get a presigned URL to download the edited document

<Tip>
  Documents are automatically stored for 1 hour (configurable) and the TTL is
  refreshed after each edit.
</Tip>

## Supported File Types

* Microsoft Word (.docx)
* PDF (.pdf)
* Maximum file size: 10MB

## Getting Started

Ready to start? Check out our endpoint documentation:

<CardGroup cols={2}>
  <Card title="Upload Document" icon="cloud-arrow-up" href="/api-reference/documents/upload">
    Upload a Word or PDF document
  </Card>

  <Card title="Edit Document" icon="wand-magic-sparkles" href="/api-reference/documents/edit">
    Apply AI-powered edits to your document
  </Card>

  <Card title="Download Document" icon="download" href="/api-reference/documents/download">
    Get a presigned URL to download your document
  </Card>

  <Card title="Read as Markdown" icon="markdown" href="/api-reference/documents/markdown">
    Extract document content as markdown
  </Card>
</CardGroup>
