Skip to main content
POST
/
v2
/
translations
/
master-json
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();

$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
}
{
  "success": true,
  "message": "Successfully imported translations for 2 resources: welcome-email, password-reset",
  "successful": [
    "welcome-email",
    "password-reset"
  ],
  "failed": [
    "missing-workflow"
  ]
}

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
locale
string
required

The locale for which translations are being imported

Example:

"en_US"

masterJson
object
required

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

success
boolean
required

Overall success status of the import operation

Example:

true

message
string
required

Human-readable message describing the import result

Example:

"Successfully imported translations for 2 resources: welcome-email, password-reset"

successful
string[]

List of resource IDs that were successfully imported

Example:
["welcome-email", "password-reset"]
failed
string[]

List of resource IDs that failed to import

Example:
["missing-workflow"]