# Export translations (API V1)

Request an export of a project, wait until it has finished and download the ZIP file.

## Request the export

`POST /v1/{workspaceUrl}/projects/{projectUrl}/exports` starts an export; LingoHub writes the files in the background. The body is optional: without it, the export contains every file in every language.

- `filePaths` limits the export to certain files. A path names a file in all its languages, so it carries the placeholder `%{locale}` where the language stands, for example `config/locales/%{locale}/messages.yml`. Replace the path of the sample with a path of your project; [Get project resource file status](/reference/v1/operations/v1projectgetprojectstatus.md) returns the paths in `filePathWithLocalePlaceholder`. A path the project doesn't have returns `404`.
- `iso2Slugs` limits the export to certain languages.

The response carries the `id` of the export. Its `status` starts as `SCHEDULED`.

**Shell**

```shell
# Step 1: Request the export
EXPORT=$(curl -sS --fail-with-body -X POST "$API/exports" \
  -H "$AUTH" \
  -H "Content-Type: application/json" \
  -d '{
    "filePaths": ["config/locales/%{locale}/messages.yml"],
    "iso2Slugs": ["en", "de"]
  }') || { echo "$EXPORT"; exit 1; }
EXPORT_ID=$(echo "$EXPORT" | jq -r '.id')
echo "Export requested: $EXPORT_ID"
```

**Python**

```python
# Step 1: Request the export
response = session.post(
    f"{API}/exports",
    json={
        "filePaths": ["config/locales/%{locale}/messages.yml"],
        "iso2Slugs": ["en", "de"],
    },
)
response.raise_for_status()
export_id = response.json()["id"]
print(f"Export requested: {export_id}")
```

## Wait for the export

Read the export with `GET .../exports/{id}` until its `status` is no longer `NEW`, `SCHEDULED` or `PROCESSING`. The final statuses are `SUCCESS`, `ERROR` and `SKIPPED`.

**Shell**

```shell
# Step 2: Wait until the export has finished
while true; do
  EXPORT=$(curl -sS --fail-with-body "$API/exports/$EXPORT_ID" -H "$AUTH") || { echo "$EXPORT"; exit 1; }
  STATUS=$(echo "$EXPORT" | jq -r '.status')
  case "$STATUS" in
    NEW|SCHEDULED|PROCESSING) sleep 2 ;;
    *) break ;;
  esac
done
echo "Export $EXPORT_ID finished: $STATUS"
```

**Python**

```python
# Step 2: Wait until the export has finished
while True:
    response = session.get(f"{API}/exports/{export_id}")
    response.raise_for_status()
    export = response.json()
    if export["status"] not in ("NEW", "SCHEDULED", "PROCESSING"):
        break
    time.sleep(2)
print(f"Export {export_id} finished: {export['status']}")
```

## Download the ZIP file

Only an export with the status `SUCCESS` has a file. `downloadUrl` is a pre-signed link to the ZIP file that is valid for 24 hours; every read of the export returns a fresh link. If the export failed, `errorDetails` says why.

**Shell**

```shell
# Step 3: Download the ZIP file
if [ "$STATUS" != "SUCCESS" ]; then
  echo "$EXPORT" | jq -r '.errorDetails'
  exit 1
fi
curl -sS -o export.zip "$(echo "$EXPORT" | jq -r '.downloadUrl')"
```

**Python**

```python
# Step 3: Download the ZIP file
if export["status"] != "SUCCESS":
    sys.exit(export["errorDetails"] or "The export produced no file.")
with requests.get(export["downloadUrl"], stream=True) as download:
    download.raise_for_status()
    with open("export.zip", "wb") as file:
        for chunk in download.iter_content(chunk_size=65536):
            file.write(chunk)
```

## Complete example

**Shell**

```shell
# Requires: LINGOHUB_API_KEY, WORKSPACE_URL and PROJECT_URL (the two slugs of the project's API URL)
API="https://api.lingohub.com/v1/$WORKSPACE_URL/projects/$PROJECT_URL"
AUTH="Authorization: Bearer $LINGOHUB_API_KEY"

# Step 1: Request the export
EXPORT=$(curl -sS --fail-with-body -X POST "$API/exports" \
  -H "$AUTH" \
  -H "Content-Type: application/json" \
  -d '{
    "filePaths": ["config/locales/%{locale}/messages.yml"],
    "iso2Slugs": ["en", "de"]
  }') || { echo "$EXPORT"; exit 1; }
EXPORT_ID=$(echo "$EXPORT" | jq -r '.id')
echo "Export requested: $EXPORT_ID"

# Step 2: Wait until the export has finished
while true; do
  EXPORT=$(curl -sS --fail-with-body "$API/exports/$EXPORT_ID" -H "$AUTH") || { echo "$EXPORT"; exit 1; }
  STATUS=$(echo "$EXPORT" | jq -r '.status')
  case "$STATUS" in
    NEW|SCHEDULED|PROCESSING) sleep 2 ;;
    *) break ;;
  esac
done
echo "Export $EXPORT_ID finished: $STATUS"

# Step 3: Download the ZIP file
if [ "$STATUS" != "SUCCESS" ]; then
  echo "$EXPORT" | jq -r '.errorDetails'
  exit 1
fi
curl -sS -o export.zip "$(echo "$EXPORT" | jq -r '.downloadUrl')"
```

**Python**

```python
# Requires: LINGOHUB_API_KEY, WORKSPACE_URL and PROJECT_URL (the two slugs of the project's API URL)
import os
import sys
import time

import requests

API = f"https://api.lingohub.com/v1/{os.environ['WORKSPACE_URL']}/projects/{os.environ['PROJECT_URL']}"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['LINGOHUB_API_KEY']}"

# Step 1: Request the export
response = session.post(
    f"{API}/exports",
    json={
        "filePaths": ["config/locales/%{locale}/messages.yml"],
        "iso2Slugs": ["en", "de"],
    },
)
response.raise_for_status()
export_id = response.json()["id"]
print(f"Export requested: {export_id}")

# Step 2: Wait until the export has finished
while True:
    response = session.get(f"{API}/exports/{export_id}")
    response.raise_for_status()
    export = response.json()
    if export["status"] not in ("NEW", "SCHEDULED", "PROCESSING"):
        break
    time.sleep(2)
print(f"Export {export_id} finished: {export['status']}")

# Step 3: Download the ZIP file
if export["status"] != "SUCCESS":
    sys.exit(export["errorDetails"] or "The export produced no file.")
with requests.get(export["downloadUrl"], stream=True) as download:
    download.raise_for_status()
    with open("export.zip", "wb") as file:
        for chunk in download.iter_content(chunk_size=65536):
            file.write(chunk)
```

## Responses

```json
{
  "id": "reg_18USq6822XIv-19847171",
  "status": "SCHEDULED",
  "resourceExports": [],
  "errorDetails": null,
  "filePath": null,
  "downloadUrl": null,
  "triggerType": "API_V1",
  "createdAt": "2026-01-15T10:30:00.000+00:00"
}
```

```json
{
  "id": "reg_18USq6822XIv-19847171",
  "status": "SUCCESS",
  "resourceExports": [
    {
      "filePath": "config/locales/en/messages.yml",
      "iso2Slug": "en",
      "status": "SUCCESS",
      "downloadUrl": "https://lingohub-...s3.amazonaws.com/..."
    },
    {
      "filePath": "config/locales/de/messages.yml",
      "iso2Slug": "de",
      "status": "SUCCESS",
      "downloadUrl": "https://lingohub-...s3.amazonaws.com/..."
    }
  ],
  "errorDetails": null,
  "filePath": "files.zip",
  "downloadUrl": "https://lingohub-...s3.amazonaws.com/...",
  "triggerType": "API_V1",
  "createdAt": "2026-01-15T10:30:00.000+00:00"
}
```
