Skip to main content
PUT
/
notifications
/
{id}
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 notificationTemplateResponse = await client.notifications.replace('id', {
  notification: {
    name: 'Updated Name',
    tags: ['updated'],
    brand: null,
    subscription: null,
    routing: null,
    content: { version: '2022-01-01', elements: [{ type: 'channel' }] },
  },
  state: 'PUBLISHED',
});

console.log(notificationTemplateResponse);
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_template_response = client.notifications.replace(
id="id",
notification={
"name": "Updated Name",
"tags": ["updated"],
"brand": None,
"subscription": None,
"routing": None,
"content": {
"version": "2022-01-01",
"elements": [{
"type": "channel"
}],
},
},
state="PUBLISHED",
)
print(notification_template_response)
package main

import (
"context"
"fmt"

"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
"github.com/trycourier/courier-go/shared"
)

func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
notificationTemplateResponse, err := client.Notifications.Replace(
context.TODO(),
"id",
courier.NotificationReplaceParams{
NotificationTemplateUpdateRequest: courier.NotificationTemplateUpdateRequestParam{
Notification: courier.NotificationTemplatePayloadParam{
Brand: courier.NotificationTemplatePayloadBrandParam{
ID: "id",
},
Content: shared.ElementalContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}},
Version: "2022-01-01",
},
Name: "Updated Name",
Routing: courier.NotificationTemplatePayloadRoutingParam{
StrategyID: "strategy_id",
},
Subscription: courier.NotificationTemplatePayloadSubscriptionParam{
TopicID: "topic_id",
},
Tags: []string{"updated"},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", notificationTemplateResponse)
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.ElementalContent;
import com.courier.models.ElementalTextNodeWithType;
import com.courier.models.notifications.NotificationReplaceParams;
import com.courier.models.notifications.NotificationTemplatePayload;
import com.courier.models.notifications.NotificationTemplateResponse;
import com.courier.models.notifications.NotificationTemplateUpdateRequest;

public final class Main {
private Main() {}

public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();

NotificationReplaceParams params = NotificationReplaceParams.builder()
.id("id")
.notificationTemplateUpdateRequest(NotificationTemplateUpdateRequest.builder()
.notification(NotificationTemplatePayload.builder()
.brand(NotificationTemplatePayload.Brand.builder()
.id("id")
.build())
.content(ElementalContent.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.version("2022-01-01")
.build())
.name("Updated Name")
.routing(NotificationTemplatePayload.Routing.builder()
.strategyId("strategy_id")
.build())
.subscription(NotificationTemplatePayload.Subscription.builder()
.topicId("topic_id")
.build())
.addTag("updated")
.build())
.build())
.build();
NotificationTemplateResponse notificationTemplateResponse = client.notifications().replace(params);
}
}
require "courier"

courier = Courier::Client.new(api_key: "My API Key")

notification_template_response = courier.notifications.replace(
"id",
notification: {
brand: {id: "id"},
content: {elements: [{}], version: "2022-01-01"},
name: "Updated Name",
routing: {strategy_id: "strategy_id"},
subscription: {topic_id: "topic_id"},
tags: ["updated"]
}
)

puts(notification_template_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 {
$notificationTemplateResponse = $client->notifications->replace(
'id',
notification: [
'brand' => ['id' => 'id'],
'content' => [
'elements' => [['type' => 'channel']], 'version' => '2022-01-01'
],
'name' => 'Updated Name',
'routing' => ['strategyID' => 'strategy_id'],
'subscription' => ['topicID' => 'topic_id'],
'tags' => ['updated'],
],
state: 'PUBLISHED',
);

var_dump($notificationTemplateResponse);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Notifications;

CourierClient client = new();

NotificationReplaceParams parameters = new()
{
ID = "id",
Notification = new()
{
Brand = new("id"),
Content = new()
{
Elements =
[
new ElementalChannelNodeWithType()
{
Type = ElementalChannelNodeWithTypeIntersectionMember1Type.Channel,
},
],
Version = "2022-01-01",
},
Name = "Updated Name",
Routing = new("strategy_id"),
Subscription = new("topic_id"),
Tags =
[
"updated"
],
},
};

var notificationTemplateResponse = await client.Notifications.Replace(parameters);

Console.WriteLine(notificationTemplateResponse);
courier notifications replace \
--api-key 'My API Key' \
--id id \
--notification "{brand: {id: id}, content: {elements: [{}], version: '2022-01-01'}, name: Updated Name, routing: {strategy_id: strategy_id}, subscription: {topic_id: topic_id}, tags: [updated]}"
curl --request PUT \
--url https://api.courier.com/notifications/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"notification": {
"name": "Updated Name",
"tags": [
"updated"
],
"brand": null,
"subscription": null,
"routing": null,
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "channel",
"channel": "email",
"elements": [
{
"type": "meta",
"title": "Updated"
},
{
"type": "text",
"content": "Updated content."
}
]
}
]
}
},
"state": "PUBLISHED"
}
'
{
  "id": "nt_01kx4h2jdafq8bk9aftxak4b40",
  "name": "Updated Name",
  "tags": [
    "updated"
  ],
  "brand": null,
  "subscription": null,
  "routing": null,
  "content": {
    "version": "2022-01-01",
    "elements": [
      {
        "type": "channel",
        "channel": "email",
        "elements": [
          {
            "type": "meta",
            "title": "Updated"
          },
          {
            "type": "text",
            "content": "Updated content."
          }
        ]
      }
    ]
  },
  "state": "PUBLISHED",
  "created": 1710000000000,
  "creator": "user_abc",
  "updated": 1710000001000,
  "updater": "user_def"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Template ID (nt_ prefix).

Body

application/json

Request body for replacing a notification template. Same shape as create. All fields required (PUT = full replacement).

notification
NotificationTemplatePayload · object
required

Core template fields used in POST and PUT request bodies (nested under a notification key) and returned at the top level in responses.

state
enum<string>
default:DRAFT

Template state after update. Case-insensitive input, normalized to uppercase in the response. Defaults to "DRAFT".

Available options:
DRAFT,
PUBLISHED

Response

Response for GET /notifications/{id}, POST /notifications, and PUT /notifications/{id}. Returns all template fields at the top level.

name
string
required

Display name for the template.

tags
string[]
required

Tags for categorization. Send empty array for none.

brand
object | null
required

Brand reference, or null for no brand.

subscription
object | null
required

Subscription topic reference, or null for none.

routing
object | null
required

Routing strategy reference, or null for none.

content
ElementalContent · object
required

Elemental content definition.

id
string
required

The template ID.

state
enum<string>
required

The template state. Always uppercase.

Available options:
DRAFT,
PUBLISHED
created
integer<int64>
required

Epoch milliseconds when the template was created.

creator
string
required

User ID of the creator.

updated
integer<int64>

Epoch milliseconds of last update.

updater
string

User ID of the last updater.