JavaScript
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const audience = await client.audiences.create('acct_01j9a43avnfqzbjfch6pygv1td', {
name: 'The Family',
});
console.log(audience.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
)
audience = client.audiences.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
name="The Family",
)
print(audience.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"),
)
audience, err := client.Audiences.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.AudienceNewParams{
Name: "The Family",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", audience.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
audience = surge.audiences.create("acct_01j9a43avnfqzbjfch6pygv1td", name: "The Family")
puts(audience)<?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 {
$audience = $client->audiences->create(
'acct_01j9a43avnfqzbjfch6pygv1td', name: 'The Family'
);
var_dump($audience);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/audiences \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "The Family"
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/audiences")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"The Family\"\n}")
.asString();{
"id": "aud_01j9dy8mdzfn3r0e8x1tbdrdrf",
"name": "The Family"
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Audiences
Create audience
Create a named audience (contact group) that you can reuse across multiple blast sends.
POST
/
accounts
/
{account_id}
/
audiences
JavaScript
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const audience = await client.audiences.create('acct_01j9a43avnfqzbjfch6pygv1td', {
name: 'The Family',
});
console.log(audience.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
)
audience = client.audiences.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
name="The Family",
)
print(audience.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"),
)
audience, err := client.Audiences.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.AudienceNewParams{
Name: "The Family",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", audience.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
audience = surge.audiences.create("acct_01j9a43avnfqzbjfch6pygv1td", name: "The Family")
puts(audience)<?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 {
$audience = $client->audiences->create(
'acct_01j9a43avnfqzbjfch6pygv1td', name: 'The Family'
);
var_dump($audience);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/audiences \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "The Family"
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/audiences")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"The Family\"\n}")
.asString();{
"id": "aud_01j9dy8mdzfn3r0e8x1tbdrdrf",
"name": "The Family"
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The account for which the audience should be created.
Example:
"acct_01j9a43avnfqzbjfch6pygv1td"
Body
application/json
Params for creating an audience
The audience name.
Maximum string length:
255