Skip to main content
POST
/
v2
/
documents
/
pretranslate
Pretranslate Documents
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

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Query Parameters

auto_accept
boolean

Auto-accept segments with 100% translation memory matches. Can also be passed in the request body. Defaults to your organization's Accept and lock exact matches setting.

case_sensitive
boolean

Use case-sensitive translation memory matching. Can also be passed in the request body. Defaults to your organization's Use case sensitive translation memory matching setting.

attribute_to_creator
boolean

Attribute translation authorship of exact matches to the author of the document. Can also be passed in the request body. Defaults to your organization's Translation authorship setting.

mode
enum<string>
default:TM

Pretranslation mode. Can also be passed in the request body. Defaults to TM.

Available options:
TM,
TM+MT

Body

application/json

The Document id(s) to pretranslate, plus optional pretranslation options.

id
required

A Document id, or an array of Document ids, to pretranslate.

Example:
[274, 275]
mode
enum<string>
default:TM

Pretranslation mode. Defaults to TM.

Available options:
TM,
TM+MT
auto_accept
boolean

Auto-accept segments with 100% translation memory matches. Defaults to your organization's Accept and lock exact matches setting.

case_sensitive
boolean

Use case-sensitive translation memory matching. Defaults to your organization's Use case sensitive translation memory matching setting.

attribute_to_creator
boolean

Attribute translation authorship of exact matches to the author of the document. Defaults to your organization's Translation authorship setting.

Response

Pretranslation has been queued. Returns the current state of every requested Document.

id
integer[]

The Document ids that were requested.

Example:
[274, 275]
is_pretranslating
boolean

Always true for a successfully queued request.

Example:

true

documents
object[]

The current state of each requested Document.