curl --request POST \
--url https://api.lilt.com/v2/documents/files \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/octet-stream' \
--header 'name: <name>' \
--header 'project_id: <project_id>' \
--data '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2">
...
</xliff>'import requests
url = "https://api.lilt.com/v2/documents/files"
payload = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>"
headers = {
"name": "<name>",
"project_id": "<project_id>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
name: '<name>',
project_id: '<project_id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/octet-stream'
},
body: '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2">\n...\n</xliff>'
};
fetch('https://api.lilt.com/v2/documents/files', 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/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/octet-stream",
"name: <name>",
"project_id: <project_id>"
],
]);
$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/files"
payload := strings.NewReader("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("name", "<name>")
req.Header.Add("project_id", "<project_id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/octet-stream")
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/files")
.header("name", "<name>")
.header("project_id", "<project_id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/octet-stream")
.body("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lilt.com/v2/documents/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["name"] = '<name>'
request["project_id"] = '<project_id>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/octet-stream'
request.body = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>"
response = http.request(request)
puts response.read_body{
"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",
"created_at": 1489147692,
"updated_at": 1489147692,
"is_review_complete": true,
"segments": [
{
"id": 84480010,
"created_at": 1489147692,
"updated_at": 1489147692,
"document_id": 1234,
"memory_id": 5678,
"source": "The red bus.",
"srclang": "en",
"target": "Le bus rouge.",
"trglang": "fr",
"is_confirmed": true,
"is_reviewed": true
}
]
}"<string>"{
"message": "Internal server error."
}Upload a File
Create a Document from a file in any of the formats documented in our knowledge base.
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. File names with characters outside of US-ASCII should be URI encoded or transliterated to US-ASCII strings.
Example CURL command:
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
curl --request POST \
--url https://api.lilt.com/v2/documents/files \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/octet-stream' \
--header 'name: <name>' \
--header 'project_id: <project_id>' \
--data '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2">
...
</xliff>'import requests
url = "https://api.lilt.com/v2/documents/files"
payload = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>"
headers = {
"name": "<name>",
"project_id": "<project_id>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
name: '<name>',
project_id: '<project_id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/octet-stream'
},
body: '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2">\n...\n</xliff>'
};
fetch('https://api.lilt.com/v2/documents/files', 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/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/octet-stream",
"name: <name>",
"project_id: <project_id>"
],
]);
$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/files"
payload := strings.NewReader("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("name", "<name>")
req.Header.Add("project_id", "<project_id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/octet-stream")
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/files")
.header("name", "<name>")
.header("project_id", "<project_id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/octet-stream")
.body("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lilt.com/v2/documents/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["name"] = '<name>'
request["project_id"] = '<project_id>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/octet-stream'
request.body = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n...\n</xliff>"
response = http.request(request)
puts response.read_body{
"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",
"created_at": 1489147692,
"updated_at": 1489147692,
"is_review_complete": true,
"segments": [
{
"id": 84480010,
"created_at": 1489147692,
"updated_at": 1489147692,
"document_id": 1234,
"memory_id": 5678,
"source": "The red bus.",
"srclang": "en",
"target": "Le bus rouge.",
"trglang": "fr",
"is_confirmed": true,
"is_reviewed": true
}
]
}"<string>"{
"message": "Internal server error."
}Authorizations
Headers
An optional parameter to auto-accept segments with 100% translation
memory matches when the pretranslate option is also set, or to
auto-accept any target data that is present when the uploaded file
is XLIFF. If omitted it will default to your organization settings for Accept and lock exact matches,
if set to false, no segments will be auto-accepted.
An optional parameter to use case sensitive translation memory matching when the pretranslate
option is also enabled. Matches must have identical character-by-character case to qualify as matches.
Default value matches your organization settings for Use case sensitive translation memory matching setting
Body
The file contents to be uploaded. The entire POST body will be treated as the file.
The body is of type file.
Response
A Document object.
A Document is a collection of zero or more Segments.
Was this page helpful?

