Skip to main content
POST
/
v2
/
translations
PHP
declare(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
}
{
  "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

Authorization
string
header
required

API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".

Headers

idempotency-key
string

A header for idempotency purposes

Body

application/json
resourceId
string
required

The resource ID to associate translation with. Accepts identifier or slug format

Example:

"welcome-email"

resourceType
enum<string>
required

The resource type to associate translation with

Available options:
workflow,
layout
locale
string
required

Locale code (e.g., en_US, es_ES)

Example:

"en_US"

content
object
required

Translation content as JSON object

Example:
{
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
}

Response

200 - application/json

Translation created or updated successfully

resourceId
string
required

Resource identifier

Example:

"welcome-email"

resourceType
enum<string>
required

Resource type

Available options:
workflow,
layout
Example:

"workflow"

locale
string
required

Locale code

Example:

"en_US"

content
object
required

Translation content as JSON object

Example:
{
"welcome.title": "Welcome",
"welcome.message": "Hello there!"
}
createdAt
string
required

Creation timestamp

Example:

"2024-01-01T00:00:00.000Z"

updatedAt
string
required

Last update timestamp

Example:

"2024-01-01T00:00:00.000Z"