curl "https://api.phrase.com/v2/projects/:project_id/keys" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-F branch=my-feature-branch \
-F name=home.index.headline \
-F description=Some%20description%20worth%20knowing... \
-F name_plural=home.index.headlines \
-F data_type=number \
-F tags=awesome-feature,needs-proofreading \
-F max_characters_allowed=140 \
-F screenshot=@/path/to/my/screenshot.png \
-F custom_metadata[property]=valuephrase keys create \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "name":"home.index.headline", "description": "Some description worth knowing...", "name_plural":"home.index.headlines", "data_type":"number", "tags":"awesome-feature,needs-proofreading", "max_characters_allowed":"140", "screenshot":"/path/to/my/screenshot.png", "custom_metadata": {"property" => "value"}}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/keys"
payload = {
"name": "home.index.headline",
"branch": "my-feature-branch",
"description": "Some description worth knowing...",
"plural": None,
"use_ordinal_rules": None,
"name_plural": "home.index.headlines",
"data_type": "number",
"tags": "awesome-feature,needs-proofreading",
"max_characters_allowed": 140,
"screenshot": "/path/to/my/screenshot.png",
"remove_screenshot": None,
"unformatted": None,
"default_translation_content": "Default translation content",
"autotranslate": None,
"xml_space_preserve": None,
"original_file": None,
"localized_format_string": None,
"localized_format_key": None,
"custom_metadata": {
"fruit": "Apple",
"vegetable": "Tomato"
},
"excluded_in_locales": ["de", "fr"],
"format_value_type": "string"
}
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: 'home.index.headline',
branch: 'my-feature-branch',
description: 'Some description worth knowing...',
plural: null,
use_ordinal_rules: null,
name_plural: 'home.index.headlines',
data_type: 'number',
tags: 'awesome-feature,needs-proofreading',
max_characters_allowed: 140,
screenshot: '/path/to/my/screenshot.png',
remove_screenshot: null,
unformatted: null,
default_translation_content: 'Default translation content',
autotranslate: null,
xml_space_preserve: null,
original_file: null,
localized_format_string: null,
localized_format_key: null,
custom_metadata: {fruit: 'Apple', vegetable: 'Tomato'},
excluded_in_locales: ['de', 'fr'],
format_value_type: 'string'
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/keys', 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}/keys",
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' => 'home.index.headline',
'branch' => 'my-feature-branch',
'description' => 'Some description worth knowing...',
'plural' => null,
'use_ordinal_rules' => null,
'name_plural' => 'home.index.headlines',
'data_type' => 'number',
'tags' => 'awesome-feature,needs-proofreading',
'max_characters_allowed' => 140,
'screenshot' => '/path/to/my/screenshot.png',
'remove_screenshot' => null,
'unformatted' => null,
'default_translation_content' => 'Default translation content',
'autotranslate' => null,
'xml_space_preserve' => null,
'original_file' => null,
'localized_format_string' => null,
'localized_format_key' => null,
'custom_metadata' => [
'fruit' => 'Apple',
'vegetable' => 'Tomato'
],
'excluded_in_locales' => [
'de',
'fr'
],
'format_value_type' => 'string'
]),
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}/keys"
payload := strings.NewReader("{\n \"name\": \"home.index.headline\",\n \"branch\": \"my-feature-branch\",\n \"description\": \"Some description worth knowing...\",\n \"plural\": null,\n \"use_ordinal_rules\": null,\n \"name_plural\": \"home.index.headlines\",\n \"data_type\": \"number\",\n \"tags\": \"awesome-feature,needs-proofreading\",\n \"max_characters_allowed\": 140,\n \"screenshot\": \"/path/to/my/screenshot.png\",\n \"remove_screenshot\": null,\n \"unformatted\": null,\n \"default_translation_content\": \"Default translation content\",\n \"autotranslate\": null,\n \"xml_space_preserve\": null,\n \"original_file\": null,\n \"localized_format_string\": null,\n \"localized_format_key\": null,\n \"custom_metadata\": {\n \"fruit\": \"Apple\",\n \"vegetable\": \"Tomato\"\n },\n \"excluded_in_locales\": [\n \"de\",\n \"fr\"\n ],\n \"format_value_type\": \"string\"\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}/keys")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"home.index.headline\",\n \"branch\": \"my-feature-branch\",\n \"description\": \"Some description worth knowing...\",\n \"plural\": null,\n \"use_ordinal_rules\": null,\n \"name_plural\": \"home.index.headlines\",\n \"data_type\": \"number\",\n \"tags\": \"awesome-feature,needs-proofreading\",\n \"max_characters_allowed\": 140,\n \"screenshot\": \"/path/to/my/screenshot.png\",\n \"remove_screenshot\": null,\n \"unformatted\": null,\n \"default_translation_content\": \"Default translation content\",\n \"autotranslate\": null,\n \"xml_space_preserve\": null,\n \"original_file\": null,\n \"localized_format_string\": null,\n \"localized_format_key\": null,\n \"custom_metadata\": {\n \"fruit\": \"Apple\",\n \"vegetable\": \"Tomato\"\n },\n \"excluded_in_locales\": [\n \"de\",\n \"fr\"\n ],\n \"format_value_type\": \"string\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/keys")
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\": \"home.index.headline\",\n \"branch\": \"my-feature-branch\",\n \"description\": \"Some description worth knowing...\",\n \"plural\": null,\n \"use_ordinal_rules\": null,\n \"name_plural\": \"home.index.headlines\",\n \"data_type\": \"number\",\n \"tags\": \"awesome-feature,needs-proofreading\",\n \"max_characters_allowed\": 140,\n \"screenshot\": \"/path/to/my/screenshot.png\",\n \"remove_screenshot\": null,\n \"unformatted\": null,\n \"default_translation_content\": \"Default translation content\",\n \"autotranslate\": null,\n \"xml_space_preserve\": null,\n \"original_file\": null,\n \"localized_format_string\": null,\n \"localized_format_key\": null,\n \"custom_metadata\": {\n \"fruit\": \"Apple\",\n \"vegetable\": \"Tomato\"\n },\n \"excluded_in_locales\": [\n \"de\",\n \"fr\"\n ],\n \"format_value_type\": \"string\"\n}"
response = http.request(request)
puts response.read_body{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "home.index.headline",
"description": "My description for this key...",
"name_hash": "1b31d2580ce324f246f66b3be00ed399",
"plural": false,
"use_ordinal_rules": false,
"tags": [
"awesome-feature",
"needs-proofreading"
],
"data_type": "string",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z",
"name_plural": "home.index.headlines",
"comments_count": 2,
"max_characters_allowed": 140,
"screenshot_url": "http://assets.example.com/screenshot.png",
"unformatted": false,
"xml_space_preserve": false,
"original_file": "",
"format_value_type": "",
"creator": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"custom_metadata": {
"fruit": "Apple",
"vegetable": "Tomato"
}
}{
"message": "Validation Failed",
"errors": [
{
"resource": "Resource",
"field": "name",
"message": "can't be blank"
}
]
}Create a key
Create a new key.
curl "https://api.phrase.com/v2/projects/:project_id/keys" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-F branch=my-feature-branch \
-F name=home.index.headline \
-F description=Some%20description%20worth%20knowing... \
-F name_plural=home.index.headlines \
-F data_type=number \
-F tags=awesome-feature,needs-proofreading \
-F max_characters_allowed=140 \
-F screenshot=@/path/to/my/screenshot.png \
-F custom_metadata[property]=valuephrase keys create \
--project_id <project_id> \
--data '{"branch":"my-feature-branch", "name":"home.index.headline", "description": "Some description worth knowing...", "name_plural":"home.index.headlines", "data_type":"number", "tags":"awesome-feature,needs-proofreading", "max_characters_allowed":"140", "screenshot":"/path/to/my/screenshot.png", "custom_metadata": {"property" => "value"}}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/keys"
payload = {
"name": "home.index.headline",
"branch": "my-feature-branch",
"description": "Some description worth knowing...",
"plural": None,
"use_ordinal_rules": None,
"name_plural": "home.index.headlines",
"data_type": "number",
"tags": "awesome-feature,needs-proofreading",
"max_characters_allowed": 140,
"screenshot": "/path/to/my/screenshot.png",
"remove_screenshot": None,
"unformatted": None,
"default_translation_content": "Default translation content",
"autotranslate": None,
"xml_space_preserve": None,
"original_file": None,
"localized_format_string": None,
"localized_format_key": None,
"custom_metadata": {
"fruit": "Apple",
"vegetable": "Tomato"
},
"excluded_in_locales": ["de", "fr"],
"format_value_type": "string"
}
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: 'home.index.headline',
branch: 'my-feature-branch',
description: 'Some description worth knowing...',
plural: null,
use_ordinal_rules: null,
name_plural: 'home.index.headlines',
data_type: 'number',
tags: 'awesome-feature,needs-proofreading',
max_characters_allowed: 140,
screenshot: '/path/to/my/screenshot.png',
remove_screenshot: null,
unformatted: null,
default_translation_content: 'Default translation content',
autotranslate: null,
xml_space_preserve: null,
original_file: null,
localized_format_string: null,
localized_format_key: null,
custom_metadata: {fruit: 'Apple', vegetable: 'Tomato'},
excluded_in_locales: ['de', 'fr'],
format_value_type: 'string'
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/keys', 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}/keys",
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' => 'home.index.headline',
'branch' => 'my-feature-branch',
'description' => 'Some description worth knowing...',
'plural' => null,
'use_ordinal_rules' => null,
'name_plural' => 'home.index.headlines',
'data_type' => 'number',
'tags' => 'awesome-feature,needs-proofreading',
'max_characters_allowed' => 140,
'screenshot' => '/path/to/my/screenshot.png',
'remove_screenshot' => null,
'unformatted' => null,
'default_translation_content' => 'Default translation content',
'autotranslate' => null,
'xml_space_preserve' => null,
'original_file' => null,
'localized_format_string' => null,
'localized_format_key' => null,
'custom_metadata' => [
'fruit' => 'Apple',
'vegetable' => 'Tomato'
],
'excluded_in_locales' => [
'de',
'fr'
],
'format_value_type' => 'string'
]),
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}/keys"
payload := strings.NewReader("{\n \"name\": \"home.index.headline\",\n \"branch\": \"my-feature-branch\",\n \"description\": \"Some description worth knowing...\",\n \"plural\": null,\n \"use_ordinal_rules\": null,\n \"name_plural\": \"home.index.headlines\",\n \"data_type\": \"number\",\n \"tags\": \"awesome-feature,needs-proofreading\",\n \"max_characters_allowed\": 140,\n \"screenshot\": \"/path/to/my/screenshot.png\",\n \"remove_screenshot\": null,\n \"unformatted\": null,\n \"default_translation_content\": \"Default translation content\",\n \"autotranslate\": null,\n \"xml_space_preserve\": null,\n \"original_file\": null,\n \"localized_format_string\": null,\n \"localized_format_key\": null,\n \"custom_metadata\": {\n \"fruit\": \"Apple\",\n \"vegetable\": \"Tomato\"\n },\n \"excluded_in_locales\": [\n \"de\",\n \"fr\"\n ],\n \"format_value_type\": \"string\"\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}/keys")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"home.index.headline\",\n \"branch\": \"my-feature-branch\",\n \"description\": \"Some description worth knowing...\",\n \"plural\": null,\n \"use_ordinal_rules\": null,\n \"name_plural\": \"home.index.headlines\",\n \"data_type\": \"number\",\n \"tags\": \"awesome-feature,needs-proofreading\",\n \"max_characters_allowed\": 140,\n \"screenshot\": \"/path/to/my/screenshot.png\",\n \"remove_screenshot\": null,\n \"unformatted\": null,\n \"default_translation_content\": \"Default translation content\",\n \"autotranslate\": null,\n \"xml_space_preserve\": null,\n \"original_file\": null,\n \"localized_format_string\": null,\n \"localized_format_key\": null,\n \"custom_metadata\": {\n \"fruit\": \"Apple\",\n \"vegetable\": \"Tomato\"\n },\n \"excluded_in_locales\": [\n \"de\",\n \"fr\"\n ],\n \"format_value_type\": \"string\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/keys")
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\": \"home.index.headline\",\n \"branch\": \"my-feature-branch\",\n \"description\": \"Some description worth knowing...\",\n \"plural\": null,\n \"use_ordinal_rules\": null,\n \"name_plural\": \"home.index.headlines\",\n \"data_type\": \"number\",\n \"tags\": \"awesome-feature,needs-proofreading\",\n \"max_characters_allowed\": 140,\n \"screenshot\": \"/path/to/my/screenshot.png\",\n \"remove_screenshot\": null,\n \"unformatted\": null,\n \"default_translation_content\": \"Default translation content\",\n \"autotranslate\": null,\n \"xml_space_preserve\": null,\n \"original_file\": null,\n \"localized_format_string\": null,\n \"localized_format_key\": null,\n \"custom_metadata\": {\n \"fruit\": \"Apple\",\n \"vegetable\": \"Tomato\"\n },\n \"excluded_in_locales\": [\n \"de\",\n \"fr\"\n ],\n \"format_value_type\": \"string\"\n}"
response = http.request(request)
puts response.read_body{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "home.index.headline",
"description": "My description for this key...",
"name_hash": "1b31d2580ce324f246f66b3be00ed399",
"plural": false,
"use_ordinal_rules": false,
"tags": [
"awesome-feature",
"needs-proofreading"
],
"data_type": "string",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z",
"name_plural": "home.index.headlines",
"comments_count": 2,
"max_characters_allowed": 140,
"screenshot_url": "http://assets.example.com/screenshot.png",
"unformatted": false,
"xml_space_preserve": false,
"original_file": "",
"format_value_type": "",
"creator": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "joe.doe",
"name": "Joe Doe"
},
"custom_metadata": {
"fruit": "Apple",
"vegetable": "Tomato"
}
}{
"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
Key name
"home.index.headline"
specify the branch to use
"my-feature-branch"
Key description (usually includes contextual information for translators)
"Some description worth knowing..."
Indicates whether key supports pluralization
null
Indicates whether key uses ordinal rules for pluralization
null
Plural name for the key (used in some file formats, e.g. Gettext)
"home.index.headlines"
Type of the key. Can be one of the following: string, number, boolean, array, markdown.
"number"
List of tags separated by comma to be associated with the key.
"awesome-feature,needs-proofreading"
Max. number of characters translations for this key can have.
140
Screenshot/image for the key. This parameter is deprecated. Please use the Screenshots endpoint instead.
Indicates whether the screenshot will be deleted. This parameter is deprecated. Please use the Screenshots endpoint instead.
null
Indicates whether the key should be exported as "unformatted". Supported by Android XML and other formats.
null
Creates a translation in the default locale with the specified content
"Default translation content"
Indicates whether the key should be autotranslated to other locales based on the copy provided in default_translation_content.
null
Indicates whether the key should be exported with "xml:space=preserve". Supported by several XML-based formats.
null
Original file attribute. Used in some formats, e.g. XLIFF.
null
NSStringLocalizedFormatKey attribute. Used in .stringsdict format.
null
NSStringLocalizedFormatKey attribute. Used in .stringsdict format.
null
Custom metadata property name and value pairs to be associated with key.
{ "fruit": "Apple", "vegetable": "Tomato" }
Locales for which translations of this key are excluded from exports. Pass an empty array to clear exclusions.
["de", "fr"]
Override of the value type for the key in the export. Most useful for formats like Android XML that distinguish string vs. plural resources.
"string"
Response
Created
Show child attributes
Show child attributes
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
}
Show child attributes
Show child attributes
Was this page helpful?