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.listUsers('job_id');
console.log(response.items);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.list_users(
job_id="job_id",
)
print(response.items)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Bulk.ListUsers(
context.TODO(),
"job_id",
courier.BulkListUsersParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Items)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.bulk.BulkListUsersParams;
import com.courier.models.bulk.BulkListUsersResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BulkListUsersResponse response = client.bulk().listUsers("job_id");
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.bulk.list_users("job_id")
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->listUsers('job_id', cursor: 'cursor');
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Bulk;
CourierClient client = new();
BulkListUsersParams parameters = new() { JobID = "job_id" };
var response = await client.Bulk.ListUsers(parameters);
Console.WriteLine(response);courier bulk list-users \
--api-key 'My API Key' \
--job-id job_idcurl --request GET \
--url https://api.courier.com/bulk/{job_id}/users \
--header 'Authorization: Bearer <token>'{
"items": [
{
"preferences": {
"categories": {
"categories_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
]
}
},
"notifications": {
"notifications_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
]
}
}
},
"profile": {},
"recipient": "string",
"data": {},
"to": {
"user_id": "user_123",
"account_id": "abc-123",
"context": {
"tenant_id": "tenant_abc"
},
"data": {},
"email": "user@example.com",
"locale": "en-US",
"phone_number": "+15551234567",
"list_id": "example.list.id",
"preferences": {
"categories": {
"categories_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
],
"source": "subscription"
}
},
"notifications": {
"notifications_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
],
"source": "subscription"
}
},
"templateId": "nt_01kx4h2jdafq8bk9aftxak4b40"
},
"tenant_id": "tenant_abc"
},
"status": "PENDING",
"messageId": "1-5e2b2615-05efbb3acab9172f88dd3f6f"
}
],
"paging": {
"cursor": "MTpFWUNFRkRRN0c1WERTRTU2",
"more": true
}
}{
"message": "Example message text",
"type": "invalid_request_error"
}Bulk
Get users
Returns the users ingested into a bulk job with paging, each carrying the status Courier recorded for it and the id of the message it produced.
GET
/
bulk
/
{job_id}
/
users
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.listUsers('job_id');
console.log(response.items);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.list_users(
job_id="job_id",
)
print(response.items)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Bulk.ListUsers(
context.TODO(),
"job_id",
courier.BulkListUsersParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Items)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.bulk.BulkListUsersParams;
import com.courier.models.bulk.BulkListUsersResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BulkListUsersResponse response = client.bulk().listUsers("job_id");
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.bulk.list_users("job_id")
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->listUsers('job_id', cursor: 'cursor');
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Bulk;
CourierClient client = new();
BulkListUsersParams parameters = new() { JobID = "job_id" };
var response = await client.Bulk.ListUsers(parameters);
Console.WriteLine(response);courier bulk list-users \
--api-key 'My API Key' \
--job-id job_idcurl --request GET \
--url https://api.courier.com/bulk/{job_id}/users \
--header 'Authorization: Bearer <token>'{
"items": [
{
"preferences": {
"categories": {
"categories_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
]
}
},
"notifications": {
"notifications_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
]
}
}
},
"profile": {},
"recipient": "string",
"data": {},
"to": {
"user_id": "user_123",
"account_id": "abc-123",
"context": {
"tenant_id": "tenant_abc"
},
"data": {},
"email": "user@example.com",
"locale": "en-US",
"phone_number": "+15551234567",
"list_id": "example.list.id",
"preferences": {
"categories": {
"categories_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
],
"source": "subscription"
}
},
"notifications": {
"notifications_key": {
"status": "OPTED_IN",
"rules": [
{
"start": "string",
"until": "string"
}
],
"channel_preferences": [
{
"channel": "direct_message"
}
],
"source": "subscription"
}
},
"templateId": "nt_01kx4h2jdafq8bk9aftxak4b40"
},
"tenant_id": "tenant_abc"
},
"status": "PENDING",
"messageId": "1-5e2b2615-05efbb3acab9172f88dd3f6f"
}
],
"paging": {
"cursor": "MTpFWUNFRkRRN0c1WERTRTU2",
"more": true
}
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
A unique identifier representing the bulk job
Query Parameters
A unique identifier that allows for fetching the next set of users added to the bulk job
⌘I