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

# Translate a Document

> Translate TXT, DOCX, and searchable PDF documents while retaining their source format

Translate one document into a target language. The response is a downloadable file in the same format as the upload: TXT returns TXT, DOCX returns DOCX, and PDF returns PDF.

```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
curl -X POST https://api.case.dev/translate/v1/document \
  -H "Authorization: Bearer sk_case_YOUR_API_KEY" \
  -F "file=@statement.docx" \
  -F "target=es" \
  --output statement-es.docx
```

## Request

Send a `multipart/form-data` request with these fields:

| Field    | Type   | Required | Description                                                                        |
| -------- | ------ | -------- | ---------------------------------------------------------------------------------- |
| `file`   | file   | Yes      | One TXT, DOCX, or searchable PDF file, up to 20MB.                                 |
| `target` | string | Yes      | Target BCP-47 language code, such as `es` or `fr-CA`.                              |
| `source` | string | No       | Source language code. When omitted, the source language is detected automatically. |

## Response

The response body contains the translated file bytes. Use the `Content-Type` and `Content-Disposition` headers to store the result. When the source language was detected, the response also includes `X-Detected-Source-Language`.

```typescript title="TypeScript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
const form = new FormData()
form.append('file', file)
form.append('target', 'es')

const response = await fetch('https://api.case.dev/translate/v1/document', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.CASEDEV_API_KEY}` },
  body: form,
})

if (!response.ok) throw new Error(`Translation failed: ${response.status}`)
const translatedDocument = await response.blob()
```

## Pricing

Pricing is passed through at the Google Cloud Translation provider rate with no Case.dev markup. TXT files are billed by source character. DOCX and PDF files are billed at \$0.08 per source page.

## Format behavior

* TXT content is translated as UTF-8 text. The TXT limit is 100,000 characters.
* DOCX and PDF files use Google Cloud Document Translation to retain much of the source layout and formatting.
* PDF input must contain searchable, selectable text. Scanned PDFs are not accepted by this endpoint.
* Photos and other non-text document elements are retained, but text embedded inside an image is not translated.
* Complex PDF layouts, overlapping text, and DOCX text boxes may not translate or render perfectly. Review the output before relying on it.

<Info>Machine translation can contain errors and is not a certified legal translation.</Info>
