# Delete Lilt Create content
Source: https://support.lilt.com/api-reference/create/delete-lilt-create-content
/api-reference/openapi-bundled.yaml delete /v2/create/{contentId}
Delete a piece of Lilt Create content.
Example CURL:
```bash
curl -X DELETE 'https://api.lilt.com/v2/create/1234?key=API_KEY'
```
# Generate new Lilt Create content
Source: https://support.lilt.com/api-reference/create/generate-new-lilt-create-content
/api-reference/openapi-bundled.yaml post /v2/create
Generate new Lilt Create content with the given parameters.
Example CURL:
```bash
curl -X POST 'https://api.lilt.com/v2/create?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"language":"en-US",
"template":"blog-post",
"templateParams":{
"contentLength":"100",
"language":"en-US",
"sections":[],
"summary":"a blog post about hiking"
},
"preferences":{"tone":"formal","styleguide":""}
}'
```
# Get Lilt Create content
Source: https://support.lilt.com/api-reference/create/get-lilt-create-content
/api-reference/openapi-bundled.yaml get /v2/create
Get a list of all content that has been generated by Lilt Create.
Example CURL:
```bash
curl -X GET 'https://api.lilt.com/v2/create?key=API_KEY'
```
# Get Lilt Create content by ID.
Source: https://support.lilt.com/api-reference/create/get-lilt-create-content-by-id
/api-reference/openapi-bundled.yaml get /v2/create/{contentId}
Get Lilt Create content by ID.
Example CURL:
```bash
curl -X GET 'https://api.lilt.com/v2/create/1234?key=API_KEY'
```
# Update Lilt Create content
Source: https://support.lilt.com/api-reference/create/update-lilt-create-content
/api-reference/openapi-bundled.yaml put /v2/create/{contentId}
Update a piece of Lilt Create content.
Example CURL:
```bash
curl -X PUT 'https://api.lilt.com/v2/create/1234?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"language":"de-DE"}'
```
# Download a Document
Source: https://support.lilt.com/api-reference/documents/download-a-document
/api-reference/openapi-bundled.yaml get /v2/documents/files
Export a Document that has been translated in the Lilt web application.
Any Document can be downloaded in XLIFF 1.2 format, or can be retrieved in its original uploaded format by setting `is_xliff=false`.
This endpoint will fail if either (a) export or (b) pre-translation operations are in-progress. The status of those operations can be determined by retrieving the Document resource.
Example CURL command:
```bash
curl -X GET https://api.lilt.com/v2/documents/files?key=API_KEY&id=274 -o from_lilt.xliff
```
# Pretranslate Documents
Source: https://support.lilt.com/api-reference/documents/pretranslate-documents
/api-reference/openapi-bundled.yaml post /v2/documents/pretranslate
Pretranslate one or more Documents using translation memory (TM) and,
optionally, machine translation (MT). Only documents that are not
currently importing/exporting and are not already pretranslating will
be pretranslated; the response always reflects the current state of
every requested Document id, whether or not it was eligible.
This is an asynchronous operation. The endpoint returns immediately
with a `202` response once pretranslation has been queued; poll the
Document resource (or the `is_pretranslating` / `status.pretranslation`
fields it returns) to see when pretranslation has finished.
This endpoint is subject to a per-organization rate limit. See the
[API Rate Limits guide](/developers/guides/rate-limits) for details on
how to read `429` responses and batch requests efficiently by passing
multiple document ids in a single call.
Example CURL:
```bash
curl -X POST 'https://api.lilt.com/v2/documents/pretranslate?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"id": [274, 275], "mode": "TM+MT", "auto_accept": true}'
```
# Upload a File
Source: https://support.lilt.com/api-reference/documents/upload-a-file
/api-reference/openapi-bundled.yaml post /v2/documents/files
Create a Document from a file in any of the formats [documented in our knowledge base](/kb/supported-file-formats).
Request parameters should be passed as JSON object with the header field `LILT-API`.
File names in the header can only contain [US-ASCII characters](https://en.wikipedia.org/wiki/ASCII). File names with characters outside of US-ASCII should be [URI encoded](https://en.wikipedia.org/wiki/Percent-encoding) or transliterated to US-ASCII strings.
Example CURL command:
```bash
curl -X POST https://api.lilt.com/v2/documents/files?key=API_KEY \
--header "LILT-API: {\"name\": \"introduction.xliff\",\"pretranslate\": \"tm+mt\",\"project_id\": 9}" \
--header "Content-Type: application/octet-stream" \
--data-binary @Introduction.xliff
```
# Retrieve Domains
Source: https://support.lilt.com/api-reference/domains/retrieve-domains
/api-reference/openapi-bundled.yaml get /v3/domains
Retrieve a list of Domains associated with the Organization's API key.
Each Domain contains potentially 4 Arrays related to the Domain these are as follows:
- models - the list of models associated with the Domain
- filterConfigs - the list of filterConfigs associated with the Domain
- domainMetadata - the list of Domain specific options that have been configured for this domain.
# Add Label to File
Source: https://support.lilt.com/api-reference/files/add-label-to-file
/api-reference/openapi-bundled.yaml post /v2/files/labels
Add a label to a File.
Example CURL:
```bash
curl -X POST 'https://api.lilt.com/v2/files/labels?key=API_KEY&id=1'
--header 'Content-Type: application/json' \
--data-raw '{
"name": "label_name"
}'
```
# Delete a File
Source: https://support.lilt.com/api-reference/files/delete-a-file
/api-reference/openapi-bundled.yaml delete /v2/files
Delete a File.
Example CURL command:
```bash
curl -X DELETE https://api.lilt.com/v2/files?key=API_KEY&id=123
```
# Download file
Source: https://support.lilt.com/api-reference/files/download-file
/api-reference/openapi-bundled.yaml get /v2/files/download
Download a File.
Example CURL:
```bash
curl -X GET 'https://api.lilt.com/v2/files/download?key=API_KEY&id=1'
```
# Remove Label from File
Source: https://support.lilt.com/api-reference/files/remove-label-from-file
/api-reference/openapi-bundled.yaml delete /v2/files/labels
Remove a label from a File.
Example CURL:
```bash
curl -X DELETE 'https://api.lilt.com/v2/files/labels?key=API_KEY&id=1&name=label_name'
```
# Retrieve a File
Source: https://support.lilt.com/api-reference/files/retrieve-a-file
/api-reference/openapi-bundled.yaml get /v2/files
Retrieves one or more files available to your user. Files are not associated with a project or a memory. They are unprocessed and can be used later in the project/document creation workflow step.
To retrieve a specific file, specify the id request parameter. To retrieve all files, omit the id request parameter.
Example CURL command:
```bash
curl -X GET https://api.lilt.com/v2/files?key=API_KEY&id=274
```
# Upload a File
Source: https://support.lilt.com/api-reference/files/upload-a-file
/api-reference/openapi-bundled.yaml post /v2/files
Upload a File in any of the formats [documented in our knowledge
base](/kb/supported-file-formats).
Request parameters should be passed in as query string parameters.
Example CURL command:
```bash
curl -X POST https://api.lilt.com/v2/files?key=API_KEY&name=en_US.json \
--header "Content-Type: application/octet-stream" \
--data-binary @en_US.json
```
Calls to GET /files are used to monitor the language detection results. The API response will be augmented to include detected language and confidence score.
The language detection will complete asynchronously. Prior to completion, the `detected_lang` value will be `zxx`, the reserved ISO 639-2 code for "No linguistic content/not applicable".
If the language can not be determined, or the detection process fails, the `detected_lang` field will return `und`, the reserved ISO 639-2 code for undetermined language, and the `detected_lang_confidence` score will be `0`.
# Archive a Job
Source: https://support.lilt.com/api-reference/jobs/archive-a-job
/api-reference/openapi-bundled.yaml post /v2/jobs/{jobId}/archive
Set job to archived, unassign all linguists and archive all projects and documents inside the job.
It will return the archived job.
Example CURL command:
```bash
curl -X POST 'https://api.lilt.com/v2/jobs/{id}/archive?key=API_KEY'
```
# Create a Job
Source: https://support.lilt.com/api-reference/jobs/create-a-job
/api-reference/openapi-bundled.yaml post /v2/jobs
Create a Job. A Job is a collection of Projects.
A Job will contain multiple projects, based on the language pair.
A Project is associated with exactly one Memory.
Jobs appear in the Jobs dashboard of the web app.
Example CURL command:
```bash
curl -X POST 'https://api.lilt.com/v2/jobs?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "test job",
"fileIds": [5009, 5010, 5011],
"due": "2022-05-05T10:56:44.985Z",
"srcLang": "en",
"srcLocale": "US",
"languagePairs": [
{ "memoryId": 3121, "trgLang": "de" },
{ "memoryId": 2508, "trgLang": "fr" },
{ "memoryId": 3037, "trgLang": "zh" }
]
}'
```
# Delete a Job
Source: https://support.lilt.com/api-reference/jobs/delete-a-job
/api-reference/openapi-bundled.yaml delete /v2/jobs/{jobId}
Delete a job, deletes all projects and documents in the job, deletes all the segments from all the job's translation memories.
Example CURL command:
```bash
curl -X DELETE 'https://api.lilt.com/v2/jobs/{id}?key=API_KEY'
```
# Deliver a Job
Source: https://support.lilt.com/api-reference/jobs/deliver-a-job
/api-reference/openapi-bundled.yaml post /v2/jobs/{jobId}/deliver
Set the job state to delivered and set all the projects in the job to done
It will return the delivered job.
Example CURL command:
```bash
curl -X POST 'https://api.lilt.com/v2/jobs/{id}/deliver?key=API_KEY'
```
# Download a Job
Source: https://support.lilt.com/api-reference/jobs/download-a-job
/api-reference/openapi-bundled.yaml get /v2/jobs/{jobId}/download
Make sure you have exported a job with the same id before using this api.
Downloading files requires the exported job `id` in the param.
Example CURL command:
```bash
curl -X GET 'https://api.lilt.com/v2/jobs/{id}/download?key=API_KEY'
```
# Export a Job
Source: https://support.lilt.com/api-reference/jobs/export-a-job
/api-reference/openapi-bundled.yaml get /v2/jobs/{jobId}/export
Prepare job files for download.
To export translated documents from the job use the query parameter `type=files`:
Example CURL command:
```bash
curl -X GET 'https://api.lilt.com/v2/jobs/{id}/export?key=API_KEY&type=files'
```
To export job memories use the query parameter `type=memory`.
The status of the export can be checked by requesting the job `GET /jobs/:jobId`, `job.isProcessing` will be `1` while in progress,
`0` when idle and `-2` when the export failed.
# Reactivate a Job
Source: https://support.lilt.com/api-reference/jobs/reactivate-a-job
/api-reference/openapi-bundled.yaml post /v2/jobs/{jobId}/reactivate
Set the job state to active. Does not change the state of projects associated with the given job.
It will return the reactivated job.
Example CURL command:
```bash
curl -X POST 'https://api.lilt.com/v2/jobs/{id}/reactivate?key=API_KEY'
```
# Retrieve a Job
Source: https://support.lilt.com/api-reference/jobs/retrieve-a-job
/api-reference/openapi-bundled.yaml get /v2/jobs/{jobId}
Retrieves a job data along with stats. To retrieve a specific job, you will need the job `id` in the url path.
Example CURL command:
```bash
curl -X GET 'https://api.lilt.com/v2/jobs/{id}?key=API_KEY'
```
# Retrieve all Jobs
Source: https://support.lilt.com/api-reference/jobs/retrieve-all-jobs
/api-reference/openapi-bundled.yaml get /v2/jobs
Get all Jobs within a given offset and limit. You can retrieve jobs from your account using the above API.
Example CURL command:
```bash
curl -X GET 'https://api.lilt.com/v2/jobs?key=API_KEY&isArchived=false'
```
# Retrieve Job Leverage Stats
Source: https://support.lilt.com/api-reference/jobs/retrieve-job-leverage-stats
/api-reference/openapi-bundled.yaml get /v2/jobs/{jobId}/stats
Get the TM leverage stats for the job (new/exact/fuzzy matches).
Example CURL command:
```bash
curl -X GET 'https://api.lilt.com/v2/jobs/{id}/stats?key=API_KEY'
```
# Unarchive a Job
Source: https://support.lilt.com/api-reference/jobs/unarchive-a-job
/api-reference/openapi-bundled.yaml post /v2/jobs/{jobId}/unarchive
Set job to unarchived, the job will move to active status.
Example CURL command:
```bash
curl -X POST 'https://api.lilt.com/v2/jobs/{id}/unarchive?key=API_KEY'
```
# Update a Job
Source: https://support.lilt.com/api-reference/jobs/update-a-job
/api-reference/openapi-bundled.yaml put /v2/jobs/{jobId}
Updates a job with the new job properties. To update a specific job, you will need the job `id` in the url path.
You can update job's name and due date by passing the property and new value in the body.
Example CURL command:
```bash
curl -X PUT 'https://api.lilt.com/v2/jobs/{id}?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "test job",
"due": "2022-05-05T10:56:44.985Z"
}'
```
# Retrieve supported languages
Source: https://support.lilt.com/api-reference/languages/retrieve-supported-languages
/api-reference/openapi-bundled.yaml get /v2/languages
Get a list of supported languages.
# Create a Memory
Source: https://support.lilt.com/api-reference/memories/create-a-memory
/api-reference/openapi-bundled.yaml post /v2/memories
Create a new Memory. A Memory is a container that collects source/target
sentences for a specific language pair (e.g., English>French). The data
in the Memory is used to train the MT system, populate the TM, and
update the lexicon. Memories are private to your account - the data is
not shared across users - unless you explicitly share a Memory with your
team (via web app only).
Refer
to our KB for a more detailed description.
# Delete a Memory
Source: https://support.lilt.com/api-reference/memories/delete-a-memory
/api-reference/openapi-bundled.yaml delete /v2/memories
Delete a Memory.
# Delete a segment from a memory.
Source: https://support.lilt.com/api-reference/memories/delete-a-segment-from-a-memory
/api-reference/openapi-bundled.yaml delete /v2/memories/segment
Delete a segment from a memory.
```bash
curl -X DELETE https://api.lilt.com/v2/memories/segment?key=API_KEY&id=ID&segment_id=$SEGMENT_ID
```
# File import for a Memory
Source: https://support.lilt.com/api-reference/memories/file-import-for-a-memory
/api-reference/openapi-bundled.yaml post /v2/memories/import
Imports common translation memory or termbase file formats to a specific LILT memory. Currently supported file formats are `*.tmx`, `*.sdltm`, `*.sdlxliff`(With custom Filters), '*.xliff', and `*.tmq` for TM data; `*.csv` and `*.tbx` for termbase data. Request parameters should be passed as JSON object with the header field `LILT-API`.
Example CURL command to upload a translation memory file named `my_memory.sdltm` in the current working directory:
```bash
curl -X POST https://api.lilt.com/v2/memories/import?key=API_KEY \
--header "LILT-API: {\"name\": \"my_memory.sdltm\",\"memory_id\": 42}" \
--header "Content-Type: application/octet-stream" \
--data-binary @my_memory.sdltm
```
Example CURL command to upload a translation memory file named `my_memory.sdlxliff` in the current working directory, with Custom Filters based on SDLXLIFF fields, conf_name which maps to, percentage, and whether we should ignore unlocked segments.
```bash
curl -X POST https://api.lilt.com/v2/memories/import?key=API_KEY \
--header "LILT-API: {\"name\": \"my_memory.sdlxliff\",\"memory_id\": 12,\"sdlxliff_filters\":[{\"conf_name\": \"Translated\", \"percentage\": 100, \"allow_unlocked\": false}]"}" \
--header "Content-Type: application/octet-stream" \
--data-binary @my_memory.sdlxliff
```
# Query a Memory
Source: https://support.lilt.com/api-reference/memories/query-a-memory
/api-reference/openapi-bundled.yaml get /v2/memories/query
Perform a translation memory query.
# Retrieve a Memory
Source: https://support.lilt.com/api-reference/memories/retrieve-a-memory
/api-reference/openapi-bundled.yaml get /v2/memories
Retrieve a Memory. If you cannot access the Memory (401 error) please check permissions (e.g. in case you created the Memory via the web app with a different account you may have to explicitly share that Memory).
# Termbase download for a Memory
Source: https://support.lilt.com/api-reference/memories/termbase-download-for-a-memory
/api-reference/openapi-bundled.yaml get /v2/memories/termbase/download
Downloads the termbase export for the given memory as a CSV file.
Ensure you first call the `/2/memories/termbase/export` endpoint to
start the export process before you try to download it.
```bash
curl -X GET https://api.lilt.com/v2/memories/termbase/download?key=API_KEY&id=ID
```
# Termbase export for a Memory
Source: https://support.lilt.com/api-reference/memories/termbase-export-for-a-memory
/api-reference/openapi-bundled.yaml post /v2/memories/termbase/export
Exports the termbase entries for the given memory into a CSV file.
Calling this endpoint will begin the export process in the background.
Check that the processing is complete by polling the `GET /2/memories`
endpoint. When the `is_processing` value is 0 then call the
`POST /2/memories/termbase/download` endpoint.
```bash
curl -X POST https://api.lilt.com/v2/memories/termbase/export?key=API_KEY&id=ID
```
# Update the name of a Memory
Source: https://support.lilt.com/api-reference/memories/update-the-name-of-a-memory
/api-reference/openapi-bundled.yaml put /v2/memories
Update a Memory.
# Create a Project
Source: https://support.lilt.com/api-reference/projects/create-a-project
/api-reference/openapi-bundled.yaml post /v2/projects
Create a Project. A Project is a collection of Documents.
A Project is associated with exactly one Memory.
Projects appear in the dashboard of the web app.
# Delete a Project
Source: https://support.lilt.com/api-reference/projects/delete-a-project
/api-reference/openapi-bundled.yaml delete /v2/projects
Delete a Project.
# Retrieve a Project
Source: https://support.lilt.com/api-reference/projects/retrieve-a-project
/api-reference/openapi-bundled.yaml get /v2/projects
Retrieves one or more projects, including the documents associated with each project. Retrieving a project is the most efficient way to retrieve a single project, multiple projects or a list of all available projects.
To retrieve a specific project, specify the `id` request parameter or you can retrieve multiple projects by adding comma (,) between ids eg. `?id=1234,5678`. To retrieve all projects, omit the `id` request parameter. To limit the retrieved projects to those with a particular source language or target language, specify the corresponding ISO 639-1 language codes in the `srclang` and `trglang` request parameters, respectively.
# Create a Segment
Source: https://support.lilt.com/api-reference/segments/create-a-segment
/api-reference/openapi-bundled.yaml post /v2/segments
Create a Segment and add it to a Memory or a Document. A Segment is a source/target
pair that is used to train the machine translation system and populate
the translation memory.
The maximum source length is 5,000 characters.
# Delete a Segment
Source: https://support.lilt.com/api-reference/segments/delete-a-segment
/api-reference/openapi-bundled.yaml delete /v2/segments
Delete a Segment from memory. This will not delete a segment from a document.
# Retrieve a Segment
Source: https://support.lilt.com/api-reference/segments/retrieve-a-segment
/api-reference/openapi-bundled.yaml get /v2/segments
Retrieve a Segment.
# Tag a Segment
Source: https://support.lilt.com/api-reference/segments/tag-a-segment
/api-reference/openapi-bundled.yaml get /v2/segments/tag
Project tags for a segment. The `source_tagged` string contains one or more SGML
tags. The `target` string is untagged. This endpoint will automatically place the
source tags in the target.
Usage charges apply to this endpoint for production REST API keys.
# Unaccept and unlock segments
Source: https://support.lilt.com/api-reference/segments/unaccept-and-unlock-segments
/api-reference/openapi-bundled.yaml post /v2/segments/review/unlock
Unaccept and unlock segments.
Sets individual segments' "Review Done" to false. Confirmed segments will remain confirmed.
Example curl:
```
curl --X --request POST 'https://lilt.com/2/segments/review/unlock?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"segmentIds": [23921, 23922]
}'
```
# Update a Segment
Source: https://support.lilt.com/api-reference/segments/update-a-segment
/api-reference/openapi-bundled.yaml put /v2/segments
Update a Segment in memory. The Memory will be updated with the new target string.
# Download translated file
Source: https://support.lilt.com/api-reference/translate/download-translated-file
/api-reference/openapi-bundled.yaml get /v2/translate/files
Download a translated File.
Example CURL:
```bash
curl -X GET 'https://api.lilt.com/v2/translate/files?key=API_KEY&id=1'
```
# Monitor file translation
Source: https://support.lilt.com/api-reference/translate/monitor-file-translation
/api-reference/openapi-bundled.yaml get /v2/translate/file
Get information about the one or more Files that are being translated with machine translation. Query filters are optional but at least one must be provided.
Example CURL:
```bash
curl -X GET 'https://api.lilt.com/v2/translate/file?key=API_KEY&translationIds=1,2&fromTime=1607966744&toTime=1707966744&status=InProgress'
```
# Translate a File
Source: https://support.lilt.com/api-reference/translate/translate-a-file
/api-reference/openapi-bundled.yaml post /v2/translate/file
Start machine translation of one or more Files that have previously been uploaded. The response will include an `id` parameter that can be used to monitor and download the translations in subsequent calls.
Example CURL:
```bash
curl -X POST 'https://api.lilt.com/v2/translate/file?key=API_KEY&fileId=583&memoryId=2495&configId=123&withTM=true'
```
# Translate a segment
Source: https://support.lilt.com/api-reference/translate/translate-a-segment
/api-reference/openapi-bundled.yaml get /v2/translate
Translate a source string.
Functionally identical to `POST /v2/translate`, with parameters passed
as query string parameters instead of a JSON request body. Useful for
simple integrations that prefer a GET request.
Setting the `rich` parameter to `true` will change the response format
to include additional information about each translation including a
model score, word alignments, and formatting information.
By default, this endpoint also returns translation memory (TM) fuzzy matches, along
with associated scores. Fuzzy matches always appear ahead of machine translation
output in the response.
The maximum source length is 50,000 characters. When a `prefix` is supplied (prefix-based translation), the maximum source length is 5,000 characters.
Word-alignment and formatting fields (`targetWords`, `targetDelimiters`, and `provenance`) are returned only for prefix or `source_hash` requests. Plain (non-prefixed) translations return `target` and `targetWithTags` only. The source-side fields `tokenizedSource` and `sourceDelimiters` are no longer returned.
Usage charges apply to this endpoint for production API keys.
# Translate a segment
Source: https://support.lilt.com/api-reference/translate/translate-a-segment-1
/api-reference/openapi-bundled.yaml post /v2/translate
Translate a source string.
Setting the `rich` parameter to `true` will change the response format
to include additional information about each translation including a
model score, word alignments, and formatting information. The rich
format can be seen in the example response on this page.
By default, this endpoint also returns translation memory (TM) fuzzy matches, along
with associated scores. Fuzzy matches always appear ahead of machine translation
output in the response.
The maximum source length is 50,000 characters. When a `prefix` is supplied (prefix-based translation), the maximum source length is 5,000 characters.
Word-alignment and formatting fields (`targetWords`, `targetDelimiters`, and `provenance`) are returned only for prefix or `source_hash` requests. Plain (non-prefixed) translations return `target` and `targetWithTags` only. The source-side fields `tokenizedSource` and `sourceDelimiters` are no longer returned.
Usage charges apply to this endpoint for production API keys.
# Cancel Multipart Upload
Source: https://support.lilt.com/api-reference/uploads/cancel-multipart-upload
/api-reference/openapi-bundled.yaml delete /v2/upload/s3/multipart/{uploadId}
Cancel/abort a multipart upload and clean up any uploaded parts.
Example CURL command:
```
curl -X DELETE "https://lilt.com/v2/upload/s3/multipart/abc123def456?key=API_KEY&key=uploads/user123/file456.zip"
```
# Complete Multipart Upload
Source: https://support.lilt.com/api-reference/uploads/complete-multipart-upload
/api-reference/openapi-bundled.yaml post /v2/upload/s3/multipart/{uploadId}/complete
Complete a multipart upload by providing all uploaded parts information.
Example CURL command:
```
curl -X POST "https://lilt.com/v2/upload/s3/multipart/abc123def456/complete?key=API_KEY&key=uploads/user123/file456.zip" \
--header "Content-Type: application/json" \
--data-raw '{
"parts": [
{"ETag": "etag1", "PartNumber": 1},
{"ETag": "etag2", "PartNumber": 2}
]
}'
```
# Get All Pending Uploads or specific list of uploads by ids or statuses
Source: https://support.lilt.com/api-reference/uploads/get-all-pending-uploads-or-specific-list-of-uploads-by-ids-or-statuses
/api-reference/openapi-bundled.yaml get /v2/upload
Retrieve all pending uploads for the current user and organization.
Example CURL command:
```
curl -X GET https://lilt.com/2/upload?key=API_KEY
```
# Get S3 Upload Parameters
Source: https://support.lilt.com/api-reference/uploads/get-s3-upload-parameters
/api-reference/openapi-bundled.yaml get /v2/upload/s3/params
Get S3 upload parameters via query string. This endpoint provides the necessary information
to complete the file upload process using GET parameters.
Example CURL command:
```
curl -X GET "https://lilt.com/v2/upload/s3/params?key=API_KEY&filename=example.json&type=application/json&metadata.size=1024&metadata.labels=important,review-needed"
```
# Get Upload by ID
Source: https://support.lilt.com/api-reference/uploads/get-upload-by-id
/api-reference/openapi-bundled.yaml get /v2/upload/{uploadId}
Retrieve a specific upload by its unique identifier.
Example CURL command:
```
curl -X GET https://lilt.com/2/upload/12345?key=API_KEY
```
# Initiate File Upload to Cloud Storage
Source: https://support.lilt.com/api-reference/uploads/initiate-file-upload-to-cloud-storage
/api-reference/openapi-bundled.yaml post /v2/upload/s3/params
Initiate the upload of a file to cloud storage. This endpoint provides the necessary information
to complete the file upload process.
Supports both single file and bulk upload requests. For bulk uploads, pass an array of upload
objects (maximum 100 items). The response format matches the request format - a single object
for single file requests, or an array for bulk requests.
Example CURL command (single file):
```
curl -X POST https://lilt.com/v2/upload/s3/params?key=API_KEY \
--header "Content-Type: application/json" \
--data-raw '{
"filename": "example.json",
"type": "application/json",
"metadata": {
"size": 1024,
"labels": ["important", "review-needed"]
}
}'
```
Example CURL command (bulk upload):
```
curl -X POST https://lilt.com/v2/upload/s3/params?key=API_KEY \
--header "Content-Type: application/json" \
--data-raw '[
{
"filename": "file1.json",
"type": "application/json",
"metadata": { "size": 1024 }
},
{
"filename": "file2.txt",
"type": "text/plain",
"metadata": { "size": 2048 }
}
]'
```
# Initiate Multipart Upload
Source: https://support.lilt.com/api-reference/uploads/initiate-multipart-upload
/api-reference/openapi-bundled.yaml post /v2/upload/s3/multipart
Initiate a multipart upload for large files. This endpoint provides the necessary information
to start a multipart upload process.
Supports both single file and bulk upload requests. For bulk uploads, pass an array of upload
objects (maximum 100 items). The response format matches the request format - a single object
for single file requests, or an array for bulk requests.
Example CURL command (single file):
```
curl -X POST https://lilt.com/v2/upload/s3/multipart?key=API_KEY \
--header "Content-Type: application/json" \
--data-raw '{
"filename": "large-file.zip",
"type": "application/zip",
"metadata": {
"size": 104857600
}
}'
```
Example CURL command (bulk upload):
```
curl -X POST https://lilt.com/v2/upload/s3/multipart?key=API_KEY \
--header "Content-Type: application/json" \
--data-raw '[
{
"filename": "large-file1.zip",
"type": "application/zip",
"metadata": { "size": 104857600 }
},
{
"filename": "large-file2.zip",
"type": "application/zip",
"metadata": { "size": 209715200 }
}
]'
```
# Sign Upload Part
Source: https://support.lilt.com/api-reference/uploads/sign-upload-part
/api-reference/openapi-bundled.yaml get /v2/upload/s3/multipart/{uploadId}/{partNumber}
Get a signed URL for uploading a specific part of a multipart upload.
Make sure to set the part size to 8MB (8388608 bytes).
Example CURL command:
```
curl -X GET "https://lilt.com/v2/upload/s3/multipart/abc123def456/1?key=API_KEY&key=uploads/user123/file456.zip&size=5242880"
```
# Creates a new Webhook Configuration
Source: https://support.lilt.com/api-reference/webhook-configuration/creates-a-new-webhook-configuration
/api-reference/openapi-bundled.yaml post /v3/connectors/configuration/webhooks
Creates a new webhook configuration for your LILT organization.
# Delete a specific Webhook Configuration by ID.
Source: https://support.lilt.com/api-reference/webhook-configuration/delete-a-specific-webhook-configuration-by-id
/api-reference/openapi-bundled.yaml delete /v3/connectors/configuration/webhooks/{id}
# Retrieve a list of Webhook Configurations.
Source: https://support.lilt.com/api-reference/webhook-configuration/retrieve-a-list-of-webhook-configurations
/api-reference/openapi-bundled.yaml get /v3/connectors/configuration/webhooks
Retrieves a list of webhook configurations available to your LILT organization.
Use this to manage your webhook configurations.
# Retrieve a specific Webhook Configuration by ID.
Source: https://support.lilt.com/api-reference/webhook-configuration/retrieve-a-specific-webhook-configuration-by-id
/api-reference/openapi-bundled.yaml get /v3/connectors/configuration/webhooks/{id}
Retrieves a specific webhook configuration by its ID.
Deleted webhook configurations are not returned.
# Update a specific Webhook Configuration by ID.
Source: https://support.lilt.com/api-reference/webhook-configuration/update-a-specific-webhook-configuration-by-id
/api-reference/openapi-bundled.yaml put /v3/connectors/configuration/webhooks/{id}
Updates a specific webhook configuration by its ID.
Only the fields that are provided in the request body will be updated.
# Retrieve workflow templates
Source: https://support.lilt.com/api-reference/workflows/retrieve-workflow-templates
/api-reference/openapi-bundled.yaml get /v2/workflows/templates
Get all of the possible Workflow Templates owned by the team. Useful for retrieving the ids corresponding to each workflow tables, and passing them to subsequent requests, for example, creating a new Job with a specific Workflow.
Example CURL:
```bash curl -X GET 'https://api.lilt.com/v2/workflows/templates?key=API_KEY' ```
# Context Database
Source: https://support.lilt.com/context-database
# **What is the Context Database?**
The Context Database is your centralized data hub for all of your multilingual business context. It brings together Translation Memories (TM), Termbases (TB), Style Guides, Reference Materials, Jobs, Projects, and Segments into a single, highly searchable ecosystem.
Rather than treating these assets as disconnected files, the Context Database cross-references them in real-time. This creates a smart engine that works seamlessly in the background to ensure your translations are accurate, consistent, and perfectly aligned with your brand's voice.
# **How It Powers Your LILT Experience**
The Context Database isn't just a storage system; it actively powers the tools you use every day:
* **Smarter AI Translations:** When LILT AI generates a translation, it instantly pulls relevant data from the Context Database to ensure the output matches your historical preferences and terminology.
* **LILT Agent Assistance:** The database supplies the LILT Agent with the exact context it needs to assist you with tasks, answer questions, and provide recommendations.
# **Unified Search & Filtering**
Looking for a specific phrase from a project you completed last year? The Context Database features a powerful natural language search page built for fast, intuitive discovery.
**What you can search by:**
* File names, job/project names, or specific segment IDs
* Specific terms, phrases, or full sentences
* Subject matter or business use case
* Job-level metadata and custom properties
**How you can narrow results:** Faceted sidebar filters allow you to quickly refine results by data type (e.g., only search within Style Guides or Termbases), content format, language pair, domain, and date range.
# **What Data is Searchable?**
The Context Database indexes a wide variety of your multilingual business data so you can easily find it later. Each item includes rich metadata to give you a complete picture:
| **Data Type** | **Key Metadata** |
| :----------------------- | :------------------------------------------------------------------------------------ |
| **Job/Project** | Name, ID, status, assigned users, dates, source/target languages, word counts, domain |
| **Document** | Name, type, job, status, word counts (new & fuzzy) |
| **Segment** | Segment ID, source/target text, language pair, parent job/project/document |
| **Term base / Glossary** | Term, translation, language pair, dates |
| **Translation Memory** | Source/target segment, language pair, dates |
| **Reference Material** | File name, type, language, linked job |
| **Style Guide** | Domain, language/locale, dates |
# **How to Use the Context Database**
To get started, navigate to **Context Database** from the main navigation menu in LILT. From there, you can:
1. **Search across everything:** Enter any search term, segment ID, document name, or business topic into the universal search bar.
2. **Filter your results:** Use the sidebar controls to narrow your view by asset type, language pair, domain, or date range.
3. **Explore connected details:** Click on any search result to open the **Segment Context sidebar** to review related terms, author information, approval status, project notes, and linked resources.
4. **Take action on your data:** Select individual entries or group multiple results together to kick off a workflow. Use the action menu to send context directly to the LILT Agent, launch a new translation job, or organize assets with custom labels.
5. **Add and manage your assets:** Upload new resources directly to the database in standard translation formats (such as TMX, TBX, CSV, or Excel). Assign language pairs, domains, or tags, and track version history to view or restore earlier versions.
6. **Enjoy automatic context in your translations:** Once your assets are stored, no extra steps are required. LILT automatically feeds this context to both the Contextual AI and the LILT Agent during translation tasks.
**Note on Access:** Search results automatically respect your team's role and domain permissions, so you will only ever see and manage content you are authorized to access.
# **Intelligent Cross-Referencing & QA**
Because all your assets live in one connected ecosystem, the Context Database can do the heavy lifting to keep your content consistent:
* **Smart Terminology Updates:** If a historical Translation Memory (TM) match contains an outdated term, the system automatically cross-references it against your current Termbase to ensure the newest terminology is applied.
* **Continuous AI Learning:** Human linguist confirmations update your entire data ecosystem simultaneously, helping LILT's Contextual AI understand the relationships between your glossaries, TMs, and style guidelines.
* **Connected Context:** Rich details (like authorship, approval status, and project notes) tie your style guidelines to specific glossary terms and are surfaced automatically in the Segment Context sidebar while translating.
* **Automated QA:** Built-in quality assurance rules constantly scan the relationships between your data sets, automatically flagging contradictions (e.g., if a drafted translation conflicts with an approved glossary term).
# **Context Hierarchy: Which Rules Apply?**
To ensure the right terminology is used at the right time, the Context Database organizes information into a hierarchy. When giving instructions to the AI or LILT Agent, context is prioritized in this order:
1. Organization: High-level instructions that apply to your entire company.
2. Domain: Style guides and instructions specific to a certain department, subject, or brand.
3. User: Your personal project instructions, preferred terms, past jobs, and language settings.
# **Security & Permissions**
Your data remains secure. All search results and database views strictly respect role-based and domain-based access controls, meaning users will only ever see the data and assets they are authorized to view.
# Connect Systems To Workflows
Source: https://support.lilt.com/developers/guides/connect-systems-to-workflows
The LILT Connectors framework simplifies the process of integrating external applications and services with the LILT platform. It provides a standardized approach for building connectors, reducing development time and effort. These connectors act as bridges, allowing data to flow seamlessly between LILT and other tools. This not only streamlines workflows but also expands LILT's capabilities by enabling it to leverage functionalities offered by external systems. With the LILT Connectors framework, users can benefit from a wider range of features and data sources, ultimately enhancing the efficiency and effectiveness of their localization processes.
The Connectors that LILT supports grows over time, a current list can be found [here](https://lilt.com/connectors).
If you want an in-depth guide for how the connectors integrate with a specific partner, check out our [knowledge base](/kb/connectors).
# Create Content
Source: https://support.lilt.com/developers/guides/create-new-content
LILT Create offers an alternative to normal translation, by allowing you to generate content in the target language using various prompts to get your message across more organically in the new language. This can make your content easier to understand for users of that language and can empower a global audience. This guide will demonstrate how to:
* [Generate Content](#generate-content)
* [Retrieve Generated Content](#get-generated-content)
* [Update or Delete Content](#update-or-delete-content)
Things you will need:
* API Key - All requests throughout the LILT API use the API Key to authenticate.
## Generate Content
There are a few things to consider before Generating Content:
1. What do I want to generate? This can be as simple as "Write a story about bees" or "Write a paragraph about product X". As long as your prompt is below the character limit of 500.
2. How do I want to group the content to be generated? Writing an article that is split into multiple sections with different headings, add sections to structure the generated content.
3. Do I want to use Terminology specific to my organization? Add a `memoryId` to the request. [See the API docs for more info](/api-reference/create/generate-new-lilt-create-content).
Below is an example request to generate content in English.
```bash theme={null}
curl -X POST 'https://api.lilt.com/v2/create?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"language":"en-US",
"template":"blog-post",
"templateParams":{
"contentLength":"1000",
"language":"en-US",
"sections":["Bees and me","Honey for you", "Conclusion"],
"summary":"a blog post about how important bees are to my honey farm"
},
"preferences":{"tone":"formal","styleguide":""}
}'
```
The response is an event stream of the generated content. You can choose to read the stream, or you can choose to wait until a DONE message is emitted. Try it out with something that makes sense for your organization or a different language you are proficient with.
## Get Generated Content
As you Create more it might become necessary to get content you already generated previously. You can get a complete list of everything you have created previously using this [endpoint](/api-reference/create/get-lilt-create-content):
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/create?key=API_KEY'
```
You can also retrieve a single piece of content by its ID using the [Get Lilt Create content by ID endpoint](/api-reference/create/get-lilt-create-content-by-id):
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/create/1234?key=API_KEY'
```
## Update or Delete Content
Existing Lilt Create content can be updated (for example, to change the language) or deleted using the content's ID.
```bash theme={null}
curl -X PUT 'https://api.lilt.com/v2/create/1234?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"language":"de-DE"}'
```
```bash theme={null}
curl -X DELETE 'https://api.lilt.com/v2/create/1234?key=API_KEY'
```
See the [API Specification](/api-reference/create/get-lilt-create-content-by-id) for the full request and response shapes for these endpoints.
# Create A Data Source
Source: https://support.lilt.com/developers/guides/manage-content/create-a-datasource
What is a Data Source? A Data Source is an object that links all of your translated content together for a given language. It allows the LILT system to reference all of your previous translations, TMX files and Termbases(TB) to provide you with the most accurate translation possible.
Things you will need:
* API Key - All requests through the LILT API use the API Key to authenticate.
* (Optional) TMX File - TMX files contain sentence to sentence translations and serve as a basis for translating content, these files aren't necessary but can produce better Instant Translate results for your documents depending on the quality of the data provided.
* (Optional) TB File - Your business likely has specific product names, advertising terminology, and other words that you may or may not want translated. Adding a TB (Termbase) file to the Data Source creates a managed way to translate certain words/phrases for your business.
**Note:**
Data Sources can also be referred to as Memories. Anywhere in the docs that mentions a `memoryId` or `/memories` endpoint is referring to a Data Source.
## Create a Data Source
Creating a Data Source with LILT is a straight-forward process. For this example we will create a Data Source in English to German using Locales. If you want to try a different language, a list of supported languages and how to access them is available in the [Quick Start Guide](/developers/quickstart). Here is an example API call to create a Data Source plus the Request body. [See the API docs for more info](/api-reference/memories/create-a-memory)
```bash theme={null}
curl -X POST https://api.lilt.com/v2/memories?key=API_KEY \
--header "Content-Type: application/json" \
--data '{"name": "Test Data Source","srclang": "en","trglang": "de","srclocale": "US","trglocale": "DE"}'
```
Once the call is made you should expect to see a response that looks something like this:
```json theme={null}
{
"id": 1234,
"srclang": "en",
"trglang": "de",
"srclocale": "US",
"trglocale": "DE",
"name": "Test Data Source",
"is_processing": false,
"version": 78,
"created_at": 1489147692,
"updated_at": 1489147692,
"resources": ["string"]
}
```
Congratulations, you have successfully created a Data Source.
## Add a TMX file/TB file to your Data Source
A Data Source is only as useful as the data stored within. LILT uses memories as a way to keep track of your organizations content in a language pair format. Adding data to an empty Data Source is a typical first step when onboarding to LILT. If your organization has done localization in the past, chances are that you have a tmx file/tb file that needs to be added to your Data Source to ensure that your historical data is taken into consideration by the LILT Transformative AI. For this example we will upload a tmx file called "test.tmx" using the [import file endpoint](/api-reference/memories/file-import-for-a-memory)
```bash theme={null}
curl -X POST https://api.lilt.com/v2/memories/import?key=API_KEY \
--header "LILT-API: {\"name\": \"test.tmx\",\"memory_id\": 1234}" \
--header "Content-Type: application/octet-stream" \
--data-binary @test.tmx
```
This should elicit a 200 response that looks something like this:
```json theme={null}
{
"id": 123,
"isProcessing": 1
}
```
This response means is that the request was registered successfully and your file is being processed by LILT into Segments which will become part of the Data Source. This process is asynchronous and can be verified using the [memories endpoint](/api-reference/memories/retrieve-a-memory):
```bash theme={null}
curl -X GET https://api.lilt.com/v2/memories?key=API_KEY&id=1234\
```
This request will give you a response similar to the creation logic, with the key difference of seeing the new resource in the resources list.
```json theme={null}
{
"id": 1234,
"srclang": "en",
"trglang": "de",
"srclocale": "US",
"trglocale": "DE",
"name": "Test Data Source",
"is_processing": false,
"version": 78,
"created_at": 1489147692,
"updated_at": 1489147692,
"resources": ["test.tmx"]
}
```
# Data Source Management
Source: https://support.lilt.com/developers/guides/manage-content/tm-query
In the normal course of translation and localization, there will be times where you need to verify the existence of a specific sentence/word/phrase in your Data Source. Whether that is because the target language has changed how it uses the word in the course of a languages evolution or if you simply want to verify that the Term your organization uses to describe a specific product is correct, this guide will show you how to look things up in a LILT Data Source without having to pull down the whole file.
In this guide you will learn how to:
* [Query a Data Source](#get-generated-content)
Things you will need:
* API Key - All requests through the LILT API use the API Key to authenticate.
## Query a Data Source
Querying a Data Source in LILT uses a string lookup to pull specific segments that fit the source provided. In this example the string we will use is "LILT Create". Please note that the n in the query is a limit on the number of segments to pull. [See the API docs for more info](/api-reference/memories/query-a-memory)
```bash theme={null}
curl -X GET https://api.lilt.com/v2/memories/query?key=API_KEY&id=MEMORY_ID&query="LILT Create is a Generative AI tool."&n=100
```
With that we would expect to see a response containing no more than 100 segments that fit the query criteria.
```json theme={null}
[
{
"source": "LILT Create is a Generative AI tool.",
"target": "LILT Create ist ein generatives KI-Tool.",
"score": 100,
"metadata": "object"
}
]
```
In this case, there was a single segment that fit the criteria with a score of 100. The score determines how close the system believes the query provided is close to what you are looking for. Anything less than 75 is automatically discarded.
## Note
The query is a useful tool for verifying small things and ensuring certain phrases are in the right place. Feel free to explore the other Data Source End points in the [API Specification](/api-reference/memories).
# API Rate Limits
Source: https://support.lilt.com/developers/guides/rate-limits
**Recent product change: API rate limits effective June 30, 2026**
LILT is committed to delivering fast, reliable translation performance to every organization on our platform. To protect that shared experience and make sure no single workload can degrade service for others, **we've adding per-organization rate limits to our document pretranslation and file-translation APIs, beginning June 30, 2026**. These endpoints aren't changing; we've simply introduced fair-use limits so capacity stays balanced across all our customers.
*Please note: All LILT Connectors are out of scope for these rate limits. These will only apply to the API.*
***
# Overview
Starting June 30, 2026, LILT is introducing per-organization rate limits on the following endpoints:
* `POST /v2/documents/pretranslate`
* `POST /v2/translate/file`
* `POST /v2/documents/files` (only when the upload invokes MT - see exclusion note below)
* `POST /2/jobs `(only request rate and not character throughput)
Two independent limits apply to every organization:
| **Limit** | **Threshold** |
| :------------------- | :------------------------------ |
| Request rate | 300 requests per minute |
| Character throughput | 2,500,000 characters per minute |
Requests that exceed either limit receive an **HTTP 429 Too Many Requests** response. This guide explains how to read the 429 response headers and restructure your integration to stay comfortably within these thresholds.
### File uploads without Machine Translation (MT) are excluded
`POST /v2/documents/files` uploads a file - it does not, by itself, run machine translation (MT). Uploads that don't invoke MT are not counted against the character-throughput limit: LILT evaluates each request's translation cost and a non-MT upload is measured as zero characters, so it draws down neither your throughput budget. Only calls that actually consume MT (`POST /v2/documents/pretranslate` and `POST /v2/translate/file`, plus a `/v2/documents/files` upload that triggers pretranslation) count toward the 2,500,000-characters-per-minute limit. You can upload source files freely; batch and pace the translation calls that follow.
# Understanding the 429 Response
When a request is rate-limited, LILT returns a 429 with three headers that tell you exactly when you can safely retry:
| **Header** | **Meaning** |
| :---------------------- | :----------------------------------------------------------------------------------- |
| `X-RateLimit-Limit` | Your per-minute allowance (requests or characters, depending on which limit was hit) |
| `X-RateLimit-Remaining` | Requests or characters still available in the current one-minute window |
| `X-RateLimit-Reset` | Seconds until the current window resets and your full quota is restored |
The two limits are **independent**. You can hit the character throughput ceiling without exhausting your request count, or vice versa. Check both headers when handling a 429.
## Example 429 response
```http theme={null}
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 38
{
"error": "rate_limit_exceeded",
"message": "Request rate limit reached. Retry after 38 seconds."
}
```
# Handling a 429: Retry with Back-Off
The simplest fix for an occasional 429 is to wait for the window to reset before retrying. Do not tight-loop or immediately re-send. This wastes quota and keeps triggering 429s.
## Recommended retry pattern
On receiving a 429:
1. Read the `X-RateLimit-Reset` value from the response headers.
2. Sleep for that many seconds (plus a small jitter to avoid synchronized retries across parallel workers).
3. Re-send the original request.
## Python example
```python theme={null}
import time, random, requests
def pretranslate(payload, headers):
url = "https://api.lilt.com/v2/documents/pretranslate"
for attempt in range(5):
resp = requests.post(url, json=payload, headers=headers)
if resp.status_code == 429:
reset_in = int(resp.headers.get("X-RateLimit-Reset", 60))
jitter = random.uniform(0.5, 2.0)
wait = reset_in + jitter
print(f"Rate limited. Retrying in {wait:.1f}s (attempt {attempt+1}/5)")
time.sleep(wait)
continue
resp.raise_for_status()
return resp.json()
raise RuntimeError("Exceeded retry limit")
```
## Node.js example
```js theme={null}
async function pretranslate(payload, headers) {
const url = "https://api.lilt.com/v2/documents/pretranslate";
for (let attempt = 0; attempt < 5; attempt++) {
const res = await fetch(url, {
method: "POST",
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
if (res.status === 429) {
const resetIn = parseInt(res.headers.get("X-RateLimit-Reset") ?? "60", 10);
const jitter = Math.random() * 1.5 + 0.5;
const wait = (resetIn + jitter) * 1000;
console.log(`Rate limited. Retrying in ${(wait/1000).toFixed(1)}s`);
await new Promise(r => setTimeout(r, wait));
continue;
}
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
throw new Error("Exceeded retry limit");
}
```
# Batching Requests
If your integration sends many small, individual translation calls in rapid succession, **batching** (combining multiple documents or files into fewer API calls) is the most effective way to stay well under the rate limits.
## What to batch
| **Endpoint** | **Batching approach** |
| :-------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /v2/documents/pretranslate` | Pass an array of document IDs in a single request body |
| `POST /v2/translate/file` | Batch by referencing multiple already-uploaded files in a single call. Pass their IDs via the fileId query parameter (e.g. ?fileId=1,2,3 or repeated ?fileId=1\&fileId=2). This does not accept multiple source files in the multipart body; the files must already exist (uploaded via the file-upload endpoint first). |
**Character throughput tip**
Batching reduces your request count, but each batch's characters still count toward the 2,500,000 character-per-minute throughput limit. If you're working with very large documents, spread batches across multiple windows rather than sending all characters at once.
## Sizing your batches
There is no fixed rule for batch size — it depends on your document sizes and submission cadence. Use these guidelines as a starting point:
* Keep each batch well under 2,500,000 characters to leave headroom for concurrent jobs from other parts of your organization.
* If you are consistently close to the `X-RateLimit-Remaining` ceiling, reduce batch frequency or split large batches into smaller ones with a brief pause between them.
* For burst workloads (e.g., end-of-sprint file exports), schedule submissions in staggered windows rather than all at once.
## Pretranslation: batching document IDs
The `POST /v2/documents/pretranslate` endpoint accepts an array of document IDs. Instead of issuing one request per document, collect IDs and submit them together:
```python theme={null}
# ✗ One request per document (inefficient)
for doc_id in document_ids:
requests.post('/v2/documents/pretranslate', json={'id': [doc_id]}, headers=headers)
# ✓ All documents in a single request (efficient)
requests.post(
'/v2/documents/pretranslate',
json={'id': document_ids}, # e.g. [1001, 1002, 1003, ...]
headers=headers,
)
```
If you have hundreds of documents to pretranslate, split them into chunks and submit one chunk per window:
```python theme={null}
import time, math, requests
CHUNK_SIZE = 50 # documents per request
WINDOW_SEC = 62 # slightly more than 60 s to be safe
def batch_pretranslate(doc_ids, headers):
chunks = [doc_ids[i:i+CHUNK_SIZE] for i in range(0, len(doc_ids), CHUNK_SIZE)]
for i, chunk in enumerate(chunks):
print(f'Submitting chunk {i+1}/{len(chunks)} ({len(chunk)} docs)')
pretranslate({'id': chunk}, headers) # uses retry helper above
if i < len(chunks) - 1:
time.sleep(WINDOW_SEC)
```
## File translation: Uploading and batching by reference
The `POST /v2/documents/files` accepts one file per request. Additional files in a multipart body are silently ignored.
To translate many files, upload each one individually, then batch the downstream operation by passing the resulting IDs in a single call (e.g. an array of document IDs to `POST /v2/documents/pretranslate`, or multiple field query params to `POST /v2/translate/file`.)
```python theme={null}
▎ import requests
▎
▎ def upload_files(file_paths, headers):
▎ """Upload files one at a time; return the list of created file IDs."""
▎ file_ids = []
▎ for path in file_paths:
▎ with open(path, 'rb') as fh:
▎ files = {'file': (path.split('/')[-1], fh, 'application/octet-stream')}
▎ resp = requests.post(
▎ 'https://api.lilt.com/v2/documents/files',
▎ files=files,
▎ headers=headers,
▎ )
▎ resp.raise_for_status()
▎ file_ids.append(resp.json()['id']) # adjust to actual response field
▎ return file_ids
▎
▎ def translate_files(file_ids, headers):
▎ """Batch-translate already-uploaded files in a single request by reference."""
▎ resp = requests.post(
▎ 'https://api.lilt.com/v2/translate/file',
▎ params={'fileId': ','.join(str(i) for i in file_ids)},
▎ headers=headers,
▎ )
▎ resp.raise_for_status()
▎ return resp.json()
```
# Proactive Throttling
Rather than reacting to 429s, you can read `X-RateLimit-Remaining` and `X-RateLimit-Reset` on every successful response and slow down before you hit the ceiling.
```python theme={null}
def check_and_throttle(response, low_watermark=20):
"""Pause proactively when remaining quota is low."""
remaining = int(response.headers.get("X-RateLimit-Remaining", 999))
reset_in = int(response.headers.get("X-RateLimit-Reset", 0))
if remaining <= low_watermark and reset_in > 0:
print(f'Quota low ({remaining} left). Pausing {reset_in}s.')
time.sleep(reset_in + 1)
```
# Pre-Launch Checklist
Before June 30, verify that your integration:
* Sends arrays of document IDs to `/v2/documents/pretranslate` rather than one ID at a time and arrays of file IDs to `/v2/files/translation`.
* Groups related files into a single `multipart/form-data` request where possible.
* Handles HTTP 429 by sleeping for `X-RateLimit-Reset` seconds (plus jitter) before retrying.
* Does not tight-loop on 429 responses.
* Monitors `X-RateLimit-Remaining` and throttles proactively when quota is low.
* Schedules large burst workloads across multiple one-minute windows.
# Need More Headroom?
The default thresholds are designed to sit well above typical usage patterns. If your workload genuinely requires higher limits, reply to the rate-limits notification email and the LILT team will work with you to find a configuration that fits your needs without impacting the shared platform.
**Contact support**
Reach out via your rate-limits notification email, or contact LILT support at [support.lilt.com](https://support.lilt.com). Please include your organization ID and a brief description of your workload volume when you get in touch.
# AI Translation
Source: https://support.lilt.com/developers/guides/translate-content/instant-translate
In this walkthrough we will demonstrate how to use the LILT API AI Translation functionality. Instant translate is a powerful way to use LILT's Transformative AI to translate your content quickly and accurately without having to wait for a human to verify the results.
Things you will need:
* API Key - All requests through the LILT API use the API Key to authenticate.
* File to Translate - We recommend a simple text file (txt) for a first attempt.
* Memory ID - A LILT Data Source's memoryId to use with the translation - [Create one here!](/developers/guides/manage-content/create-a-datasource)
## File Upload
Please refer to the [File Upload](/developers/guides/upload/file-upload) documentation to get a File ID.
## Translate File
Now that you have a file saved in LILT, let's translate it! To run an AI translation for a single file you will need to use the [translate file endpoint](/api-reference/translate/translate-a-file). The end point below will translate your file, using the provided memoryId, fileId. File Translation is an Asynchronous process.
*Note: If you don't add "withTM" as a parameter, the default setting is TRUE and the instant translation will leverage your TM.*
```powershell theme={null}
curl -X POST 'https://api.lilt.com/v2/translate/file?key=API_KEY&fileId=123&memoryId=1234'
```
The response will be a status object that looks like this:
```json theme={null}
{
"id": 1,
"fileId": "2,",
"status": "InProgress",
"createdAt": 1609357135
}
```
## Monitor Translation
Now that you have the translation id, you can call the [monitor endpoint](/api-reference/translate/monitor-file-translation) to get the current status of your translations. You can ask for status for any number of translations at a time, we recommend bundling these translationIds together.
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/translate/file?key=API_KEY&translationIds=1,2,3,4'
```
The response to the Monitor end point will look the same as the POST call you made earlier. The status might be different. Here are the statuses you can expect to see:
* `InProgress` - The Translation has begun!
* `Completed` - Translation is Complete but not yet ready for download.
* `Failed` - The Translation was unsuccessful. 🙃
* `ReadyForDownload` - The Translation was Complete and is available for retrieval.
## Download Translated File
Once you have the green light to download the translated file you can call the [download endpoint](/api-reference/translate/download-translated-file). This endpoint only allows for downloading one file at a time.
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/translate/files?key=API_KEY&id=1'
```
The response to this end point will be your content translated into whatever language you picked for the Data Source!
## Notes
The end points described above have additional features, but we don't recommend them for most users. If you are curious, feel free to take a look at the [API Specification](/api-reference).
# Verified Translation
Source: https://support.lilt.com/developers/guides/translate-content/verified-translation
Verified Translation has a human in the loop to ensure the highest translation quality. That means immediate turn around times will not be possible unlike with [Instant Translate](/developers/guides/translate-content/instant-translate).
In this section we will discuss:
* [Uploading Files](#uploading-files)
* [Creating a Job](#creating-a-job)
* [Monitoring Job Status](#monitoring-the-job-status)
* [Downloading Translated Jobs](#downloading-translated-jobs)
* [Archiving Downloaded Jobs](#archiving-downloaded-jobs)
Things you will need:
* API Key - All requests through the LILT API use the API Key to authenticate.
* File to Translate - We recommend a simple text file (txt) for a first attempt.
* Memory ID - A LILT Data Source's `memoryId` to use with the translation - [Create one here!](/developers/guides/manage-content/create-a-datasource)
## Submitting a New LILT Job
A LILT Job encapsulates the various files that you want to translate. A Job is usually made up of multiple Projects. A Project is a grouping of Documents to be translated for an individual language pair (en->de - English to German). The LILT app has a useful wizard for creating Jobs that breaks all of these concepts down into a single package.
In the next section you will learn how to create your first LILT Job. If you are curious about how these objects fit together, feel free to check out the API Reference:
* [Jobs](/api-reference/jobs)
* [Projects](/api-reference/projects)
* [Documents](/api-reference/documents)
* [Files](/api-reference/files)
* [Languages](/api-reference/languages)
## Uploading Files
The first step is to upload some files. For this example, a text (txt) file will be used as it is one of the simplest file types supported for verified translation. [See the API docs for more file upload options](/api-reference/files/upload-a-file).
```java theme={null}
curl -X POST https://api.lilt.com/v2/files?key=API_KEY&name=testfile.txt \
--header "Content-Type: application/octet-stream" \
--data-binary @testfile.txt
```
The response will have an ID that relates to the File:
```javascript theme={null}
{
"id": {Your File Id here},
"name": "testfile.txt",
"file_hash": "3858f62230ac3c915f300c664312c63f",
"detected_lang": "en",
"detected_lang_confidence": 0.7,
"category": "API",
"labels": [],
"created_at": "2024-02-16T22:12:34.000Z",
"updated_at": "2024-02-16T22:12:34.000Z"
}
```
Hold onto the file IDs as you will need them in Step 2. If you lose them, you can always query the [Files API](/api#tag/Files/operation/getFiles) to see a list of your files.
**Tip**
Upload all of the files first before creating a Job with them.
## Creating a Job
To create a Job you need at least one Data Source for the language you want to translate into. We will use the corresponding `memoryId` and the target language from that memory to specify a Language Pair, which can then be linked to the relevant Job.
### Basic Job Creation
For now, let's create a Job for a single File and a single Language Pair. The request to create a Job will look like this. [See the API docs for more info](/api-reference/jobs/retrieve-all-jobs).
```bash theme={null}
curl -X POST 'https://api.lilt.com/v2/jobs?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "test job",
"fileIds": [1234],
"due": "2024-02-05T10:56:44.985Z",
"srcLang": "en",
"srcLocale": "US",
"languagePairs": [
{ "memoryId": 3121, "trgLang": "de" }
]
}'
```
### Advanced Job Creation with Unified Fields
You can also include additional fields to provide more context and metadata:
```swift theme={null}
curl -X POST 'https://api.lilt.com/v2/jobs?key=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Marketing Campaign Q1",
"fileIds": [1234, 1235],
"due": "2024-02-05T10:56:44.985Z",
"srcLang": "en",
"srcLocale": "US",
"jobInstructions": "This is a marketing campaign for Q1. Please maintain brand voice and use approved terminology from the style guide.",
"customProperties": {
"purchaseOrder": "PO-2024-Q1-001",
"department": "Marketing",
"campaign": "Q1-Launch",
"priority": "high"
},
"enablePostProcessing": true,
"languagePairs": [
{
"memoryId": 3121,
"trgLang": "de",
"instructions": "Use formal German (Sie form) for B2B audience"
},
{
"memoryId": 3122,
"trgLang": "fr",
"instructions": "Use informal French (tu form) for consumer audience"
}
]
}'
```
**Field Descriptions:**
* **`jobInstructions`** (optional): General instructions that apply to all projects in the job. Visible to all translators and reviewers. Max 5000 characters.
* **`customProperties`** (optional): Key-value pairs for custom metadata. Useful for tracking purchase orders, departments, or other organizational data.
* **`enablePostProcessing`** (optional): Boolean flag to enable additional post-processing steps after translation.
* **`languagePairs[].instructions`** (optional): Language-specific instructions for each target language. Max 200 characters per language pair.
That is all it takes to create a Verified Translation Job in LILT with full context and metadata.
The Job has now been created and the LILT team will handle processing the verified translations. The Job will be marked as Delivered in LILT to indicate that the translations are ready for download.
## Monitoring the Job Status
To determine which translations are ready for download query for jobs where `isDelivered=true` and `isArchived=false`.
```bash theme={null}
curl -X GET https://api.lilt.com/v2/jobs?key=API_KEY&isDelivered=true&isArchived=false
```
[See the API Docs for more info](/api-reference/jobs/retrieve-all-jobs).
## Downloading Translated Jobs
To download the completed translations, first initiate an export of the Job using the [export endpoint](/api-reference/jobs/export-a-job). This will set the `isProcessing` value to `1`.
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/jobs/{id}/export?key=API_KEY&type=files'
```
Check the status of the export by calling the [get job by ID endpoint](/api-reference/jobs/retrieve-a-job). When the export is complete, the `isProcessing` value will be set to `0` (or `-2` in the case of an export error).
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/jobs/{id}?key=API_KEY'
```
Once the export is complete the translations can be downloaded. The [download endpoint](/api-reference/jobs/download-a-job) will return a zip file containing all of the translations.
```powershell theme={null}
curl -X GET 'https://api.lilt.com/v2/jobs/{id}/download?key=API_KEY'
```
## Archiving Downloaded Jobs
Call the [archive endpoint](/api-reference/jobs/archive-a-job) after successful download of the translations to indicate that the translations have been received.
```powershell theme={null}
curl -X POST 'https://api.lilt.com/v2/jobs/{id}/archive?key=API_KEY'
```
That concludes this end-to-end guide for completing Verified Translation Jobs using the LILT API.
# Cloud Upload API Documentation
Source: https://support.lilt.com/developers/guides/upload/file-upload
## Overview
The LILT Cloud Upload API provides secure file upload capabilities using S3-compatible presigned URLs. This system supports both single file uploads and multipart uploads for large files, enabling efficient and secure file transfers directly to cloud storage.
## Key Features
* **Direct S3 Uploads**: Files are uploaded directly to S3-compatible storage, reducing server load
* **Presigned URL Security**: Time-limited, secure URLs with no exposed credentials
* **Multipart Upload Support**: Efficient handling of large files through chunked uploads
* **Flexible Client Support**: Use any HTTP client library in your preferred programming language
* **Managed Infrastructure**: LILT handles all bucket configuration, CORS setup, and storage management
## How It Works
The upload process uses AWS S3-compatible presigned URLs for secure file transfers:
1. **Request Upload Parameters**: Call the Lilt API to get presigned URL and upload parameters
2. **Upload Directly to Storage**: Use the presigned URL to upload files directly to S3-compatible storage
3. **Complete Upload**:
* For multipart uploads, notify the API when all parts are uploaded
* Poll for antivirus scan completion to get the File ID which you can use for other endpoints (add to jobs or projects)
## API Endpoints
### 1. Initiate Single File Upload
**Endpoint:** `POST /v2/upload/s3/params` or `GET /v2/upload/s3/params`
Initiates a single file upload and returns presigned URL for direct upload to storage.
#### Request Body
```json theme={null}
{
"filename": "document.pdf",
"type": "application/pdf",
"metadata": {
"size": 1048576,
"category": "SOURCE",
"uuid": "123e4567-e89b-12d3-a456-426614174000"
}
}
```
#### Parameters
| Field | Type | Required | Description |
| ------------------- | ------- | -------- | ----------------------------------- |
| `filename` | string | Yes | File name including extension |
| `type` | string | Yes | MIME type of the file |
| `metadata.size` | integer | No | File size in bytes |
| `metadata.category` | string | No | File category (SOURCE or REFERENCE) |
| `metadata.uuid` | string | No | Unique identifier for the file |
#### Response
```json theme={null}
{
"url": "https://storage.example.com/bucket/path/file.pdf?AWSAccessKeyId=...",
"method": "PUT",
"filename": "text2.txt",
"contentType": "text/plain",
"metadata": {
"size": 1048576,
"category": "SOURCE",
"uuid": "123e4567-e89b-12d3-a456-426614174000"
},
"upload": {
"createdAt": "2025-07-08T11:11:27.674Z",
"updatedAt": "2025-07-08T11:11:27.674Z",
"isDeleted": false,
"deletedAt": null,
"id": 362,
"UserId": 10727,
"OrganizationId": 682,
"fileLocation": "gs://.../text2.txt",
"status": "UPLOADING",
"totalBytes": 333,
"uploadedBytes": 0,
"category": "SOURCE"
}
}
```
### 2. Initiate Multipart Upload
**Endpoint:** `POST /v2/upload/s3/multipart`
Initiates a multipart upload for large files (recommended for files > 100MB).
Make sure your part size is set to 8MB (8388608 bytes).
#### Request Body
```json theme={null}
{
"filename": "large-file.zip",
"type": "application/zip",
"metadata": {
"size": 104857600,
"category": "SOURCE"
}
}
```
#### Response
```json theme={null}
{
"uploadId": "abc123def456",
"key": "uploads/user123/large-file.zip",
"upload": {
"createdAt": "2025-07-08T11:11:27.674Z",
"updatedAt": "2025-07-08T11:11:27.674Z",
"isDeleted": false,
"deletedAt": null,
"id": 362,
"UserId": 10727,
"OrganizationId": 682,
"fileLocation": "gs://.../text2.txt",
"status": "UPLOADING",
"totalBytes": 333,
"uploadedBytes": 0,
"category": "SOURCE"
}
}
```
The following parameters are optional and only relevant when uploading video content for translation:
* `extractText`: When uploading a video file, set this parameter to `True` to ensure that text is extracted from the video (if needed).
* `isSourceReviewRequired`: When uploading a video file, set this parameter to `True`to indicate that the source content should be reviewed before translation begins.
### 3. Get Upload Part URL
**Endpoint:** `GET /v2/upload/s3/multipart/{uploadId}/{partNumber}`
Retrieves a presigned URL for uploading a specific part of a multipart upload.
#### Parameters
| Parameter | Type | Required | Description |
| ------------ | ------- | -------- | ------------------------------------------ |
| `uploadId` | string | Yes | Multipart upload ID from initiate response |
| `partNumber` | integer | Yes | Part number (1-based, 1-10000) |
| `s3Key` | string | Yes | Upload key from initiate response |
| `size` | integer | Yes | Size of the file |
#### Example Request
```bash theme={null}
GET /v2/upload/s3/multipart/abc123def456/1?s3Key=uploads/user123/large-file.zip&size=104857600
```
#### Response
```json theme={null}
{
"url": "https://storage.example.com/bucket/path/file.zip?partNumber=1&uploadId=...",
"method": "PUT"
}
```
### 4. Complete Multipart Upload
**Endpoint:** `POST /v2/upload/s3/multipart/{uploadId}/complete`
Completes a multipart upload by providing information about all uploaded parts.
#### Parameters
| Parameter | Type | Required | Description |
| ---------- | ------ | -------- | --------------------------------- |
| `uploadId` | string | Yes | Multipart upload ID |
| `s3Key` | string | Yes | Upload key from initiate response |
#### Request Body
```json theme={null}
{
"parts": [
{
"ETag": "\"abc123def456\"",
"PartNumber": 1
},
{
"ETag": "\"def789ghi012\"",
"PartNumber": 2
}
]
}
```
#### Response
```json theme={null}
{
"success": true,
"location": "https://storage.example.com/bucket/uploads/user123/large-file.zip"
}
```
### 5. Cancel Multipart Upload
**Endpoint:** `DELETE /v2/upload/s3/multipart/{uploadId}`
Cancels a multipart upload and cleans up any uploaded parts.
#### Parameters
| Parameter | Type | Required | Description |
| ---------- | ------ | -------- | --------------------------------- |
| `uploadId` | string | Yes | Multipart upload ID to cancel |
| `s3Key` | string | Yes | Upload key from initiate response |
#### Response
```json theme={null}
{
"success": true,
"message": "Multipart upload cancelled successfully"
}
```
## Upload Workflows
### Simple Upload Flow
```text theme={null}
1. POST /v2/upload/s3/params → Get presigned URL and upload object
2. PUT to presigned URL → Upload file directly to S3
3. Poll GET /v2/upload/:uploadId for AV scan completion
4. File is ready for use when upload.status=SUCCESS and upload.FileId is a number
```
### Multipart Upload Flow
```text theme={null}
1. POST /v2/upload/s3/multipart → Get upload ID and key
2. For each part:
- GET /v2/upload/s3/multipart/{uploadId}/{partNumber} → Get part URL
- PUT to part URL → Upload part to S3
- Save ETag from response
3. POST /v2/upload/s3/multipart/{uploadId}/complete → Complete upload
4. Poll GET /v2/upload/:uploadId for AV scan completion
5. File is ready for use when upload.status=SUCCESS and upload.FileId is a number
```
## Implementation Examples
### Node.js Example
```javascript theme={null}
const axios = require("axios");
const fs = require("fs");
// Initialize axios with base URL
const api = axios.create({
baseURL: "https://api.lilt.com/v2",
headers: {
Authorization: "Bearer YOUR_API_KEY"
}
});
// Single file upload
async function uploadFile(filePath, filename, contentType) {
const fileBuffer = fs.readFileSync(filePath);
// 1. Initiate upload
const { data: uploadParams } = await api.post("/upload/s3/params", {
filename,
type: contentType,
metadata: {
size: fileBuffer.length
}
});
// 2. Upload to S3 using presigned URL
await axios.put(uploadParams.url, fileBuffer, {
headers: {
"Content-Type": contentType,
...uploadParams.headers
}
});
console.log("Upload successful");
}
// Multipart upload for large files
async function uploadLargeFile(filePath, filename, contentType) {
const fileBuffer = fs.readFileSync(filePath);
const chunkSize = 8 * 1024 * 1024; // 8MB chunks
// 1. Initiate multipart upload
const { data: initResponse } = await api.post("/upload/s3/multipart", {
filename,
type: contentType,
metadata: {
size: fileBuffer.length
}
});
const { uploadId, key } = initResponse;
const parts = [];
// 2. Upload each part
for (let i = 0; i < fileBuffer.length; i += chunkSize) {
const partNumber = Math.floor(i / chunkSize) + 1;
const chunk = fileBuffer.slice(i, i + chunkSize);
// Get presigned URL for this part
const { data: partParams } = await api.get(
`/upload/s3/multipart/${uploadId}/${partNumber}`,
{
params: {
s3Key: key,
size: chunk.length
}
}
);
// Upload part
const response = await axios.put(partParams.url, chunk, {
headers: {
"Content-Type": contentType
}
});
parts.push({
ETag: response.headers.etag,
PartNumber: partNumber
});
}
// 3. Complete multipart upload
await api.post(
`/upload/s3/multipart/${uploadId}/complete`,
{
parts
},
{
params: {
s3Key: key
}
}
);
console.log("Multipart upload successful");
}
```
### Python Example
```python theme={null}
import requests
import os
from typing import List, Dict
class LiltUploadClient:
def __init__(self, api_key: str, base_url: str = "https://api.lilt.com/v2"):
self.api_key = api_key
self.base_url = base_url
self.headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
def upload_file(self, file_path: str, filename: str, content_type: str):
"""Upload a single file"""
with open(file_path, 'rb') as f:
file_data = f.read()
# 1. Initiate upload
response = requests.post(
f"{self.base_url}/upload/s3/params",
json={
"filename": filename,
"type": content_type,
"metadata": {
"size": len(file_data)
}
},
headers=self.headers
)
response.raise_for_status()
upload_params = response.json()
# 2. Upload to S3
upload_headers = {
'Content-Type': content_type,
**upload_params.get('headers', {})
}
upload_response = requests.put(
upload_params['url'],
data=file_data,
headers=upload_headers
)
upload_response.raise_for_status()
print("Upload successful")
def upload_large_file(self, file_path: str, filename: str, content_type: str, chunk_size: int = 8 * 1024 * 1024):
"""Upload a large file using multipart upload"""
file_size = os.path.getsize(file_path)
# 1. Initiate multipart upload
response = requests.post(
f"{self.base_url}/upload/s3/multipart",
json={
"filename": filename,
"type": content_type,
"metadata": {
"size": file_size
}
},
headers=self.headers
)
response.raise_for_status()
init_response = response.json()
upload_id = init_response['uploadId']
key = init_response['key']
parts = []
# 2. Upload each part
with open(file_path, 'rb') as f:
part_number = 1
while True:
chunk = f.read(chunk_size)
if not chunk:
break
# Get presigned URL for this part
part_response = requests.get(
f"{self.base_url}/upload/s3/multipart/{upload_id}/{part_number}",
params={
's3Key': key,
'size': len(chunk)
},
headers=self.headers
)
part_response.raise_for_status()
part_params = part_response.json()
# Upload part
upload_response = requests.put(
part_params['url'],
data=chunk,
headers={'Content-Type': content_type}
)
upload_response.raise_for_status()
parts.append({
'ETag': upload_response.headers['etag'],
'PartNumber': part_number
})
part_number += 1
# 3. Complete multipart upload
complete_response = requests.post(
f"{self.base_url}/upload/s3/multipart/{upload_id}/complete",
json={'parts': parts},
params={'s3Key': key},
headers=self.headers
)
complete_response.raise_for_status()
print("Multipart upload successful")
# Usage
client = LiltUploadClient('your-api-key')
client.upload_file('/path/to/file.pdf', 'document.pdf', 'application/pdf')
```
### Java Example
```java theme={null}
import java.io.*;
import java.net.http.*;
import java.util.*;
import com.fasterxml.jackson.databind.ObjectMapper;
public class LiltUploadClient {
private final String apiKey;
private final String baseUrl;
private final HttpClient httpClient;
private final ObjectMapper objectMapper;
public LiltUploadClient(String apiKey, String baseUrl) {
this.apiKey = apiKey;
this.baseUrl = baseUrl != null ? baseUrl : "https://api.lilt.com/v2";
this.httpClient = HttpClient.newHttpClient();
this.objectMapper = new ObjectMapper();
}
public void uploadFile(String filePath, String filename, String contentType) throws Exception {
byte[] fileData = Files.readAllBytes(Paths.get(filePath));
// 1. Initiate upload
Map uploadRequest = new HashMap<>();
uploadRequest.put("filename", filename);
uploadRequest.put("type", contentType);
Map metadata = new HashMap<>();
metadata.put("size", fileData.length);
uploadRequest.put("metadata", metadata);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/upload/s3/params"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(objectMapper.writeValueAsString(uploadRequest)))
.build();
HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
throw new RuntimeException("Failed to initiate upload: " + response.body());
}
Map uploadParams = objectMapper.readValue(response.body(), Map.class);
// 2. Upload to S3
HttpRequest.Builder uploadRequestBuilder = HttpRequest.newBuilder()
.uri(URI.create((String) uploadParams.get("url")))
.header("Content-Type", contentType)
.PUT(HttpRequest.BodyPublishers.ofByteArray(fileData));
// Add any additional headers
Map headers = (Map) uploadParams.get("headers");
if (headers != null) {
headers.forEach(uploadRequestBuilder::header);
}
HttpRequest uploadRequest = uploadRequestBuilder.build();
HttpResponse uploadResponse = httpClient.send(uploadRequest, HttpResponse.BodyHandlers.ofString());
if (uploadResponse.statusCode() != 200) {
throw new RuntimeException("Failed to upload file: " + uploadResponse.body());
}
System.out.println("Upload successful");
}
public void uploadLargeFile(String filePath, String filename, String contentType) throws Exception {
File file = new File(filePath);
long fileSize = file.length();
int chunkSize = 8 * 1024 * 1024; // 8MB chunks
// 1. Initiate multipart upload
Map uploadRequest = new HashMap<>();
uploadRequest.put("filename", filename);
uploadRequest.put("type", contentType);
Map metadata = new HashMap<>();
metadata.put("size", fileSize);
uploadRequest.put("metadata", metadata);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/upload/s3/multipart"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(objectMapper.writeValueAsString(uploadRequest)))
.build();
HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
Map initResponse = objectMapper.readValue(response.body(), Map.class);
String uploadId = (String) initResponse.get("uploadId");
String key = (String) initResponse.get("key");
List