Translations
Import master translations JSON
Import translations for multiple workflows from master JSON format for a specific locale
POST
/
v2
/
translations
/
master-json
TypeScript
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.import({
locale: "en_US",
masterJson: {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
});
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Translations.Master.ImportAsync(importMasterJsonRequestDto: new ImportMasterJsonRequestDto() {
Locale = "en_US",
MasterJson = new Dictionary<string, object>() {
{ "workflows", new Dictionary<string, object>() {
{ "welcome-email", new Dictionary<string, object>() {
{ "welcome.title", "Welcome to our platform" },
{ "welcome.message", "Hello there!" },
} },
{ "password-reset", new Dictionary<string, object>() {
{ "reset.title", "Reset your password" },
{ "reset.message", "Click the link to reset" },
} },
} },
},
});
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$importMasterJsonRequestDto = new Components\ImportMasterJsonRequestDto(
locale: 'en_US',
masterJson: [
'workflows' => [
'welcome-email' => [
'welcome.title' => 'Welcome to our platform',
'welcome.message' => 'Hello there!',
],
'password-reset' => [
'reset.title' => 'Reset your password',
'reset.message' => 'Click the link to reset',
],
],
],
);
$response = $sdk->translations->master->import(
importMasterJsonRequestDto: $importMasterJsonRequestDto
);
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.import_master_json(import_master_json_request_dto={
"locale": "en_US",
"master_json": {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Translations.Master.Import(ctx, components.ImportMasterJSONRequestDto{
Locale: "en_US",
MasterJSON: map[string]any{
"workflows": map[string]any{
"welcome-email": map[string]any{
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": map[string]any{
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
}, 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 \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"locale": "en_US",
"masterJson": {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!"
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset"
}
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
locale: 'en_US',
masterJson: {
workflows: {
'welcome-email': {'welcome.title': 'Welcome to our platform', 'welcome.message': 'Hello there!'},
'password-reset': {
'reset.title': 'Reset your password',
'reset.message': 'Click the link to reset'
}
}
}
})
};
fetch('https://api.novu.co/v2/translations/master-json', 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")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"locale\": \"en_US\",\n \"masterJson\": {\n \"workflows\": {\n \"welcome-email\": {\n \"welcome.title\": \"Welcome to our platform\",\n \"welcome.message\": \"Hello there!\"\n },\n \"password-reset\": {\n \"reset.title\": \"Reset your password\",\n \"reset.message\": \"Click the link to reset\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/translations/master-json")
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 \"locale\": \"en_US\",\n \"masterJson\": {\n \"workflows\": {\n \"welcome-email\": {\n \"welcome.title\": \"Welcome to our platform\",\n \"welcome.message\": \"Hello there!\"\n },\n \"password-reset\": {\n \"reset.title\": \"Reset your password\",\n \"reset.message\": \"Click the link to reset\"\n }\n }\n }\n}"
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
application/json
The locale for which translations are being imported
Example:
"en_US"
Master JSON object containing all translations organized by workflow identifier
Example:
{
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!"
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset"
}
}
}
Response
200 - application/json
Master translations imported 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";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.import({
locale: "en_US",
masterJson: {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
});
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Translations.Master.ImportAsync(importMasterJsonRequestDto: new ImportMasterJsonRequestDto() {
Locale = "en_US",
MasterJson = new Dictionary<string, object>() {
{ "workflows", new Dictionary<string, object>() {
{ "welcome-email", new Dictionary<string, object>() {
{ "welcome.title", "Welcome to our platform" },
{ "welcome.message", "Hello there!" },
} },
{ "password-reset", new Dictionary<string, object>() {
{ "reset.title", "Reset your password" },
{ "reset.message", "Click the link to reset" },
} },
} },
},
});
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$importMasterJsonRequestDto = new Components\ImportMasterJsonRequestDto(
locale: 'en_US',
masterJson: [
'workflows' => [
'welcome-email' => [
'welcome.title' => 'Welcome to our platform',
'welcome.message' => 'Hello there!',
],
'password-reset' => [
'reset.title' => 'Reset your password',
'reset.message' => 'Click the link to reset',
],
],
],
);
$response = $sdk->translations->master->import(
importMasterJsonRequestDto: $importMasterJsonRequestDto
);
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.import_master_json(import_master_json_request_dto={
"locale": "en_US",
"master_json": {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Translations.Master.Import(ctx, components.ImportMasterJSONRequestDto{
Locale: "en_US",
MasterJSON: map[string]any{
"workflows": map[string]any{
"welcome-email": map[string]any{
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": map[string]any{
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
}, 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 \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"locale": "en_US",
"masterJson": {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!"
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset"
}
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
locale: 'en_US',
masterJson: {
workflows: {
'welcome-email': {'welcome.title': 'Welcome to our platform', 'welcome.message': 'Hello there!'},
'password-reset': {
'reset.title': 'Reset your password',
'reset.message': 'Click the link to reset'
}
}
}
})
};
fetch('https://api.novu.co/v2/translations/master-json', 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")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"locale\": \"en_US\",\n \"masterJson\": {\n \"workflows\": {\n \"welcome-email\": {\n \"welcome.title\": \"Welcome to our platform\",\n \"welcome.message\": \"Hello there!\"\n },\n \"password-reset\": {\n \"reset.title\": \"Reset your password\",\n \"reset.message\": \"Click the link to reset\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/translations/master-json")
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 \"locale\": \"en_US\",\n \"masterJson\": {\n \"workflows\": {\n \"welcome-email\": {\n \"welcome.title\": \"Welcome to our platform\",\n \"welcome.message\": \"Hello there!\"\n },\n \"password-reset\": {\n \"reset.title\": \"Reset your password\",\n \"reset.message\": \"Click the link to reset\"\n }\n }\n }\n}"
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"
]
}