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.notifications.putElement('elementId', {
id: 'id',
type: 'text',
data: { content: 'Updated text content' },
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.notifications.put_element(
element_id="elementId",
id="id",
type="text",
data={
"content": "Updated text content"
},
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.Notifications.PutElement(
context.TODO(),
"elementId",
courier.NotificationPutElementParams{
ID: "id",
NotificationElementPutRequest: courier.NotificationElementPutRequestParam{
Type: "text",
},
},
)
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.notifications.NotificationContentMutationResponse;
import com.courier.models.notifications.NotificationElementPutRequest;
import com.courier.models.notifications.NotificationPutElementParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
NotificationPutElementParams params = NotificationPutElementParams.builder()
.id("id")
.elementId("elementId")
.notificationElementPutRequest(NotificationElementPutRequest.builder()
.type("text")
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.notifications().putElement(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.notifications.put_element("elementId", id: "id", type: "text")
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->notifications->putElement(
'elementId',
id: 'id',
type: 'text',
channels: ['string'],
data: ['content' => 'bar'],
if: 'if',
loop: 'loop',
ref: 'ref',
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Notifications;
CourierClient client = new();
NotificationPutElementParams parameters = new()
{
ID = "id",
ElementID = "elementId",
Type = "text",
};
var notificationContentMutationResponse = await client.Notifications.PutElement(parameters);
Console.WriteLine(notificationContentMutationResponse);courier notifications put-element \
--api-key 'My API Key' \
--id id \
--element-id elementId \
--type textcurl --request PUT \
--url https://api.courier.com/notifications/{id}/elements/{elementId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "text",
"data": {
"content": "Updated text content"
},
"state": "DRAFT"
}
'{
"id": "nt_01kx4h2jdafq8bk9aftxak4b40",
"version": "2022-01-01",
"elements": [
{
"id": "elem_1",
"checksum": "abc123"
},
{
"id": "elem_2",
"checksum": "def456"
}
],
"state": "DRAFT"
}Notification Templates
Put Notification Element
Update a single element within a notification template. Only supported for V2 (elemental) templates.
PUT
/
notifications
/
{id}
/
elements
/
{elementId}
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.notifications.putElement('elementId', {
id: 'id',
type: 'text',
data: { content: 'Updated text content' },
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.notifications.put_element(
element_id="elementId",
id="id",
type="text",
data={
"content": "Updated text content"
},
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.Notifications.PutElement(
context.TODO(),
"elementId",
courier.NotificationPutElementParams{
ID: "id",
NotificationElementPutRequest: courier.NotificationElementPutRequestParam{
Type: "text",
},
},
)
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.notifications.NotificationContentMutationResponse;
import com.courier.models.notifications.NotificationElementPutRequest;
import com.courier.models.notifications.NotificationPutElementParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
NotificationPutElementParams params = NotificationPutElementParams.builder()
.id("id")
.elementId("elementId")
.notificationElementPutRequest(NotificationElementPutRequest.builder()
.type("text")
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.notifications().putElement(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.notifications.put_element("elementId", id: "id", type: "text")
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->notifications->putElement(
'elementId',
id: 'id',
type: 'text',
channels: ['string'],
data: ['content' => 'bar'],
if: 'if',
loop: 'loop',
ref: 'ref',
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Notifications;
CourierClient client = new();
NotificationPutElementParams parameters = new()
{
ID = "id",
ElementID = "elementId",
Type = "text",
};
var notificationContentMutationResponse = await client.Notifications.PutElement(parameters);
Console.WriteLine(notificationContentMutationResponse);courier notifications put-element \
--api-key 'My API Key' \
--id id \
--element-id elementId \
--type textcurl --request PUT \
--url https://api.courier.com/notifications/{id}/elements/{elementId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "text",
"data": {
"content": "Updated text content"
},
"state": "DRAFT"
}
'{
"id": "nt_01kx4h2jdafq8bk9aftxak4b40",
"version": "2022-01-01",
"elements": [
{
"id": "elem_1",
"checksum": "abc123"
},
{
"id": "elem_2",
"checksum": "def456"
}
],
"state": "DRAFT"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Notification template ID (nt_ prefix).
Element ID within the template.
Body
application/json
Request body for updating a single element. Additional type-specific fields are allowed.
Response
Element updated.
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