Translations
Create a translation
Create a translation for a specific workflow and locale, if the translation already exists, it will be updated
POST
/
v2
/
translations
TypeScript
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.create({
resourceId: "welcome-email",
resourceType: "workflow",
locale: "en_US",
content: {
"welcome.title": "Welcome",
"welcome.message": "Hello there!",
},
});
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.CreateAsync(createTranslationRequestDto: new CreateTranslationRequestDto() {
ResourceId = "welcome-email",
ResourceType = Novu.Models.Components.ResourceType.Workflow,
Locale = "en_US",
Content = new Dictionary<string, object>() {
{ "welcome.title", "Welcome" },
{ "welcome.message", "Hello there!" },
},
});
// 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();
$createTranslationRequestDto = new Components\CreateTranslationRequestDto(
resourceId: 'welcome-email',
resourceType: Components\ResourceType::Layout,
locale: 'en_US',
content: [
'welcome.title' => 'Welcome',
'welcome.message' => 'Hello there!',
],
);
$response = $sdk->translations->create(
createTranslationRequestDto: $createTranslationRequestDto
);
if ($response->translationResponseDto !== null) {
// handle response
}import novu_py
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.translations.create(create_translation_request_dto={
"resource_id": "welcome-email",
"resource_type": novu_py.ResourceType.LAYOUT,
"locale": "en_US",
"content": {
"welcome.title": "Welcome",
"welcome.message": "Hello there!",
},
})
# 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.Create(ctx, components.CreateTranslationRequestDto{
ResourceID: "welcome-email",
ResourceType: components.ResourceTypeWorkflow,
Locale: "en_US",
Content: map[string]any{
"welcome.title": "Welcome",
"welcome.message": "Hello there!",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.TranslationResponseDto != nil {
// handle response
}
}curl --request POST \
--url https://api.novu.co/v2/translations \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"resourceId": "welcome-email",
"locale": "en_US",
"content": {
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resourceId: 'welcome-email',
locale: 'en_US',
content: {'welcome.title': 'Welcome', 'welcome.message': 'Hello there!'}
})
};
fetch('https://api.novu.co/v2/translations', 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")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resourceId\": \"welcome-email\",\n \"locale\": \"en_US\",\n \"content\": {\n \"welcome.title\": \"Welcome\",\n \"welcome.message\": \"Hello there!\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/translations")
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 \"resourceId\": \"welcome-email\",\n \"locale\": \"en_US\",\n \"content\": {\n \"welcome.title\": \"Welcome\",\n \"welcome.message\": \"Hello there!\"\n }\n}"
response = http.request(request)
puts response.read_body{
"resourceId": "welcome-email",
"resourceType": "workflow",
"locale": "en_US",
"content": {
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
},
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}Authorizations
secretKeysecretKey
API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".
Headers
A header for idempotency purposes
Body
application/json
The resource ID to associate translation with. Accepts identifier or slug format
Example:
"welcome-email"
The resource type to associate translation with
Available options:
workflow, layout Locale code (e.g., en_US, es_ES)
Example:
"en_US"
Translation content as JSON object
Example:
{
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
}
Response
200 - application/json
Translation created or updated successfully
Resource identifier
Example:
"welcome-email"
Resource type
Available options:
workflow, layout Example:
"workflow"
Locale code
Example:
"en_US"
Translation content as JSON object
Example:
{
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
}
Creation timestamp
Example:
"2024-01-01T00:00:00.000Z"
Last update timestamp
Example:
"2024-01-01T00:00:00.000Z"
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.create({
resourceId: "welcome-email",
resourceType: "workflow",
locale: "en_US",
content: {
"welcome.title": "Welcome",
"welcome.message": "Hello there!",
},
});
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.CreateAsync(createTranslationRequestDto: new CreateTranslationRequestDto() {
ResourceId = "welcome-email",
ResourceType = Novu.Models.Components.ResourceType.Workflow,
Locale = "en_US",
Content = new Dictionary<string, object>() {
{ "welcome.title", "Welcome" },
{ "welcome.message", "Hello there!" },
},
});
// 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();
$createTranslationRequestDto = new Components\CreateTranslationRequestDto(
resourceId: 'welcome-email',
resourceType: Components\ResourceType::Layout,
locale: 'en_US',
content: [
'welcome.title' => 'Welcome',
'welcome.message' => 'Hello there!',
],
);
$response = $sdk->translations->create(
createTranslationRequestDto: $createTranslationRequestDto
);
if ($response->translationResponseDto !== null) {
// handle response
}import novu_py
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.translations.create(create_translation_request_dto={
"resource_id": "welcome-email",
"resource_type": novu_py.ResourceType.LAYOUT,
"locale": "en_US",
"content": {
"welcome.title": "Welcome",
"welcome.message": "Hello there!",
},
})
# 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.Create(ctx, components.CreateTranslationRequestDto{
ResourceID: "welcome-email",
ResourceType: components.ResourceTypeWorkflow,
Locale: "en_US",
Content: map[string]any{
"welcome.title": "Welcome",
"welcome.message": "Hello there!",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.TranslationResponseDto != nil {
// handle response
}
}curl --request POST \
--url https://api.novu.co/v2/translations \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"resourceId": "welcome-email",
"locale": "en_US",
"content": {
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resourceId: 'welcome-email',
locale: 'en_US',
content: {'welcome.title': 'Welcome', 'welcome.message': 'Hello there!'}
})
};
fetch('https://api.novu.co/v2/translations', 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")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resourceId\": \"welcome-email\",\n \"locale\": \"en_US\",\n \"content\": {\n \"welcome.title\": \"Welcome\",\n \"welcome.message\": \"Hello there!\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/translations")
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 \"resourceId\": \"welcome-email\",\n \"locale\": \"en_US\",\n \"content\": {\n \"welcome.title\": \"Welcome\",\n \"welcome.message\": \"Hello there!\"\n }\n}"
response = http.request(request)
puts response.read_body{
"resourceId": "welcome-email",
"resourceType": "workflow",
"locale": "en_US",
"content": {
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
},
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}