cURL
curl "https://api.phrase.com/v2/projects/:project_id/job_templates" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-d '{"branch":"my-feature-branch","name":"template","briefing":"text"}' \
-H 'Content-Type: application/json'phrase job_templates create \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "name":"template", "briefing":"text"}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/job_templates"
payload = {
"name": "template",
"branch": "my-feature-branch",
"briefing": "text",
"autotranslate": True,
"source_locale_id": "abcd1234cdef1234abcd1234cdef1234"
}
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({
name: 'template',
branch: 'my-feature-branch',
briefing: 'text',
autotranslate: true,
source_locale_id: 'abcd1234cdef1234abcd1234cdef1234'
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/job_templates', 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}/job_templates",
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([
'name' => 'template',
'branch' => 'my-feature-branch',
'briefing' => 'text',
'autotranslate' => true,
'source_locale_id' => 'abcd1234cdef1234abcd1234cdef1234'
]),
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}/job_templates"
payload := strings.NewReader("{\n \"name\": \"template\",\n \"branch\": \"my-feature-branch\",\n \"briefing\": \"text\",\n \"autotranslate\": true,\n \"source_locale_id\": \"abcd1234cdef1234abcd1234cdef1234\"\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}/job_templates")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"template\",\n \"branch\": \"my-feature-branch\",\n \"briefing\": \"text\",\n \"autotranslate\": true,\n \"source_locale_id\": \"abcd1234cdef1234abcd1234cdef1234\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/job_templates")
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 \"name\": \"template\",\n \"branch\": \"my-feature-branch\",\n \"briefing\": \"text\",\n \"autotranslate\": true,\n \"source_locale_id\": \"abcd1234cdef1234abcd1234cdef1234\"\n}"
response = http.request(request)
puts response.read_body{
"id": "626ea67628690c73ac86ac81eec2d185",
"name": "template",
"briefing": "text",
"created_at": "2017-01-28T09:52:53Z",
"updated_at": "2017-01-28T09:52:53Z",
"project": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "My Android Project",
"main_format": "xml",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
},
"owner": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"creator": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"locales": [
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "English",
"code": "en-GB"
}
]
}{
"message": "Validation Failed",
"errors": [
{
"resource": "Resource",
"field": "name",
"message": "can't be blank"
}
]
}Job Templates
Create a job template
Create a new job template.
POST
/
projects
/
{project_id}
/
job_templates
cURL
curl "https://api.phrase.com/v2/projects/:project_id/job_templates" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-d '{"branch":"my-feature-branch","name":"template","briefing":"text"}' \
-H 'Content-Type: application/json'phrase job_templates create \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "name":"template", "briefing":"text"}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/job_templates"
payload = {
"name": "template",
"branch": "my-feature-branch",
"briefing": "text",
"autotranslate": True,
"source_locale_id": "abcd1234cdef1234abcd1234cdef1234"
}
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({
name: 'template',
branch: 'my-feature-branch',
briefing: 'text',
autotranslate: true,
source_locale_id: 'abcd1234cdef1234abcd1234cdef1234'
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/job_templates', 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}/job_templates",
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([
'name' => 'template',
'branch' => 'my-feature-branch',
'briefing' => 'text',
'autotranslate' => true,
'source_locale_id' => 'abcd1234cdef1234abcd1234cdef1234'
]),
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}/job_templates"
payload := strings.NewReader("{\n \"name\": \"template\",\n \"branch\": \"my-feature-branch\",\n \"briefing\": \"text\",\n \"autotranslate\": true,\n \"source_locale_id\": \"abcd1234cdef1234abcd1234cdef1234\"\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}/job_templates")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"template\",\n \"branch\": \"my-feature-branch\",\n \"briefing\": \"text\",\n \"autotranslate\": true,\n \"source_locale_id\": \"abcd1234cdef1234abcd1234cdef1234\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/job_templates")
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 \"name\": \"template\",\n \"branch\": \"my-feature-branch\",\n \"briefing\": \"text\",\n \"autotranslate\": true,\n \"source_locale_id\": \"abcd1234cdef1234abcd1234cdef1234\"\n}"
response = http.request(request)
puts response.read_body{
"id": "626ea67628690c73ac86ac81eec2d185",
"name": "template",
"briefing": "text",
"created_at": "2017-01-28T09:52:53Z",
"updated_at": "2017-01-28T09:52:53Z",
"project": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "My Android Project",
"main_format": "xml",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
},
"owner": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"creator": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"locales": [
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "English",
"code": "en-GB"
}
]
}{
"message": "Validation Failed",
"errors": [
{
"resource": "Resource",
"field": "name",
"message": "can't be blank"
}
]
}Authorizations
TokenBasic
Enter your token in the format token TOKEN
Headers
Two-Factor-Authentication token (optional)
Path Parameters
Project ID
Body
application/json
Job template name
Example:
"template"
specify the branch to use
Example:
"my-feature-branch"
Briefing for the translators
Example:
"text"
Automatically translate the job using machine translation.
Example:
true
The API id of the source language. This locale will be set as source locale for the job template. If not provided, the project default locale will be used.
Example:
"abcd1234cdef1234abcd1234cdef1234"
Response
Created
Show child attributes
Show child attributes
Example:
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "My Android Project",
"main_format": "xml",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
}
When true, jobs created from this template are auto-translated on creation.
Show child attributes
Show child attributes
Example:
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
}
Show child attributes
Show child attributes
Example:
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
}
Show child attributes
Show child attributes
Was this page helpful?
⌘I