curl --request POST \
--url https://api.lilt.com/v2/documents/pretranslate \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"id": [
274,
275
],
"mode": "TM",
"auto_accept": true,
"case_sensitive": true,
"attribute_to_creator": true
}
'import requests
url = "https://api.lilt.com/v2/documents/pretranslate"
payload = {
"id": [274, 275],
"mode": "TM",
"auto_accept": True,
"case_sensitive": True,
"attribute_to_creator": True
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: [274, 275],
mode: 'TM',
auto_accept: true,
case_sensitive: true,
attribute_to_creator: true
})
};
fetch('https://api.lilt.com/v2/documents/pretranslate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lilt.com/v2/documents/pretranslate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => [
274,
275
],
'mode' => 'TM',
'auto_accept' => true,
'case_sensitive' => true,
'attribute_to_creator' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.lilt.com/v2/documents/pretranslate"
payload := strings.NewReader("{\n \"id\": [\n 274,\n 275\n ],\n \"mode\": \"TM\",\n \"auto_accept\": true,\n \"case_sensitive\": true,\n \"attribute_to_creator\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.lilt.com/v2/documents/pretranslate")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"id\": [\n 274,\n 275\n ],\n \"mode\": \"TM\",\n \"auto_accept\": true,\n \"case_sensitive\": true,\n \"attribute_to_creator\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lilt.com/v2/documents/pretranslate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": [\n 274,\n 275\n ],\n \"mode\": \"TM\",\n \"auto_accept\": true,\n \"case_sensitive\": true,\n \"attribute_to_creator\": true\n}"
response = http.request(request)
puts response.read_body{
"id": [
274,
275
],
"is_pretranslating": true,
"documents": [
{
"id": 46530,
"project_id": 287,
"srclang": "en",
"trglang": "de",
"name": "Introduction.xliff",
"import_in_progress": false,
"import_succeeded": false,
"import_error_message": "Could not parse XML.",
"export_in_progress": false,
"export_succeeded": false,
"export_error_message": "Could not parse XML.",
"is_pretranslating": false,
"status": {
"pretranslation": "idle"
},
"translator_email": "translator@example.com",
"reviewer_email": "reviewer@example.com",
"customer_reviewer_email": "reviewer@example.com",
"created_at": 1489147692,
"updated_at": 1489147692,
"is_review_complete": true
}
]
}"<string>"{
"message": "Internal server error."
}{
"message": "Internal server error."
}Pretranslate Documents
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 for details on
how to read 429 responses and batch requests efficiently by passing
multiple document ids in a single call.
Example CURL:
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}'
curl --request POST \
--url https://api.lilt.com/v2/documents/pretranslate \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"id": [
274,
275
],
"mode": "TM",
"auto_accept": true,
"case_sensitive": true,
"attribute_to_creator": true
}
'import requests
url = "https://api.lilt.com/v2/documents/pretranslate"
payload = {
"id": [274, 275],
"mode": "TM",
"auto_accept": True,
"case_sensitive": True,
"attribute_to_creator": True
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: [274, 275],
mode: 'TM',
auto_accept: true,
case_sensitive: true,
attribute_to_creator: true
})
};
fetch('https://api.lilt.com/v2/documents/pretranslate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lilt.com/v2/documents/pretranslate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => [
274,
275
],
'mode' => 'TM',
'auto_accept' => true,
'case_sensitive' => true,
'attribute_to_creator' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.lilt.com/v2/documents/pretranslate"
payload := strings.NewReader("{\n \"id\": [\n 274,\n 275\n ],\n \"mode\": \"TM\",\n \"auto_accept\": true,\n \"case_sensitive\": true,\n \"attribute_to_creator\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.lilt.com/v2/documents/pretranslate")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"id\": [\n 274,\n 275\n ],\n \"mode\": \"TM\",\n \"auto_accept\": true,\n \"case_sensitive\": true,\n \"attribute_to_creator\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lilt.com/v2/documents/pretranslate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": [\n 274,\n 275\n ],\n \"mode\": \"TM\",\n \"auto_accept\": true,\n \"case_sensitive\": true,\n \"attribute_to_creator\": true\n}"
response = http.request(request)
puts response.read_body{
"id": [
274,
275
],
"is_pretranslating": true,
"documents": [
{
"id": 46530,
"project_id": 287,
"srclang": "en",
"trglang": "de",
"name": "Introduction.xliff",
"import_in_progress": false,
"import_succeeded": false,
"import_error_message": "Could not parse XML.",
"export_in_progress": false,
"export_succeeded": false,
"export_error_message": "Could not parse XML.",
"is_pretranslating": false,
"status": {
"pretranslation": "idle"
},
"translator_email": "translator@example.com",
"reviewer_email": "reviewer@example.com",
"customer_reviewer_email": "reviewer@example.com",
"created_at": 1489147692,
"updated_at": 1489147692,
"is_review_complete": true
}
]
}"<string>"{
"message": "Internal server error."
}{
"message": "Internal server error."
}Authorizations
Query Parameters
Body
The Document id(s) to pretranslate, plus optional pretranslation options.
Response
Pretranslation has been queued. Returns the current state of every requested Document.
Was this page helpful?

