Skip to main content
GET
/
audiences
/
{audience_id}
/
contacts
JavaScript
import Surge from '@surgeapi/node';

const client = new Surge({
  apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const contact of client.audiences.listContacts('aud_01j9a43avnfqzbjfch6pygv1td')) {
  console.log(contact.id);
}
import os
from surge import Surge

client = Surge(
api_key=os.environ.get("SURGE_API_KEY"), # This is the default and can be omitted
)
page = client.audiences.list_contacts(
audience_id="aud_01j9a43avnfqzbjfch6pygv1td",
)
page = page.data[0]
print(page.id)
package main

import (
"context"
"fmt"

"github.com/stainless-sdks/surge-go"
"github.com/stainless-sdks/surge-go/option"
)

func main() {
client := surge.NewClient(
option.WithAPIKey("My API Key"),
)
page, err := client.Audiences.ListContacts(
context.TODO(),
"aud_01j9a43avnfqzbjfch6pygv1td",
surge.AudienceListContactsParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
require "surge_api"

surge = SurgeAPI::Client.new(api_key: "My API Key")

page = surge.audiences.list_contacts("aud_01j9a43avnfqzbjfch6pygv1td")

puts(page)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Surge\Client;
use Surge\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API Key');

try {
$page = $client->audiences->listContacts(
'aud_01j9a43avnfqzbjfch6pygv1td', after: 'after', before: 'before'
);

var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}
curl --request GET \
--url https://api.surge.app/audiences/{audience_id}/contacts \
--header 'Authorization: Bearer <token>'
HttpResponse<String> response = Unirest.get("https://api.surge.app/audiences/{audience_id}/contacts")
.header("Authorization", "Bearer <token>")
.asString();
{
  "data": [
    {
      "email": "dom@toretto.family",
      "first_name": "Dominic",
      "id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
      "last_name": "Toretto",
      "metadata": {
        "car": "1970 Dodge Charger R/T"
      },
      "phone_number": "+18015551234"
    }
  ],
  "pagination": {
    "next_cursor": null,
    "previous_cursor": null
  }
}
{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}

Authorizations

Authorization
string
header
required

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

Path Parameters

audience_id
string
required

The audience ID to list contacts for.

Example:

"aud_01j9a43avnfqzbjfch6pygv1td"

Query Parameters

after
string

Cursor for forward pagination. Use the next_cursor from a previous response.

before
string

Cursor for backward pagination. Use the previous_cursor from a previous response.

Response

List of contacts

A paginated list of contacts

data
Contact · object[]
required

The list of contacts

pagination
Pagination · object
required

Cursor-based pagination information

Example:
{
"next_cursor": "g3QAAAABZAACaWRtAAAAGnBuXzAxamtzY2s5eDdkeW0wZnBxZjdjYmRyeQ==",
"previous_cursor": null
}