JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const notificationContentMutationResponse = await client.journeys.templates.putLocale('x', {
templateId: 'x',
notificationId: 'x',
elements: [
{ id: 'elem_1', content: 'Hola {{data.name}}.' },
{ id: 'elem_2', title: 'Bienvenido!' },
],
state: 'DRAFT',
});
console.log(notificationContentMutationResponse.id);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
notification_content_mutation_response = client.journeys.templates.put_locale(
locale_id="x",
template_id="x",
notification_id="x",
elements=[{
"id": "elem_1",
"content": "Hola {{data.name}}.",
}, {
"id": "elem_2",
"title": "Bienvenido!",
}],
state="DRAFT",
)
print(notification_content_mutation_response.id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
notificationContentMutationResponse, err := client.Journeys.Templates.PutLocale(
context.TODO(),
"x",
courier.JourneyTemplatePutLocaleParams{
TemplateID: "x",
NotificationID: "x",
NotificationLocalePutRequest: courier.NotificationLocalePutRequestParam{
Elements: []courier.NotificationLocalePutRequestElementParam{{
ID: "elem_1",
}, {
ID: "elem_2",
}},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", notificationContentMutationResponse.ID)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.journeys.templates.TemplatePutLocaleParams;
import com.courier.models.notifications.NotificationContentMutationResponse;
import com.courier.models.notifications.NotificationLocalePutRequest;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplatePutLocaleParams params = TemplatePutLocaleParams.builder()
.templateId("x")
.notificationId("x")
.localeId("x")
.notificationLocalePutRequest(NotificationLocalePutRequest.builder()
.addElement(NotificationLocalePutRequest.Element.builder()
.id("elem_1")
.build())
.addElement(NotificationLocalePutRequest.Element.builder()
.id("elem_2")
.build())
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.journeys().templates().putLocale(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.journeys.templates.put_locale(
"x",
template_id: "x",
notification_id: "x",
elements: [{id: "elem_1"}, {id: "elem_2"}]
)
puts(notification_content_mutation_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
use Courier\Notifications\NotificationTemplateState;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$notificationContentMutationResponse = $client
->journeys
->templates
->putLocale(
'x',
templateID: 'x',
notificationID: 'x',
elements: [['id' => 'elem_1'], ['id' => 'elem_2']],
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Journeys.Templates;
CourierClient client = new();
TemplatePutLocaleParams parameters = new()
{
TemplateID = "x",
NotificationID = "x",
LocaleID = "x",
Elements =
[
new("elem_1"), new("elem_2")
],
};
var notificationContentMutationResponse = await client.Journeys.Templates.PutLocale(parameters);
Console.WriteLine(notificationContentMutationResponse);courier journeys:templates put-locale \
--api-key 'My API Key' \
--template-id x \
--notification-id x \
--locale-id x \
--element '{id: elem_1}' \
--element '{id: elem_2}'curl --request PUT \
--url https://api.courier.com/journeys/{templateId}/templates/{notificationId}/locales/{localeId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"elements": [
{
"id": "elem_1",
"content": "Hola {{data.name}}."
},
{
"id": "elem_2",
"title": "Bienvenido!"
}
],
"state": "DRAFT"
}
'{
"id": "nt_01kx4h2jdafq8bk9aftxak4b40",
"version": "2022-01-01",
"elements": [
{
"id": "elem_1",
"checksum": "abc123"
},
{
"id": "elem_2",
"checksum": "def456"
}
],
"state": "DRAFT"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Journeys
Replace a single locale of a journey-scoped notification template
Set locale-specific content overrides for a journey-scoped notification template. Each element override must reference an existing element by ID.
PUT
/
journeys
/
{templateId}
/
templates
/
{notificationId}
/
locales
/
{localeId}
JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const notificationContentMutationResponse = await client.journeys.templates.putLocale('x', {
templateId: 'x',
notificationId: 'x',
elements: [
{ id: 'elem_1', content: 'Hola {{data.name}}.' },
{ id: 'elem_2', title: 'Bienvenido!' },
],
state: 'DRAFT',
});
console.log(notificationContentMutationResponse.id);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
notification_content_mutation_response = client.journeys.templates.put_locale(
locale_id="x",
template_id="x",
notification_id="x",
elements=[{
"id": "elem_1",
"content": "Hola {{data.name}}.",
}, {
"id": "elem_2",
"title": "Bienvenido!",
}],
state="DRAFT",
)
print(notification_content_mutation_response.id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
notificationContentMutationResponse, err := client.Journeys.Templates.PutLocale(
context.TODO(),
"x",
courier.JourneyTemplatePutLocaleParams{
TemplateID: "x",
NotificationID: "x",
NotificationLocalePutRequest: courier.NotificationLocalePutRequestParam{
Elements: []courier.NotificationLocalePutRequestElementParam{{
ID: "elem_1",
}, {
ID: "elem_2",
}},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", notificationContentMutationResponse.ID)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.journeys.templates.TemplatePutLocaleParams;
import com.courier.models.notifications.NotificationContentMutationResponse;
import com.courier.models.notifications.NotificationLocalePutRequest;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplatePutLocaleParams params = TemplatePutLocaleParams.builder()
.templateId("x")
.notificationId("x")
.localeId("x")
.notificationLocalePutRequest(NotificationLocalePutRequest.builder()
.addElement(NotificationLocalePutRequest.Element.builder()
.id("elem_1")
.build())
.addElement(NotificationLocalePutRequest.Element.builder()
.id("elem_2")
.build())
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.journeys().templates().putLocale(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.journeys.templates.put_locale(
"x",
template_id: "x",
notification_id: "x",
elements: [{id: "elem_1"}, {id: "elem_2"}]
)
puts(notification_content_mutation_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
use Courier\Notifications\NotificationTemplateState;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$notificationContentMutationResponse = $client
->journeys
->templates
->putLocale(
'x',
templateID: 'x',
notificationID: 'x',
elements: [['id' => 'elem_1'], ['id' => 'elem_2']],
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Journeys.Templates;
CourierClient client = new();
TemplatePutLocaleParams parameters = new()
{
TemplateID = "x",
NotificationID = "x",
LocaleID = "x",
Elements =
[
new("elem_1"), new("elem_2")
],
};
var notificationContentMutationResponse = await client.Journeys.Templates.PutLocale(parameters);
Console.WriteLine(notificationContentMutationResponse);courier journeys:templates put-locale \
--api-key 'My API Key' \
--template-id x \
--notification-id x \
--locale-id x \
--element '{id: elem_1}' \
--element '{id: elem_2}'curl --request PUT \
--url https://api.courier.com/journeys/{templateId}/templates/{notificationId}/locales/{localeId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"elements": [
{
"id": "elem_1",
"content": "Hola {{data.name}}."
},
{
"id": "elem_2",
"title": "Bienvenido!"
}
],
"state": "DRAFT"
}
'{
"id": "nt_01kx4h2jdafq8bk9aftxak4b40",
"version": "2022-01-01",
"elements": [
{
"id": "elem_1",
"checksum": "abc123"
},
{
"id": "elem_2",
"checksum": "def456"
}
],
"state": "DRAFT"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Journey id
Minimum string length:
1Notification template id
Minimum string length:
1Locale code (e.g., es, fr, pt-BR).
Minimum string length:
1Body
application/json
Request body for setting locale-specific content overrides. Each element override must include the target element ID.
Response
Updated scoped notification locale
Shared mutation response for PUT content, PUT element, and PUT locale operations. Contains the template ID, content version, per-element checksums, and resulting state.
⌘I