Journeys
Replace the content of a Journey-scoped Notification Template
Replace the elemental content of a journey-scoped notification template. Overwrites all elements in the template draft with the provided content.
PUT
/
journeys
/
{templateId}
/
templates
/
{notificationId}
/
content
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.putContent('x', {
templateId: 'x',
content: {
version: '2022-01-01',
elements: [
{
type: 'channel',
channel: 'email',
elements: [
{ type: 'meta', title: 'Welcome!' },
{ type: 'text', content: 'Hello {{data.name}}.' },
],
},
],
},
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_content(
notification_id="x",
template_id="x",
content={
"version": "2022-01-01",
"elements": [{
"type": "channel",
"channel": "email",
"elements": [{
"type": "meta",
"title": "Welcome!",
}, {
"type": "text",
"content": "Hello {{data.name}}.",
}],
}],
},
state="DRAFT",
)
print(notification_content_mutation_response.id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
"github.com/trycourier/courier-go/v4/shared"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
notificationContentMutationResponse, err := client.Journeys.Templates.PutContent(
context.TODO(),
"x",
courier.JourneyTemplatePutContentParams{
TemplateID: "x",
NotificationContentPutRequest: courier.NotificationContentPutRequestParam{
Content: courier.NotificationContentPutRequestContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalTextNodeParam: shared.ElementalTextNodeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
},
}},
},
},
},
)
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.ElementalTextNodeWithType;
import com.courier.models.journeys.templates.TemplatePutContentParams;
import com.courier.models.notifications.NotificationContentMutationResponse;
import com.courier.models.notifications.NotificationContentPutRequest;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplatePutContentParams params = TemplatePutContentParams.builder()
.templateId("x")
.notificationId("x")
.notificationContentPutRequest(NotificationContentPutRequest.builder()
.content(NotificationContentPutRequest.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.build())
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.journeys().templates().putContent(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.journeys.templates.put_content("x", template_id: "x", content: {elements: [{}]})
puts(notification_content_mutation_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\TextStyle;
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
->putContent(
'x',
templateID: 'x',
content: [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'channel' => 'email',
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'title' => 'Welcome!',
'type' => 'meta',
],
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'align' => 'left',
'bold' => 'bold',
'color' => 'color',
'content' => 'Hello {{data.name}}.',
'fontSize' => 'font_size',
'format' => 'markdown',
'italic' => 'italic',
'lineHeight' => 'line_height',
'locales' => ['foo' => ['content' => 'content']],
'strikethrough' => 'strikethrough',
'textStyle' => TextStyle::TEXT,
'underline' => 'underline',
'type' => 'text',
],
],
'fontSize' => 'font_size',
'lineHeight' => 'line_height',
'padding' => 'padding',
'raw' => ['foo' => 'bar'],
'type' => 'channel',
],
],
'version' => '2022-01-01',
],
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Journeys.Templates;
CourierClient client = new();
TemplatePutContentParams parameters = new()
{
TemplateID = "x",
NotificationID = "x",
Content = new()
{
Elements =
[
new ElementalChannelNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Channel = "email",
Elements =
[
new UnionMember1()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Title = "Welcome!",
Type = UnionMember1IntersectionMember1Type.Meta,
},
new UnionMember0()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Align = Align.Left,
Bold = "bold",
Color = "color",
Content = "Hello {{data.name}}.",
FontSize = "font_size",
Format = Format.Markdown,
Italic = "italic",
LineHeight = "line_height",
Locales = new Dictionary<string, LocalesItem>()
{
{ "foo", new("content") }
},
Strikethrough = "strikethrough",
TextStyle = TextStyle.Text,
Underline = "underline",
Type = UnionMember0IntersectionMember1Type.Text,
},
],
FontSize = "font_size",
LineHeight = "line_height",
Padding = "padding",
Raw = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Type = ElementalChannelNodeWithTypeIntersectionMember1Type.Channel,
},
],
Version = "2022-01-01",
},
};
var notificationContentMutationResponse = await client.Journeys.Templates.PutContent(parameters);
Console.WriteLine(notificationContentMutationResponse);courier journeys:templates put-content \
--api-key 'My API Key' \
--template-id x \
--notification-id x \
--content '{elements: [{}]}'curl --request PUT \
--url https://api.courier.com/journeys/{templateId}/templates/{notificationId}/content \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "channel",
"channel": "email",
"elements": [
{
"type": "meta",
"title": "Welcome!"
},
{
"type": "text",
"content": "Hello {{data.name}}."
}
]
}
]
},
"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:
1Body
application/json
Response
Updated scoped notification content
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
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.putContent('x', {
templateId: 'x',
content: {
version: '2022-01-01',
elements: [
{
type: 'channel',
channel: 'email',
elements: [
{ type: 'meta', title: 'Welcome!' },
{ type: 'text', content: 'Hello {{data.name}}.' },
],
},
],
},
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_content(
notification_id="x",
template_id="x",
content={
"version": "2022-01-01",
"elements": [{
"type": "channel",
"channel": "email",
"elements": [{
"type": "meta",
"title": "Welcome!",
}, {
"type": "text",
"content": "Hello {{data.name}}.",
}],
}],
},
state="DRAFT",
)
print(notification_content_mutation_response.id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
"github.com/trycourier/courier-go/v4/shared"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
notificationContentMutationResponse, err := client.Journeys.Templates.PutContent(
context.TODO(),
"x",
courier.JourneyTemplatePutContentParams{
TemplateID: "x",
NotificationContentPutRequest: courier.NotificationContentPutRequestParam{
Content: courier.NotificationContentPutRequestContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalTextNodeParam: shared.ElementalTextNodeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
},
}},
},
},
},
)
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.ElementalTextNodeWithType;
import com.courier.models.journeys.templates.TemplatePutContentParams;
import com.courier.models.notifications.NotificationContentMutationResponse;
import com.courier.models.notifications.NotificationContentPutRequest;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplatePutContentParams params = TemplatePutContentParams.builder()
.templateId("x")
.notificationId("x")
.notificationContentPutRequest(NotificationContentPutRequest.builder()
.content(NotificationContentPutRequest.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.build())
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.journeys().templates().putContent(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.journeys.templates.put_content("x", template_id: "x", content: {elements: [{}]})
puts(notification_content_mutation_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\TextStyle;
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
->putContent(
'x',
templateID: 'x',
content: [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'channel' => 'email',
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'title' => 'Welcome!',
'type' => 'meta',
],
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'align' => 'left',
'bold' => 'bold',
'color' => 'color',
'content' => 'Hello {{data.name}}.',
'fontSize' => 'font_size',
'format' => 'markdown',
'italic' => 'italic',
'lineHeight' => 'line_height',
'locales' => ['foo' => ['content' => 'content']],
'strikethrough' => 'strikethrough',
'textStyle' => TextStyle::TEXT,
'underline' => 'underline',
'type' => 'text',
],
],
'fontSize' => 'font_size',
'lineHeight' => 'line_height',
'padding' => 'padding',
'raw' => ['foo' => 'bar'],
'type' => 'channel',
],
],
'version' => '2022-01-01',
],
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Journeys.Templates;
CourierClient client = new();
TemplatePutContentParams parameters = new()
{
TemplateID = "x",
NotificationID = "x",
Content = new()
{
Elements =
[
new ElementalChannelNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Channel = "email",
Elements =
[
new UnionMember1()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Title = "Welcome!",
Type = UnionMember1IntersectionMember1Type.Meta,
},
new UnionMember0()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Align = Align.Left,
Bold = "bold",
Color = "color",
Content = "Hello {{data.name}}.",
FontSize = "font_size",
Format = Format.Markdown,
Italic = "italic",
LineHeight = "line_height",
Locales = new Dictionary<string, LocalesItem>()
{
{ "foo", new("content") }
},
Strikethrough = "strikethrough",
TextStyle = TextStyle.Text,
Underline = "underline",
Type = UnionMember0IntersectionMember1Type.Text,
},
],
FontSize = "font_size",
LineHeight = "line_height",
Padding = "padding",
Raw = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Type = ElementalChannelNodeWithTypeIntersectionMember1Type.Channel,
},
],
Version = "2022-01-01",
},
};
var notificationContentMutationResponse = await client.Journeys.Templates.PutContent(parameters);
Console.WriteLine(notificationContentMutationResponse);courier journeys:templates put-content \
--api-key 'My API Key' \
--template-id x \
--notification-id x \
--content '{elements: [{}]}'curl --request PUT \
--url https://api.courier.com/journeys/{templateId}/templates/{notificationId}/content \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "channel",
"channel": "email",
"elements": [
{
"type": "meta",
"title": "Welcome!"
},
{
"type": "text",
"content": "Hello {{data.name}}."
}
]
}
]
},
"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"
}