curl "https://api.phrase.com/v2/projects/:project_id/translations" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-d '{"branch":"my-feature-branch","locale_id":"abcd1234cdef1234abcd1234cdef1234","key_id":"abcd1234cdef1234abcd1234cdef1234","content":"My translation"}' \
-H 'Content-Type: application/json'phrase translations create \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "locale_id":"abcd1234cdef1234abcd1234cdef1234", "key_id":"abcd1234cdef1234abcd1234cdef1234", "content": "My translation"}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/translations"
payload = {
"branch": "my-feature-branch",
"locale_id": "abcd1234cdef1234abcd1234cdef1234",
"key_id": "abcd1234cdef1234abcd1234cdef1234",
"content": "My translation",
"plural_suffix": None,
"unverified": None,
"excluded": None,
"autotranslate": None,
"minor_change": False,
"reviewed": False
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
branch: 'my-feature-branch',
locale_id: 'abcd1234cdef1234abcd1234cdef1234',
key_id: 'abcd1234cdef1234abcd1234cdef1234',
content: 'My translation',
plural_suffix: null,
unverified: null,
excluded: null,
autotranslate: null,
minor_change: false,
reviewed: false
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/translations', 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.phrase.com/v2/projects/{project_id}/translations",
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([
'branch' => 'my-feature-branch',
'locale_id' => 'abcd1234cdef1234abcd1234cdef1234',
'key_id' => 'abcd1234cdef1234abcd1234cdef1234',
'content' => 'My translation',
'plural_suffix' => null,
'unverified' => null,
'excluded' => null,
'autotranslate' => null,
'minor_change' => false,
'reviewed' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.phrase.com/v2/projects/{project_id}/translations"
payload := strings.NewReader("{\n \"branch\": \"my-feature-branch\",\n \"locale_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"key_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"content\": \"My translation\",\n \"plural_suffix\": null,\n \"unverified\": null,\n \"excluded\": null,\n \"autotranslate\": null,\n \"minor_change\": false,\n \"reviewed\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.phrase.com/v2/projects/{project_id}/translations")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"branch\": \"my-feature-branch\",\n \"locale_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"key_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"content\": \"My translation\",\n \"plural_suffix\": null,\n \"unverified\": null,\n \"excluded\": null,\n \"autotranslate\": null,\n \"minor_change\": false,\n \"reviewed\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/translations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"branch\": \"my-feature-branch\",\n \"locale_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"key_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"content\": \"My translation\",\n \"plural_suffix\": null,\n \"unverified\": null,\n \"excluded\": null,\n \"autotranslate\": null,\n \"minor_change\": false,\n \"reviewed\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "abcd1234cdef1234abcd1234cdef1234",
"content": "My translation",
"unverified": false,
"excluded": false,
"plural_suffix": "",
"key": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "home.index.headline",
"plural": false,
"use_ordinal_rules": false
},
"locale": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "de",
"code": "de-DE"
},
"placeholders": [
"%{count}"
],
"state": "translated",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z",
"user": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"word_count": 2
}{
"message": "Validation Failed",
"errors": [
{
"resource": "Resource",
"field": "name",
"message": "can't be blank"
}
]
}Create a translation
Create a translation.
curl "https://api.phrase.com/v2/projects/:project_id/translations" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-d '{"branch":"my-feature-branch","locale_id":"abcd1234cdef1234abcd1234cdef1234","key_id":"abcd1234cdef1234abcd1234cdef1234","content":"My translation"}' \
-H 'Content-Type: application/json'phrase translations create \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "locale_id":"abcd1234cdef1234abcd1234cdef1234", "key_id":"abcd1234cdef1234abcd1234cdef1234", "content": "My translation"}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/translations"
payload = {
"branch": "my-feature-branch",
"locale_id": "abcd1234cdef1234abcd1234cdef1234",
"key_id": "abcd1234cdef1234abcd1234cdef1234",
"content": "My translation",
"plural_suffix": None,
"unverified": None,
"excluded": None,
"autotranslate": None,
"minor_change": False,
"reviewed": False
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
branch: 'my-feature-branch',
locale_id: 'abcd1234cdef1234abcd1234cdef1234',
key_id: 'abcd1234cdef1234abcd1234cdef1234',
content: 'My translation',
plural_suffix: null,
unverified: null,
excluded: null,
autotranslate: null,
minor_change: false,
reviewed: false
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/translations', 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.phrase.com/v2/projects/{project_id}/translations",
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([
'branch' => 'my-feature-branch',
'locale_id' => 'abcd1234cdef1234abcd1234cdef1234',
'key_id' => 'abcd1234cdef1234abcd1234cdef1234',
'content' => 'My translation',
'plural_suffix' => null,
'unverified' => null,
'excluded' => null,
'autotranslate' => null,
'minor_change' => false,
'reviewed' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.phrase.com/v2/projects/{project_id}/translations"
payload := strings.NewReader("{\n \"branch\": \"my-feature-branch\",\n \"locale_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"key_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"content\": \"My translation\",\n \"plural_suffix\": null,\n \"unverified\": null,\n \"excluded\": null,\n \"autotranslate\": null,\n \"minor_change\": false,\n \"reviewed\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.phrase.com/v2/projects/{project_id}/translations")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"branch\": \"my-feature-branch\",\n \"locale_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"key_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"content\": \"My translation\",\n \"plural_suffix\": null,\n \"unverified\": null,\n \"excluded\": null,\n \"autotranslate\": null,\n \"minor_change\": false,\n \"reviewed\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/translations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"branch\": \"my-feature-branch\",\n \"locale_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"key_id\": \"abcd1234cdef1234abcd1234cdef1234\",\n \"content\": \"My translation\",\n \"plural_suffix\": null,\n \"unverified\": null,\n \"excluded\": null,\n \"autotranslate\": null,\n \"minor_change\": false,\n \"reviewed\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "abcd1234cdef1234abcd1234cdef1234",
"content": "My translation",
"unverified": false,
"excluded": false,
"plural_suffix": "",
"key": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "home.index.headline",
"plural": false,
"use_ordinal_rules": false
},
"locale": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "de",
"code": "de-DE"
},
"placeholders": [
"%{count}"
],
"state": "translated",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z",
"user": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"word_count": 2
}{
"message": "Validation Failed",
"errors": [
{
"resource": "Resource",
"field": "name",
"message": "can't be blank"
}
]
}Authorizations
Enter your token in the format token TOKEN
Headers
Two-Factor-Authentication token (optional)
Path Parameters
Project ID
Body
specify the branch to use
"my-feature-branch"
Locale. Can be the name or id of the locale. Preferred is id
"abcd1234cdef1234abcd1234cdef1234"
Key
"abcd1234cdef1234abcd1234cdef1234"
Translation content
"My translation"
Plural suffix. Can be one of: zero, one, two, few, many, other. Must be specified if the key associated to the translation is pluralized.
null
Indicates whether translation is unverified. Part of the Advanced Workflows feature.
null
Indicates whether translation is excluded.
null
Indicates whether the translation should be auto-translated. Responses with status 422 if provided for translation within a non-default locale or the project does not have the Autopilot feature enabled.
null
When true, the translation is marked as a minor edit and does not trigger downstream re-verification on the linked locales' translations.
false
When true and the project's review workflow is enabled, the translation is created in the reviewed state.
false
Response
Created
Show child attributes
Show child attributes
null
Show child attributes
Show child attributes
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "English",
"code": "en-GB"
}
Show child attributes
Show child attributes
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"content": "My parent translation"
}
Show child attributes
Show child attributes
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
}
Was this page helpful?