Skip to main content
GET
/
audiences
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 audiences = await client.audiences.list();

console.log(audiences.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
)
audiences = client.audiences.list()
print(audiences.items)
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"),
)
audiences, err := client.Audiences.List(context.TODO(), courier.AudienceListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", audiences.Items)
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.audiences.AudienceListParams;
import com.courier.models.audiences.AudienceListResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();

AudienceListResponse audiences = client.audiences().list();
}
}
require "courier"

courier = Courier::Client.new(api_key: "My API Key")

audiences = courier.audiences.list

puts(audiences)
<?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 {
$audiences = $client->audiences->list(cursor: 'cursor');

var_dump($audiences);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using TryCourier;
using TryCourier.Models.Audiences;

CourierClient client = new();

AudienceListParams parameters = new();

var audiences = await client.Audiences.List(parameters);

Console.WriteLine(audiences);
courier audiences list \
--api-key 'My API Key'
curl --request GET \
--url https://api.courier.com/audiences \
--header 'Authorization: Bearer <token>'
{
  "paging": {
    "cursor": "MTpFWUNFRkRRN0c1WERTRTU2",
    "more": true
  },
  "items": [
    {
      "id": "aud_01H8M...",
      "name": "Example Name",
      "description": "An example description.",
      "operator": "AND",
      "filter": {
        "operator": "AND",
        "filters": [
          {
            "operator": "EQ",
            "path": "profile.title",
            "value": "Software Engineer"
          },
          {
            "operator": "IS_AFTER",
            "path": "profile.created_at",
            "value": "2024-01-01"
          }
        ]
      },
      "created_at": "2024-01-15T10:30:00.000Z",
      "updated_at": "2024-01-15T10:30:00.000Z"
    }
  ]
}
{
"message": "Example message text",
"type": "invalid_request_error"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

cursor
string | null

A unique identifier that allows for fetching the next set of audiences

Response

paging
Paging · object
required
items
Audience · object[]
required