Translations
Upload master translations JSON file
Upload a master JSON file containing translations for multiple workflows. Locale is automatically detected from filename (e.g., en_US.json)
POST
/
v2
/
translations
/
master-json
/
upload
TypeScript
import { Novu } from "@novu/api";
import { openAsBlob } from "node:fs";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.upload({
file: await openAsBlob("example.file"),
});
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Translations.Master.UploadAsync(requestBody: new TranslationControllerUploadMasterJsonEndpointRequestBody() {
File = new Novu.Models.Requests.File() {
FileName = "example.file",
Content = System.IO.File.ReadAllBytes("example.file"),
},
});
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Operations;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$requestBody = new Operations\TranslationControllerUploadMasterJsonEndpointRequestBody(
file: new Operations\File(
fileName: 'example.file',
content: file_get_contents('example.file');,
),
);
$response = $sdk->translations->master->upload(
requestBody: $requestBody
);
if ($response->importMasterJsonResponseDto !== null) {
// handle response
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.translations.master.upload(request_body={
"file": {
"file_name": "example.file",
"content": open("example.file", "rb"),
},
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"os"
"github.com/novuhq/novu-go/v3/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
example, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
res, err := s.Translations.Master.Upload(ctx, operations.TranslationControllerUploadMasterJSONEndpointRequestBody{
File: operations.File{
FileName: "example.file",
Content: example,
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.ImportMasterJSONResponseDto != nil {
// handle response
}
}curl --request POST \
--url https://api.novu.co/v2/translations/master-json/upload \
--header 'Authorization: <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
options.body = form;
fetch('https://api.novu.co/v2/translations/master-json/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.novu.co/v2/translations/master-json/upload")
.header("Authorization", "<api-key>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/translations/master-json/upload")
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"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Successfully imported translations for 2 resources: welcome-email, password-reset",
"successful": [
"welcome-email",
"password-reset"
],
"failed": [
"missing-workflow"
]
}Authorizations
secretKeysecretKey
API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".
Headers
A header for idempotency purposes
Body
multipart/form-data
Master JSON file with locale as filename (e.g., en_US.json)
Response
200 - application/json
Master translations uploaded successfully
Overall success status of the import operation
Example:
true
Human-readable message describing the import result
Example:
"Successfully imported translations for 2 resources: welcome-email, password-reset"
List of resource IDs that were successfully imported
Example:
["welcome-email", "password-reset"]
List of resource IDs that failed to import
Example:
["missing-workflow"]
Was this page helpful?
⌘I
TypeScript
import { Novu } from "@novu/api";
import { openAsBlob } from "node:fs";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.upload({
file: await openAsBlob("example.file"),
});
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Translations.Master.UploadAsync(requestBody: new TranslationControllerUploadMasterJsonEndpointRequestBody() {
File = new Novu.Models.Requests.File() {
FileName = "example.file",
Content = System.IO.File.ReadAllBytes("example.file"),
},
});
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Operations;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$requestBody = new Operations\TranslationControllerUploadMasterJsonEndpointRequestBody(
file: new Operations\File(
fileName: 'example.file',
content: file_get_contents('example.file');,
),
);
$response = $sdk->translations->master->upload(
requestBody: $requestBody
);
if ($response->importMasterJsonResponseDto !== null) {
// handle response
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.translations.master.upload(request_body={
"file": {
"file_name": "example.file",
"content": open("example.file", "rb"),
},
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"os"
"github.com/novuhq/novu-go/v3/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
example, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
res, err := s.Translations.Master.Upload(ctx, operations.TranslationControllerUploadMasterJSONEndpointRequestBody{
File: operations.File{
FileName: "example.file",
Content: example,
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.ImportMasterJSONResponseDto != nil {
// handle response
}
}curl --request POST \
--url https://api.novu.co/v2/translations/master-json/upload \
--header 'Authorization: <api-key>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
options.body = form;
fetch('https://api.novu.co/v2/translations/master-json/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.novu.co/v2/translations/master-json/upload")
.header("Authorization", "<api-key>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/translations/master-json/upload")
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"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Successfully imported translations for 2 resources: welcome-email, password-reset",
"successful": [
"welcome-email",
"password-reset"
],
"failed": [
"missing-workflow"
]
}