curl --request POST \
--url https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"strings": [
{
"key": "<string>",
"filePath": "<string>",
"sourceText": "<string>",
"context": "<string>",
"type": "<string>",
"maxLength": 50000,
"hidden": true
}
],
"keepApproved": false
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
strings: [
{
key: '<string>',
filePath: '<string>',
sourceText: '<string>',
context: '<string>',
type: '<string>',
maxLength: 50000,
hidden: true
}
],
keepApproved: false
})
};
fetch('https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch"
payload = {
"strings": [
{
"key": "<string>",
"filePath": "<string>",
"sourceText": "<string>",
"context": "<string>",
"type": "<string>",
"maxLength": 50000,
"hidden": True
}
],
"keepApproved": False
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch"
payload := strings.NewReader("{\n \"strings\": [\n {\n \"key\": \"<string>\",\n \"filePath\": \"<string>\",\n \"sourceText\": \"<string>\",\n \"context\": \"<string>\",\n \"type\": \"<string>\",\n \"maxLength\": 50000,\n \"hidden\": true\n }\n ],\n \"keepApproved\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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))
}{
"created": 1,
"updated": 1,
"strings": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "<string>",
"sourceText": "<string>",
"context": "<string>",
"type": "<string>",
"maxLength": 123,
"hidden": true,
"filePath": "<string>",
"tags": [
"<string>"
],
"designUrl": "<string>",
"customMetadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
]
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}Create or update strings in bulk
Requires strings:write. Native projects only. Each item matches a string by key and filePath (no filePath means a string in no file). A match is updated with the fields the item sets; otherwise a string is created and sourceText is required. The batch runs in one transaction: if an item fails, nothing is saved and the X-Failed-Item header holds its index. Changing the source text of a locked string returns 409, and so does changing the source text of a string in a file while the project’s “Allow source text editing” setting is off, or of a hidden string, or in a file that isn’t JSON, JSONC or ARB, came from an integration, or was last uploaded before uploads were recorded (source_text_not_editable). New source text holding the control characters U+001E or U+0000 returns 400 (invalid_source_text). Only admins, localization managers and developers may change the source text of a string in a file (403). Surrounding spaces alone are not a change. In a project whose “When source text changes” setting is “Needs review”, changing a string’s source text moves its approved translations back to needs_review, unless keepApproved is true.
curl --request POST \
--url https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"strings": [
{
"key": "<string>",
"filePath": "<string>",
"sourceText": "<string>",
"context": "<string>",
"type": "<string>",
"maxLength": 50000,
"hidden": true
}
],
"keepApproved": false
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
strings: [
{
key: '<string>',
filePath: '<string>',
sourceText: '<string>',
context: '<string>',
type: '<string>',
maxLength: 50000,
hidden: true
}
],
keepApproved: false
})
};
fetch('https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch"
payload = {
"strings": [
{
"key": "<string>",
"filePath": "<string>",
"sourceText": "<string>",
"context": "<string>",
"type": "<string>",
"maxLength": 50000,
"hidden": True
}
],
"keepApproved": False
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.hyperlocalise.com/v1/projects/{projectId}/strings/batch"
payload := strings.NewReader("{\n \"strings\": [\n {\n \"key\": \"<string>\",\n \"filePath\": \"<string>\",\n \"sourceText\": \"<string>\",\n \"context\": \"<string>\",\n \"type\": \"<string>\",\n \"maxLength\": 50000,\n \"hidden\": true\n }\n ],\n \"keepApproved\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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))
}{
"created": 1,
"updated": 1,
"strings": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "<string>",
"sourceText": "<string>",
"context": "<string>",
"type": "<string>",
"maxLength": 123,
"hidden": true,
"filePath": "<string>",
"tags": [
"<string>"
],
"designUrl": "<string>",
"customMetadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
]
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}{
"error": "<string>",
"message": "<string>",
"details": {}
}Body
Was this page helpful?

