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 journeyTemplateGetResponse = await client.journeys.templates.replace('x', {
templateId: 'x',
notification: {
brand: { id: 'id' },
content: { elements: [{}], version: '2022-01-01' },
name: 'name',
subscription: { topic_id: 'topic_id' },
tags: ['string'],
},
});
console.log(journeyTemplateGetResponse.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
)
journey_template_get_response = client.journeys.templates.replace(
notification_id="x",
template_id="x",
notification={
"brand": {
"id": "id"
},
"content": {
"elements": [{}],
"version": "2022-01-01",
},
"name": "name",
"subscription": {
"topic_id": "topic_id"
},
"tags": ["string"],
},
)
print(journey_template_get_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"),
)
journeyTemplateGetResponse, err := client.Journeys.Templates.Replace(
context.TODO(),
"x",
courier.JourneyTemplateReplaceParams{
TemplateID: "x",
JourneyTemplateReplaceRequest: courier.JourneyTemplateReplaceRequestParam{
Notification: courier.JourneyTemplateReplaceRequestNotificationParam{
Brand: courier.JourneyTemplateReplaceRequestNotificationBrandParam{
ID: "id",
},
Content: courier.JourneyTemplateReplaceRequestNotificationContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}},
Version: "2022-01-01",
},
Name: "name",
Subscription: courier.JourneyTemplateReplaceRequestNotificationSubscriptionParam{
TopicID: "topic_id",
},
Tags: []string{"string"},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", journeyTemplateGetResponse.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.JourneyTemplateGetResponse;
import com.courier.models.journeys.JourneyTemplateReplaceRequest;
import com.courier.models.journeys.templates.TemplateReplaceParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplateReplaceParams params = TemplateReplaceParams.builder()
.templateId("x")
.notificationId("x")
.journeyTemplateReplaceRequest(JourneyTemplateReplaceRequest.builder()
.notification(JourneyTemplateReplaceRequest.Notification.builder()
.brand(JourneyTemplateReplaceRequest.Notification.Brand.builder()
.id("id")
.build())
.content(JourneyTemplateReplaceRequest.Notification.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.version(JourneyTemplateReplaceRequest.Notification.Content.Version._2022_01_01)
.build())
.name("name")
.subscription(JourneyTemplateReplaceRequest.Notification.Subscription.builder()
.topicId("topic_id")
.build())
.addTag("string")
.build())
.build())
.build();
JourneyTemplateGetResponse journeyTemplateGetResponse = client.journeys().templates().replace(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
journey_template_get_response = courier.journeys.templates.replace(
"x",
template_id: "x",
notification: {
brand: {id: "id"},
content: {elements: [{}], version: :"2022-01-01"},
name: "name",
subscription: {topic_id: "topic_id"},
tags: ["string"]
}
)
puts(journey_template_get_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$journeyTemplateGetResponse = $client->journeys->templates->replace(
'x',
templateID: 'x',
notification: [
'brand' => ['id' => 'id'],
'content' => [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'text',
],
],
'version' => '2022-01-01',
'scope' => 'default',
],
'name' => 'name',
'subscription' => ['topicID' => 'topic_id'],
'tags' => ['string'],
],
state: 'state',
);
var_dump($journeyTemplateGetResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Journeys.Templates;
CourierClient client = new();
TemplateReplaceParams parameters = new()
{
TemplateID = "x",
NotificationID = "x",
Notification = new()
{
Brand = new("id"),
Content = new()
{
Elements =
[
new ElementalTextNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalTextNodeWithTypeIntersectionMember1Type.Text,
},
],
Version = TemplateReplaceParamsNotificationContentVersion.V2022_01_01,
Scope = TemplateReplaceParamsNotificationContentScope.Default,
},
Name = "name",
Subscription = new("topic_id"),
Tags =
[
"string"
],
},
};
var journeyTemplateGetResponse = await client.Journeys.Templates.Replace(parameters);
Console.WriteLine(journeyTemplateGetResponse);courier journeys:templates replace \
--api-key 'My API Key' \
--template-id x \
--notification-id x \
--notification "{brand: {id: id}, content: {elements: [{}], version: '2022-01-01'}, name: name, subscription: {topic_id: topic_id}, tags: [string]}"curl --request PUT \
--url https://api.courier.com/journeys/{templateId}/templates/{notificationId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Welcome email v2",
"tags": [],
"brand": null,
"subscription": null,
"content": {
"version": "2022-01-01",
"elements": []
}
}
'{
"name": "Welcome email v2",
"tags": [],
"brand": null,
"subscription": null,
"content": {
"scope": "default",
"version": "2022-01-01",
"elements": []
}
}{
"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 journey-scoped notification template
Replaces the draft content of one journey’s notification template. Publish it before send nodes referencing it render the change.
PUT
/
journeys
/
{templateId}
/
templates
/
{notificationId}
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 journeyTemplateGetResponse = await client.journeys.templates.replace('x', {
templateId: 'x',
notification: {
brand: { id: 'id' },
content: { elements: [{}], version: '2022-01-01' },
name: 'name',
subscription: { topic_id: 'topic_id' },
tags: ['string'],
},
});
console.log(journeyTemplateGetResponse.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
)
journey_template_get_response = client.journeys.templates.replace(
notification_id="x",
template_id="x",
notification={
"brand": {
"id": "id"
},
"content": {
"elements": [{}],
"version": "2022-01-01",
},
"name": "name",
"subscription": {
"topic_id": "topic_id"
},
"tags": ["string"],
},
)
print(journey_template_get_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"),
)
journeyTemplateGetResponse, err := client.Journeys.Templates.Replace(
context.TODO(),
"x",
courier.JourneyTemplateReplaceParams{
TemplateID: "x",
JourneyTemplateReplaceRequest: courier.JourneyTemplateReplaceRequestParam{
Notification: courier.JourneyTemplateReplaceRequestNotificationParam{
Brand: courier.JourneyTemplateReplaceRequestNotificationBrandParam{
ID: "id",
},
Content: courier.JourneyTemplateReplaceRequestNotificationContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}},
Version: "2022-01-01",
},
Name: "name",
Subscription: courier.JourneyTemplateReplaceRequestNotificationSubscriptionParam{
TopicID: "topic_id",
},
Tags: []string{"string"},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", journeyTemplateGetResponse.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.JourneyTemplateGetResponse;
import com.courier.models.journeys.JourneyTemplateReplaceRequest;
import com.courier.models.journeys.templates.TemplateReplaceParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplateReplaceParams params = TemplateReplaceParams.builder()
.templateId("x")
.notificationId("x")
.journeyTemplateReplaceRequest(JourneyTemplateReplaceRequest.builder()
.notification(JourneyTemplateReplaceRequest.Notification.builder()
.brand(JourneyTemplateReplaceRequest.Notification.Brand.builder()
.id("id")
.build())
.content(JourneyTemplateReplaceRequest.Notification.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.version(JourneyTemplateReplaceRequest.Notification.Content.Version._2022_01_01)
.build())
.name("name")
.subscription(JourneyTemplateReplaceRequest.Notification.Subscription.builder()
.topicId("topic_id")
.build())
.addTag("string")
.build())
.build())
.build();
JourneyTemplateGetResponse journeyTemplateGetResponse = client.journeys().templates().replace(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
journey_template_get_response = courier.journeys.templates.replace(
"x",
template_id: "x",
notification: {
brand: {id: "id"},
content: {elements: [{}], version: :"2022-01-01"},
name: "name",
subscription: {topic_id: "topic_id"},
tags: ["string"]
}
)
puts(journey_template_get_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$journeyTemplateGetResponse = $client->journeys->templates->replace(
'x',
templateID: 'x',
notification: [
'brand' => ['id' => 'id'],
'content' => [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'text',
],
],
'version' => '2022-01-01',
'scope' => 'default',
],
'name' => 'name',
'subscription' => ['topicID' => 'topic_id'],
'tags' => ['string'],
],
state: 'state',
);
var_dump($journeyTemplateGetResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Journeys.Templates;
CourierClient client = new();
TemplateReplaceParams parameters = new()
{
TemplateID = "x",
NotificationID = "x",
Notification = new()
{
Brand = new("id"),
Content = new()
{
Elements =
[
new ElementalTextNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalTextNodeWithTypeIntersectionMember1Type.Text,
},
],
Version = TemplateReplaceParamsNotificationContentVersion.V2022_01_01,
Scope = TemplateReplaceParamsNotificationContentScope.Default,
},
Name = "name",
Subscription = new("topic_id"),
Tags =
[
"string"
],
},
};
var journeyTemplateGetResponse = await client.Journeys.Templates.Replace(parameters);
Console.WriteLine(journeyTemplateGetResponse);courier journeys:templates replace \
--api-key 'My API Key' \
--template-id x \
--notification-id x \
--notification "{brand: {id: id}, content: {elements: [{}], version: '2022-01-01'}, name: name, subscription: {topic_id: topic_id}, tags: [string]}"curl --request PUT \
--url https://api.courier.com/journeys/{templateId}/templates/{notificationId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Welcome email v2",
"tags": [],
"brand": null,
"subscription": null,
"content": {
"version": "2022-01-01",
"elements": []
}
}
'{
"name": "Welcome email v2",
"tags": [],
"brand": null,
"subscription": null,
"content": {
"scope": "default",
"version": "2022-01-01",
"elements": []
}
}{
"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 notification template
A journey-scoped notification template.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Available options:
DRAFT, PUBLISHED ⌘I