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 response = await client.bulk.createJob({ message: { event: 'event' } });
console.log(response.jobId);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
response = client.bulk.create_job(
message={
"event": "event"
},
)
print(response.job_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"),
)
response, err := client.Bulk.NewJob(context.TODO(), courier.BulkNewJobParams{
Message: courier.InboundBulkMessageParam{
Event: "event",
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.JobID)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.bulk.BulkCreateJobParams;
import com.courier.models.bulk.BulkCreateJobResponse;
import com.courier.models.bulk.InboundBulkMessage;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BulkCreateJobParams params = BulkCreateJobParams.builder()
.message(InboundBulkMessage.builder()
.event("event")
.build())
.build();
BulkCreateJobResponse response = client.bulk().createJob(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.bulk.create_job(message: {event: "event"})
puts(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 {
$response = $client->bulk->createJob(
message: [
'event' => 'event',
'brand' => 'brand',
'content' => ['body' => 'body', 'title' => 'title'],
'data' => ['foo' => 'bar'],
'locale' => ['foo' => ['foo' => 'bar']],
'override' => ['foo' => 'bar'],
'template' => 'template',
],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Bulk;
CourierClient client = new();
BulkCreateJobParams parameters = new()
{
Message = new()
{
Event = "event",
Brand = "brand",
Content = new ElementalContentSugar()
{
Body = "body",
Title = "title",
},
Data = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Locale = new Dictionary<string, IReadOnlyDictionary<string, JsonElement>>(
)
{
{ "foo", new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
} },
},
Override = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Template = "template",
},
};
var response = await client.Bulk.CreateJob(parameters);
Console.WriteLine(response);courier bulk create-job \
--api-key 'My API Key' \
--message '{event: event}'curl --request POST \
--url https://api.courier.com/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": {
"event": "<string>",
"brand": "<string>",
"data": {},
"template": "<string>",
"content": {
"title": "<string>",
"body": "<string>"
},
"locale": {},
"override": {}
}
}
'{
"jobId": "1-61e9f29c-c4a93e9c11dd83c690bb14f7"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Bulk
Create a bulk job
Creates a new bulk job for sending messages to multiple recipients.
Required: message.event (event ID or notification ID)
Optional (V2 format): message.template (notification ID) or message.content (Elemental content)
can be provided to override the notification associated with the event.
POST
/
bulk
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 response = await client.bulk.createJob({ message: { event: 'event' } });
console.log(response.jobId);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
response = client.bulk.create_job(
message={
"event": "event"
},
)
print(response.job_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"),
)
response, err := client.Bulk.NewJob(context.TODO(), courier.BulkNewJobParams{
Message: courier.InboundBulkMessageParam{
Event: "event",
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.JobID)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.bulk.BulkCreateJobParams;
import com.courier.models.bulk.BulkCreateJobResponse;
import com.courier.models.bulk.InboundBulkMessage;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BulkCreateJobParams params = BulkCreateJobParams.builder()
.message(InboundBulkMessage.builder()
.event("event")
.build())
.build();
BulkCreateJobResponse response = client.bulk().createJob(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.bulk.create_job(message: {event: "event"})
puts(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 {
$response = $client->bulk->createJob(
message: [
'event' => 'event',
'brand' => 'brand',
'content' => ['body' => 'body', 'title' => 'title'],
'data' => ['foo' => 'bar'],
'locale' => ['foo' => ['foo' => 'bar']],
'override' => ['foo' => 'bar'],
'template' => 'template',
],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Bulk;
CourierClient client = new();
BulkCreateJobParams parameters = new()
{
Message = new()
{
Event = "event",
Brand = "brand",
Content = new ElementalContentSugar()
{
Body = "body",
Title = "title",
},
Data = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Locale = new Dictionary<string, IReadOnlyDictionary<string, JsonElement>>(
)
{
{ "foo", new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
} },
},
Override = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Template = "template",
},
};
var response = await client.Bulk.CreateJob(parameters);
Console.WriteLine(response);courier bulk create-job \
--api-key 'My API Key' \
--message '{event: event}'curl --request POST \
--url https://api.courier.com/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": {
"event": "<string>",
"brand": "<string>",
"data": {},
"template": "<string>",
"content": {
"title": "<string>",
"body": "<string>"
},
"locale": {},
"override": {}
}
}
'{
"jobId": "1-61e9f29c-c4a93e9c11dd83c690bb14f7"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Bulk message definition. Supports two formats:
- V1 format: Requires
eventfield (event ID or notification ID) - V2 format: Optionally use
template(notification ID) orcontent(Elemental content) in addition toevent
Show child attributes
Show child attributes
Response
⌘I