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.broadcasts.putContent('broadcastId', {
content: { version: '2022-01-01', elements: [{ type: 'meta' }, { type: 'text' }] },
});
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.broadcasts.put_content(
broadcast_id="broadcastId",
content={
"version": "2022-01-01",
"elements": [{
"type": "meta"
}, {
"type": "text"
}],
},
)
print(notification_content_mutation_response.id)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"),
)
notificationContentMutationResponse, err := client.Broadcasts.PutContent(
context.TODO(),
"broadcastId",
courier.BroadcastPutContentParams{
NotificationContentPutRequest: courier.NotificationContentPutRequestParam{
Content: courier.NotificationContentPutRequestContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}, {
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
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.broadcasts.BroadcastPutContentParams;
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();
BroadcastPutContentParams params = BroadcastPutContentParams.builder()
.broadcastId("broadcastId")
.notificationContentPutRequest(NotificationContentPutRequest.builder()
.content(NotificationContentPutRequest.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.addElement(ElementalTextNodeWithType.builder().build())
.build())
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.broadcasts().putContent(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.broadcasts.put_content("broadcastId", content: {elements: [{}, {}]})
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->broadcasts->putContent(
'broadcastId',
content: [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'meta',
],
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'text',
],
],
'version' => '2022-01-01',
],
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Broadcasts;
CourierClient client = new();
BroadcastPutContentParams parameters = new()
{
BroadcastID = "broadcastId",
Content = new()
{
Elements =
[
new ElementalMetaNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalMetaNodeWithTypeIntersectionMember1Type.Meta,
},
new ElementalTextNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalTextNodeWithTypeIntersectionMember1Type.Text,
},
],
Version = "2022-01-01",
},
};
var notificationContentMutationResponse = await client.Broadcasts.PutContent(parameters);
Console.WriteLine(notificationContentMutationResponse);courier broadcasts put-content \
--api-key 'My API Key' \
--broadcast-id broadcastId \
--content '{elements: [{}, {}]}'curl --request PUT \
--url https://api.courier.com/broadcasts/{broadcastId}/content \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "meta",
"title": "Spring Sale is here"
},
{
"type": "text",
"content": "Hello! Check out our spring sale."
}
]
}
}
'{
"id": "<string>",
"version": "<string>",
"elements": [
{
"id": "<string>",
"checksum": "<string>"
}
],
"state": "DRAFT"
}{
"message": "<string>",
"type": "invalid_request_error"
}{
"message": "<string>",
"type": "invalid_request_error"
}{
"message": "<string>",
"type": "invalid_request_error"
}Broadcasts
Update Broadcast Content
Author the broadcast’s content by replacing the draft elemental content of its private notification template. The draft is published automatically when the broadcast is sent or scheduled.
PUT
/
broadcasts
/
{broadcastId}
/
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.broadcasts.putContent('broadcastId', {
content: { version: '2022-01-01', elements: [{ type: 'meta' }, { type: 'text' }] },
});
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.broadcasts.put_content(
broadcast_id="broadcastId",
content={
"version": "2022-01-01",
"elements": [{
"type": "meta"
}, {
"type": "text"
}],
},
)
print(notification_content_mutation_response.id)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"),
)
notificationContentMutationResponse, err := client.Broadcasts.PutContent(
context.TODO(),
"broadcastId",
courier.BroadcastPutContentParams{
NotificationContentPutRequest: courier.NotificationContentPutRequestParam{
Content: courier.NotificationContentPutRequestContentParam{
Elements: []shared.ElementalNodeUnionParam{{
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
ElementalBaseNodeParam: shared.ElementalBaseNodeParam{},
},
}, {
OfElementalTextNodeWithType: &shared.ElementalTextNodeWithTypeParam{
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.broadcasts.BroadcastPutContentParams;
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();
BroadcastPutContentParams params = BroadcastPutContentParams.builder()
.broadcastId("broadcastId")
.notificationContentPutRequest(NotificationContentPutRequest.builder()
.content(NotificationContentPutRequest.Content.builder()
.addElement(ElementalTextNodeWithType.builder().build())
.addElement(ElementalTextNodeWithType.builder().build())
.build())
.build())
.build();
NotificationContentMutationResponse notificationContentMutationResponse = client.broadcasts().putContent(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
notification_content_mutation_response = courier.broadcasts.put_content("broadcastId", content: {elements: [{}, {}]})
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->broadcasts->putContent(
'broadcastId',
content: [
'elements' => [
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'meta',
],
[
'channels' => ['string'],
'if' => 'if',
'loop' => 'loop',
'ref' => 'ref',
'type' => 'text',
],
],
'version' => '2022-01-01',
],
state: NotificationTemplateState::DRAFT,
);
var_dump($notificationContentMutationResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Broadcasts;
CourierClient client = new();
BroadcastPutContentParams parameters = new()
{
BroadcastID = "broadcastId",
Content = new()
{
Elements =
[
new ElementalMetaNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalMetaNodeWithTypeIntersectionMember1Type.Meta,
},
new ElementalTextNodeWithType()
{
Channels =
[
"string"
],
If = "if",
Loop = "loop",
Ref = "ref",
Type = ElementalTextNodeWithTypeIntersectionMember1Type.Text,
},
],
Version = "2022-01-01",
},
};
var notificationContentMutationResponse = await client.Broadcasts.PutContent(parameters);
Console.WriteLine(notificationContentMutationResponse);courier broadcasts put-content \
--api-key 'My API Key' \
--broadcast-id broadcastId \
--content '{elements: [{}, {}]}'curl --request PUT \
--url https://api.courier.com/broadcasts/{broadcastId}/content \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": {
"version": "2022-01-01",
"elements": [
{
"type": "meta",
"title": "Spring Sale is here"
},
{
"type": "text",
"content": "Hello! Check out our spring sale."
}
]
}
}
'{
"id": "<string>",
"version": "<string>",
"elements": [
{
"id": "<string>",
"checksum": "<string>"
}
],
"state": "DRAFT"
}{
"message": "<string>",
"type": "invalid_request_error"
}{
"message": "<string>",
"type": "invalid_request_error"
}{
"message": "<string>",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
Response
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