# Upload a document

> POST /api/v1/documents: Upload a document.

`POST https://appliflo.com/api/v1/documents`

Send your API key in the `Authorization: Bearer` header. Every response is JSON: `{ success, data, error }`.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header | no | A client-generated key scoping this request as a retry of a prior identical request. A replay within 24h returns the first response instead of repeating the side effect (e.g. a second send). The key is bound to the request it was first used with: the same key with a different body or target is refused (422, code idempotency_key_reused) |

## Request body (multipart/form-data)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | string | yes | Format: binary |
| `name` | string | no |  |

## Request body (application/json)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | Up to 255 characters |
| `content_base64` | string | no | The PDF or DOCX, base64-encoded |
| `file_url` | string | no | A public https:// link to the file, downloaded by AppliFlo: no private or internal addresses, at most 3 redirects, 20 MB and 20 seconds. The type is read from the bytes, never the link. Up to 2048 characters |

## Responses

| Status | Description |
| --- | --- |
| 201 | Document created. |
| 401 | Missing or invalid API key, or `api_key_expired` for a key past its expiry. |
| 403 | The API key's workspace does not have access to this resource, or `insufficient_scope` (with `required_scope`) for a key without the scope this route needs. |
| 404 | Resource not found in this workspace. |
| 422 | Request failed validation. |
| 500 | Internal error. |

## 201 response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | true | yes |  |
| `data` | object | yes |  |
| `data.id` | string | yes |  |
| `data.name` | string | yes |  |
| `data.status` | string | yes |  |

See also: [Errors](https://dev.appliflo.com/guides/errors), [Rate limits](https://dev.appliflo.com/guides/rate-limits), [Idempotency](https://dev.appliflo.com/guides/idempotency).
