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.create('x', {
channel: 'email',
notification: {
name: 'Welcome email',
tags: [],
brand: null,
subscription: null,
content: { version: '2022-01-01', elements: [{ type: 'text' }] },
},
});
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.create(
template_id="x",
channel="email",
notification={
"name": "Welcome email",
"tags": [],
"brand": None,
"subscription": None,
"content": {
"version": "2022-01-01",
"elements": [{
"type": "text"
}],
},
},
)
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.New(
context.TODO(),
"x",
courier.JourneyTemplateNewParams{
JourneyTemplateCreateRequest: courier.JourneyTemplateCreateRequestParam{
Channel: "email",
Notification: courier.JourneyTemplateCreateRequestNotificationParam{
Brand: courier.JourneyTemplateCreateRequestNotificationBrandParam{
ID: "id",
},
Content: courier.JourneyTemplateCreateRequestNotificationContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}},
Version: "2022-01-01",
},
Name: "Welcome email",
Subscription: courier.JourneyTemplateCreateRequestNotificationSubscriptionParam{
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.JourneyTemplateCreateRequest;
import com.courier.models.journeys.JourneyTemplateGetResponse;
import com.courier.models.journeys.templates.TemplateCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplateCreateParams params = TemplateCreateParams.builder()
.templateId("x")
.journeyTemplateCreateRequest(JourneyTemplateCreateRequest.builder()
.channel("email")
.notification(JourneyTemplateCreateRequest.Notification.builder()
.brand(JourneyTemplateCreateRequest.Notification.Brand.builder()
.id("id")
.build())
.content(JourneyTemplateCreateRequest.Notification.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.version(JourneyTemplateCreateRequest.Notification.Content.Version._2022_01_01)
.build())
.name("Welcome email")
.subscription(JourneyTemplateCreateRequest.Notification.Subscription.builder()
.topicId("topic_id")
.build())
.addTag("string")
.build())
.build())
.build();
JourneyTemplateGetResponse journeyTemplateGetResponse = client.journeys().templates().create(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
journey_template_get_response = courier.journeys.templates.create(
"x",
channel: "email",
notification: {
brand: {id: "id"},
content: {elements: [{}], version: :"2022-01-01"},
name: "Welcome email",
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->create(
'x',
channel: 'email',
notification: [
'brand' => ['id' => 'id'],
'content' => [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'text',
],
],
'version' => '2022-01-01',
'scope' => 'default',
],
'name' => 'Welcome email',
'subscription' => ['topicID' => 'topic_id'],
'tags' => ['string'],
],
providerKey: 'x',
state: 'state',
idempotencyKey: 'order-ORD-456-user-123',
xIdempotencyExpiration: '1785312000',
);
var_dump($journeyTemplateGetResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models;
using Templates = TryCourier.Models.Journeys.Templates;
CourierClient client = new();
Templates::TemplateCreateParams parameters = new()
{
TemplateID = "x",
Channel = "email",
Notification = new()
{
Brand = new("id"),
Content = new()
{
Elements =
[
new ElementalTextNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalTextNodeWithTypeIntersectionMember1Type.Text,
},
],
Version = Templates::Version.V2022_01_01,
Scope = Templates::Scope.Default,
},
Name = "Welcome email",
Subscription = new("topic_id"),
Tags =
[
"string"
],
},
};
var journeyTemplateGetResponse = await client.Journeys.Templates.Create(parameters);
Console.WriteLine(journeyTemplateGetResponse);courier journeys:templates create \
--api-key 'My API Key' \
--template-id x \
--channel email \
--notification "{brand: {id: id}, content: {elements: [{}], version: '2022-01-01'}, name: Welcome email, subscription: {topic_id: topic_id}, tags: [string]}"curl --request POST \
--url https://api.courier.com/journeys/{templateId}/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"channel": "email",
"notification": {
"name": "Welcome email",
"tags": [],
"brand": null,
"subscription": null,
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "text",
"content": "Welcome!"
}
]
}
}
}
'{
"name": "Welcome email",
"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"
}Create a notification template scoped to a journey
Create a notification template scoped to this journey. Defaults to DRAFT state; pass state: "PUBLISHED" to publish on create.
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.create('x', {
channel: 'email',
notification: {
name: 'Welcome email',
tags: [],
brand: null,
subscription: null,
content: { version: '2022-01-01', elements: [{ type: 'text' }] },
},
});
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.create(
template_id="x",
channel="email",
notification={
"name": "Welcome email",
"tags": [],
"brand": None,
"subscription": None,
"content": {
"version": "2022-01-01",
"elements": [{
"type": "text"
}],
},
},
)
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.New(
context.TODO(),
"x",
courier.JourneyTemplateNewParams{
JourneyTemplateCreateRequest: courier.JourneyTemplateCreateRequestParam{
Channel: "email",
Notification: courier.JourneyTemplateCreateRequestNotificationParam{
Brand: courier.JourneyTemplateCreateRequestNotificationBrandParam{
ID: "id",
},
Content: courier.JourneyTemplateCreateRequestNotificationContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}},
Version: "2022-01-01",
},
Name: "Welcome email",
Subscription: courier.JourneyTemplateCreateRequestNotificationSubscriptionParam{
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.JourneyTemplateCreateRequest;
import com.courier.models.journeys.JourneyTemplateGetResponse;
import com.courier.models.journeys.templates.TemplateCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplateCreateParams params = TemplateCreateParams.builder()
.templateId("x")
.journeyTemplateCreateRequest(JourneyTemplateCreateRequest.builder()
.channel("email")
.notification(JourneyTemplateCreateRequest.Notification.builder()
.brand(JourneyTemplateCreateRequest.Notification.Brand.builder()
.id("id")
.build())
.content(JourneyTemplateCreateRequest.Notification.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.version(JourneyTemplateCreateRequest.Notification.Content.Version._2022_01_01)
.build())
.name("Welcome email")
.subscription(JourneyTemplateCreateRequest.Notification.Subscription.builder()
.topicId("topic_id")
.build())
.addTag("string")
.build())
.build())
.build();
JourneyTemplateGetResponse journeyTemplateGetResponse = client.journeys().templates().create(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
journey_template_get_response = courier.journeys.templates.create(
"x",
channel: "email",
notification: {
brand: {id: "id"},
content: {elements: [{}], version: :"2022-01-01"},
name: "Welcome email",
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->create(
'x',
channel: 'email',
notification: [
'brand' => ['id' => 'id'],
'content' => [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'text',
],
],
'version' => '2022-01-01',
'scope' => 'default',
],
'name' => 'Welcome email',
'subscription' => ['topicID' => 'topic_id'],
'tags' => ['string'],
],
providerKey: 'x',
state: 'state',
idempotencyKey: 'order-ORD-456-user-123',
xIdempotencyExpiration: '1785312000',
);
var_dump($journeyTemplateGetResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models;
using Templates = TryCourier.Models.Journeys.Templates;
CourierClient client = new();
Templates::TemplateCreateParams parameters = new()
{
TemplateID = "x",
Channel = "email",
Notification = new()
{
Brand = new("id"),
Content = new()
{
Elements =
[
new ElementalTextNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalTextNodeWithTypeIntersectionMember1Type.Text,
},
],
Version = Templates::Version.V2022_01_01,
Scope = Templates::Scope.Default,
},
Name = "Welcome email",
Subscription = new("topic_id"),
Tags =
[
"string"
],
},
};
var journeyTemplateGetResponse = await client.Journeys.Templates.Create(parameters);
Console.WriteLine(journeyTemplateGetResponse);courier journeys:templates create \
--api-key 'My API Key' \
--template-id x \
--channel email \
--notification "{brand: {id: id}, content: {elements: [{}], version: '2022-01-01'}, name: Welcome email, subscription: {topic_id: topic_id}, tags: [string]}"curl --request POST \
--url https://api.courier.com/journeys/{templateId}/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"channel": "email",
"notification": {
"name": "Welcome email",
"tags": [],
"brand": null,
"subscription": null,
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "text",
"content": "Welcome!"
}
]
}
}
}
'{
"name": "Welcome email",
"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.
Headers
A unique key that makes this request idempotent. If Courier receives another request with the same Idempotency-Key, it returns the stored response from the first request without performing the operation again (including the original status code and any error). Use it to safely retry POST requests after network failures without risking duplicate sends. The key is scoped to this endpoint.
How long the idempotency key remains valid, as a Unix epoch timestamp in seconds or an ISO 8601 date string. Only applies when Idempotency-Key is provided. If omitted, the key is retained for 25 hours; the maximum is 1 year.
Path Parameters
Journey id
1Body
Response
Created 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
DRAFT, PUBLISHED