curl "https://api.phrase.com/v2/projects/:project_id/upload_batches" \
-X POST \
-H "Content-Type: application/json" \
-d '{
"branch": "my-feature-branch",
"delete_unmentioned_keys": true,
"upload_ids": [
"abcd1234cdef1234abcd1234cdef1234",
"bcde2345defg2345bcde2345defg2345"
]
}' \
-u <token>:phrase upload_batches create --project-id :project_id \
--data '{
"branch": "my-feature-branch",
"delete_unmentioned_keys": true,
"upload_ids": [
"abcd1234cdef1234abcd1234cdef1234",
"bcde2345defg2345bcde2345defg2345"
]
}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/upload_batches"
payload = {
"upload_ids": ["abcd1234cdef1234abcd1234cdef1234", "bcde2345defg2345bcde2345defg2345"],
"branch": "my-feature-branch",
"delete_unmentioned_keys": True
}
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({
upload_ids: ['abcd1234cdef1234abcd1234cdef1234', 'bcde2345defg2345bcde2345defg2345'],
branch: 'my-feature-branch',
delete_unmentioned_keys: true
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/upload_batches', 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}/upload_batches",
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([
'upload_ids' => [
'abcd1234cdef1234abcd1234cdef1234',
'bcde2345defg2345bcde2345defg2345'
],
'branch' => 'my-feature-branch',
'delete_unmentioned_keys' => true
]),
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}/upload_batches"
payload := strings.NewReader("{\n \"upload_ids\": [\n \"abcd1234cdef1234abcd1234cdef1234\",\n \"bcde2345defg2345bcde2345defg2345\"\n ],\n \"branch\": \"my-feature-branch\",\n \"delete_unmentioned_keys\": true\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}/upload_batches")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"upload_ids\": [\n \"abcd1234cdef1234abcd1234cdef1234\",\n \"bcde2345defg2345bcde2345defg2345\"\n ],\n \"branch\": \"my-feature-branch\",\n \"delete_unmentioned_keys\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/upload_batches")
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 \"upload_ids\": [\n \"abcd1234cdef1234abcd1234cdef1234\",\n \"bcde2345defg2345bcde2345defg2345\"\n ],\n \"branch\": \"my-feature-branch\",\n \"delete_unmentioned_keys\": true\n}"
response = http.request(request)
puts response.read_body{
"delete_unmentioned_keys": true,
"uploads_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"project": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "My Android Project",
"main_format": "xml",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
},
"user": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
},
"uploads": [
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"filename": "example.json",
"format": "json",
"state": "success",
"tag": "tag",
"summary": {
"locales_created": 2,
"translation_keys_created": 162,
"translation_keys_updated": 10,
"translation_keys_unmentioned": 0,
"translations_created": 291,
"translations_updated": 3,
"tags_created": 2,
"translation_keys_ignored": 0
},
"user": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
},
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
}
]
}{
"message": "Validation Failed",
"errors": [
{
"resource": "Resource",
"field": "name",
"message": "can't be blank"
}
]
}Create upload batch
Groups multiple file uploads into a single batch. Optionally, launches the deletion of unmentioned translation keys after all uploads in the batch are completed.
curl "https://api.phrase.com/v2/projects/:project_id/upload_batches" \
-X POST \
-H "Content-Type: application/json" \
-d '{
"branch": "my-feature-branch",
"delete_unmentioned_keys": true,
"upload_ids": [
"abcd1234cdef1234abcd1234cdef1234",
"bcde2345defg2345bcde2345defg2345"
]
}' \
-u <token>:phrase upload_batches create --project-id :project_id \
--data '{
"branch": "my-feature-branch",
"delete_unmentioned_keys": true,
"upload_ids": [
"abcd1234cdef1234abcd1234cdef1234",
"bcde2345defg2345bcde2345defg2345"
]
}' \
--access_token <token>import requests
url = "https://api.phrase.com/v2/projects/{project_id}/upload_batches"
payload = {
"upload_ids": ["abcd1234cdef1234abcd1234cdef1234", "bcde2345defg2345bcde2345defg2345"],
"branch": "my-feature-branch",
"delete_unmentioned_keys": True
}
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({
upload_ids: ['abcd1234cdef1234abcd1234cdef1234', 'bcde2345defg2345bcde2345defg2345'],
branch: 'my-feature-branch',
delete_unmentioned_keys: true
})
};
fetch('https://api.phrase.com/v2/projects/{project_id}/upload_batches', 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}/upload_batches",
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([
'upload_ids' => [
'abcd1234cdef1234abcd1234cdef1234',
'bcde2345defg2345bcde2345defg2345'
],
'branch' => 'my-feature-branch',
'delete_unmentioned_keys' => true
]),
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}/upload_batches"
payload := strings.NewReader("{\n \"upload_ids\": [\n \"abcd1234cdef1234abcd1234cdef1234\",\n \"bcde2345defg2345bcde2345defg2345\"\n ],\n \"branch\": \"my-feature-branch\",\n \"delete_unmentioned_keys\": true\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}/upload_batches")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"upload_ids\": [\n \"abcd1234cdef1234abcd1234cdef1234\",\n \"bcde2345defg2345bcde2345defg2345\"\n ],\n \"branch\": \"my-feature-branch\",\n \"delete_unmentioned_keys\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phrase.com/v2/projects/{project_id}/upload_batches")
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 \"upload_ids\": [\n \"abcd1234cdef1234abcd1234cdef1234\",\n \"bcde2345defg2345bcde2345defg2345\"\n ],\n \"branch\": \"my-feature-branch\",\n \"delete_unmentioned_keys\": true\n}"
response = http.request(request)
puts response.read_body{
"delete_unmentioned_keys": true,
"uploads_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"project": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "My Android Project",
"main_format": "xml",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
},
"user": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
},
"uploads": [
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"filename": "example.json",
"format": "json",
"state": "success",
"tag": "tag",
"summary": {
"locales_created": 2,
"translation_keys_created": 162,
"translation_keys_updated": 10,
"translation_keys_unmentioned": 0,
"translations_created": 291,
"translations_updated": 3,
"tags_created": 2,
"translation_keys_ignored": 0
},
"user": {
"id": "abcd1234cdef1234abcd1234cdef1234",
"username": "johndoe",
"name": "John Doe",
"gravatar_uid": "205e460b479e2e5b48aec07710c08d50"
},
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
}
]
}{
"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
Array of upload IDs to include in the batch
[
"abcd1234cdef1234abcd1234cdef1234",
"bcde2345defg2345bcde2345defg2345"
]
specify the branch to use
"my-feature-branch"
If set to true, after all uploads in the batch are completed, translation keys that were not mentioned in any of the uploaded files will be deleted.
true
Response
Created
Processing state of the upload batch
started, done Indicates whether unmentioned keys will be deleted after processing all uploads in the batch
Number of uploads attached to this batch.
Show child attributes
Show child attributes
{
"id": "abcd1234cdef1234abcd1234cdef1234",
"name": "My Android Project",
"main_format": "xml",
"created_at": "2015-01-28T09:52:53Z",
"updated_at": "2015-01-28T09:52:53Z"
}
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?