JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
await client.bulk.addUsers('job_id', { users: [{}] });import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
client.bulk.add_users(
job_id="job_id",
users=[{}],
)package main
import (
"context"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Bulk.AddUsers(
context.TODO(),
"job_id",
courier.BulkAddUsersParams{
Users: []courier.InboundBulkMessageUserParam{{}},
},
)
if err != nil {
panic(err.Error())
}
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.bulk.BulkAddUsersParams;
import com.courier.models.bulk.InboundBulkMessageUser;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BulkAddUsersParams params = BulkAddUsersParams.builder()
.jobId("job_id")
.addUser(InboundBulkMessageUser.builder().build())
.build();
client.bulk().addUsers(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
result = courier.bulk.add_users("job_id", users: [{}])
puts(result)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\PreferenceStatus;
use Courier\ChannelClassification;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$result = $client->bulk->addUsers(
'job_id',
users: [
[
'data' => (object) [],
'preferences' => [
'categories' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
],
],
'notifications' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
],
],
],
'profile' => ['foo' => 'bar'],
'recipient' => 'recipient',
'to' => [
'accountID' => 'account_id',
'context' => ['tenantID' => 'tenant_id'],
'data' => ['foo' => 'bar'],
'email' => 'email',
'listID' => 'list_id',
'locale' => 'locale',
'phoneNumber' => 'phone_number',
'preferences' => [
'notifications' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
'source' => 'subscription',
],
],
'categories' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
'source' => 'subscription',
],
],
'templateID' => 'templateId',
],
'tenantID' => 'tenant_id',
'userID' => 'user_id',
],
],
],
);
var_dump($result);
} catch (APIException $e) {
echo $e->getMessage();
}using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Bulk;
CourierClient client = new();
BulkAddUsersParams parameters = new()
{
JobID = "job_id",
Users =
[
new()
{
Data = JsonSerializer.Deserialize<JsonElement>("{}"),
Preferences = new()
{
Categories = new Dictionary<string, NotificationPreferenceDetails>(
)
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
} },
},
Notifications = new Dictionary<string, NotificationPreferenceDetails>(
)
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
} },
},
},
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Recipient = "recipient",
To = new()
{
AccountID = "account_id",
Context = new() { TenantID = "tenant_id" },
Data = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Email = "email",
ListID = "list_id",
Locale = "locale",
PhoneNumber = "phone_number",
Preferences = new()
{
Notifications = new Dictionary<string, Preference>()
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
Source = Source.Subscription,
} },
},
Categories = new Dictionary<string, Preference>()
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
Source = Source.Subscription,
} },
},
TemplateID = "templateId",
},
TenantID = "tenant_id",
UserID = "user_id",
},
},
],
};
await client.Bulk.AddUsers(parameters);courier bulk add-users \
--api-key 'My API Key' \
--job-id job_id \
--user '{}'curl --request POST \
--url https://api.courier.com/bulk/{job_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"users": [
{
"preferences": {
"categories": {},
"notifications": {}
},
"profile": {},
"recipient": "<string>",
"data": "<unknown>",
"to": {
"user_id": "<string>",
"account_id": "<string>",
"context": {
"tenant_id": "<string>"
},
"data": {},
"email": "<string>",
"locale": "<string>",
"phone_number": "<string>",
"list_id": "<string>",
"preferences": {
"notifications": {},
"categories": {},
"templateId": "<string>"
},
"tenant_id": "<string>"
}
}
]
}
'Bulk
Add users
Ingest user data into a Bulk Job.
Important: For email-based bulk jobs, each user must include profile.email
for provider routing to work correctly. The to.email field is not sufficient
for email provider routing.
POST
/
bulk
/
{job_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
});
await client.bulk.addUsers('job_id', { users: [{}] });import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
client.bulk.add_users(
job_id="job_id",
users=[{}],
)package main
import (
"context"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Bulk.AddUsers(
context.TODO(),
"job_id",
courier.BulkAddUsersParams{
Users: []courier.InboundBulkMessageUserParam{{}},
},
)
if err != nil {
panic(err.Error())
}
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.bulk.BulkAddUsersParams;
import com.courier.models.bulk.InboundBulkMessageUser;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BulkAddUsersParams params = BulkAddUsersParams.builder()
.jobId("job_id")
.addUser(InboundBulkMessageUser.builder().build())
.build();
client.bulk().addUsers(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
result = courier.bulk.add_users("job_id", users: [{}])
puts(result)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\PreferenceStatus;
use Courier\ChannelClassification;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$result = $client->bulk->addUsers(
'job_id',
users: [
[
'data' => (object) [],
'preferences' => [
'categories' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
],
],
'notifications' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
],
],
],
'profile' => ['foo' => 'bar'],
'recipient' => 'recipient',
'to' => [
'accountID' => 'account_id',
'context' => ['tenantID' => 'tenant_id'],
'data' => ['foo' => 'bar'],
'email' => 'email',
'listID' => 'list_id',
'locale' => 'locale',
'phoneNumber' => 'phone_number',
'preferences' => [
'notifications' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
'source' => 'subscription',
],
],
'categories' => [
'foo' => [
'status' => PreferenceStatus::OPTED_IN,
'channelPreferences' => [
['channel' => ChannelClassification::DIRECT_MESSAGE]
],
'rules' => [['until' => 'until', 'start' => 'start']],
'source' => 'subscription',
],
],
'templateID' => 'templateId',
],
'tenantID' => 'tenant_id',
'userID' => 'user_id',
],
],
],
);
var_dump($result);
} catch (APIException $e) {
echo $e->getMessage();
}using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models;
using TryCourier.Models.Bulk;
CourierClient client = new();
BulkAddUsersParams parameters = new()
{
JobID = "job_id",
Users =
[
new()
{
Data = JsonSerializer.Deserialize<JsonElement>("{}"),
Preferences = new()
{
Categories = new Dictionary<string, NotificationPreferenceDetails>(
)
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
} },
},
Notifications = new Dictionary<string, NotificationPreferenceDetails>(
)
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
} },
},
},
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Recipient = "recipient",
To = new()
{
AccountID = "account_id",
Context = new() { TenantID = "tenant_id" },
Data = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Email = "email",
ListID = "list_id",
Locale = "locale",
PhoneNumber = "phone_number",
Preferences = new()
{
Notifications = new Dictionary<string, Preference>()
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
Source = Source.Subscription,
} },
},
Categories = new Dictionary<string, Preference>()
{
{ "foo", new()
{
Status = PreferenceStatus.OptedIn,
ChannelPreferences =
[
new(ChannelClassification.DirectMessage)
],
Rules =
[
new()
{
Until = "until",
Start = "start",
},
],
Source = Source.Subscription,
} },
},
TemplateID = "templateId",
},
TenantID = "tenant_id",
UserID = "user_id",
},
},
],
};
await client.Bulk.AddUsers(parameters);courier bulk add-users \
--api-key 'My API Key' \
--job-id job_id \
--user '{}'curl --request POST \
--url https://api.courier.com/bulk/{job_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"users": [
{
"preferences": {
"categories": {},
"notifications": {}
},
"profile": {},
"recipient": "<string>",
"data": "<unknown>",
"to": {
"user_id": "<string>",
"account_id": "<string>",
"context": {
"tenant_id": "<string>"
},
"data": {},
"email": "<string>",
"locale": "<string>",
"phone_number": "<string>",
"list_id": "<string>",
"preferences": {
"notifications": {},
"categories": {},
"templateId": "<string>"
},
"tenant_id": "<string>"
}
}
]
}
'Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
A unique identifier representing the bulk job
Body
application/json
Show child attributes
Show child attributes
Response
204 - undefined
⌘I