Skip to main content
PATCH
/
projects
/
{project_id}
/
keys
/
{id}
cURL
curl "https://api.phrase.com/v2/projects/:project_id/keys/:id" \
  -u USERNAME_OR_ACCESS_TOKEN \
  -X PATCH \
  -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]=value
phrase keys update \
--project_id <project_id> \
--id <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/{id}"

payload = {
"branch": "my-feature-branch",
"name": "home.index.headline",
"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,
"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.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
branch: 'my-feature-branch',
name: 'home.index.headline',
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,
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/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'branch' => 'my-feature-branch',
'name' => 'home.index.headline',
'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,
'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/{id}"

payload := strings.NewReader("{\n \"branch\": \"my-feature-branch\",\n \"name\": \"home.index.headline\",\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 \"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("PATCH", 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.patch("https://api.phrase.com/v2/projects/{project_id}/keys/{id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"branch\": \"my-feature-branch\",\n \"name\": \"home.index.headline\",\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 \"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/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"branch\": \"my-feature-branch\",\n \"name\": \"home.index.headline\",\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 \"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

Authorization
string
header
required

Enter your token in the format token TOKEN

Headers

X-PhraseApp-OTP
string

Two-Factor-Authentication token (optional)

Path Parameters

project_id
string
required

Project ID

id
string
required

ID

Body

application/json
branch
string

specify the branch to use

Example:

"my-feature-branch"

name
string

Key name

Example:

"home.index.headline"

description
string

Key description (usually includes contextual information for translators)

Example:

"Some description worth knowing..."

plural
boolean

Indicates whether key supports pluralization

Example:

null

use_ordinal_rules
boolean

Indicates whether key uses ordinal rules for pluralization

Example:

null

name_plural
string

Plural name for the key (used in some file formats, e.g. Gettext)

Example:

"home.index.headlines"

data_type
string

Type of the key. Can be one of the following: string, number, boolean, array, markdown.

Example:

"number"

tags
string

List of tags separated by comma to be associated with the key.

Example:

"awesome-feature,needs-proofreading"

max_characters_allowed
integer

Max. number of characters translations for this key can have.

Example:

140

screenshot
file
deprecated

Screenshot/image for the key. This parameter is deprecated. Please use the Screenshots endpoint instead.

remove_screenshot
boolean
deprecated

Indicates whether the screenshot will be deleted. This parameter is deprecated. Please use the Screenshots endpoint instead.

Example:

null

unformatted
boolean

Indicates whether the key should be exported as "unformatted". Supported by Android XML and other formats.

Example:

null

xml_space_preserve
boolean

Indicates whether the key should be exported with "xml:space=preserve". Supported by several XML-based formats.

Example:

null

original_file
string

Original file attribute. Used in some formats, e.g. XLIFF.

Example:

null

localized_format_string
string

NSStringLocalizedFormatKey attribute. Used in .stringsdict format.

Example:

null

localized_format_key
string

NSStringLocalizedFormatKey attribute. Used in .stringsdict format.

Example:

null

custom_metadata
object

Updates/Creates custom metadata property name and value pairs to be associated with key. If you want to delete a custom metadata property, you can set its value to null. If you want to update a custom metadata property, you can set its value to the new value.

Example:
{ "fruit": "Apple", "vegetable": "Tomato" }
excluded_in_locales
string[]

Locales for which translations of this key are excluded from exports. Pass an empty array to clear exclusions.

Example:
["de", "fr"]
format_value_type
string

Override of the value type for the key in the export. Most useful for formats like Android XML that distinguish string vs. plural resources.

Example:

"string"

Response

OK

id
string
name
string
description
string
name_hash
string
plural
boolean
use_ordinal_rules
boolean
tags
string[]
data_type
string
created_at
string<date-time>
updated_at
string<date-time>
name_plural
string
comments_count
integer
max_characters_allowed
integer
screenshot_url
string
unformatted
boolean
xml_space_preserve
boolean
original_file
string
format_value_type
string
creator
user_preview · object
Example:
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
}
custom_metadata
custom_metadata · object