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 contact = await client.audiences.addContact('aud_01j9a43avnfqzbjfch6pygv1td', {
id: 'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf',
});
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
)
contact = client.audiences.add_contact(
audience_id="aud_01j9a43avnfqzbjfch6pygv1td",
id="ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
)
print(contact.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"),
)
contact, err := client.Audiences.AddContact(
context.TODO(),
"aud_01j9a43avnfqzbjfch6pygv1td",
surge.AudienceAddContactParams{
ID: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", contact.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
contact = surge.audiences.add_contact("aud_01j9a43avnfqzbjfch6pygv1td", id: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")
puts(contact)<?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 {
$contact = $client->audiences->addContact(
'aud_01j9a43avnfqzbjfch6pygv1td', id: 'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf'
);
var_dump($contact);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/audiences/{audience_id}/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/audiences/{audience_id}/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf\"\n}")
.asString();{
"email": "dom@toretto.family",
"first_name": "Dominic",
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"last_name": "Toretto",
"metadata": {
"car": "1970 Dodge Charger R/T"
},
"outbound_disabled": false,
"phone_number": "+18015551234"
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Audiences
Add contact to audience
Add a contact to an audience.
POST
/
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
});
const contact = await client.audiences.addContact('aud_01j9a43avnfqzbjfch6pygv1td', {
id: 'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf',
});
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
)
contact = client.audiences.add_contact(
audience_id="aud_01j9a43avnfqzbjfch6pygv1td",
id="ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
)
print(contact.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"),
)
contact, err := client.Audiences.AddContact(
context.TODO(),
"aud_01j9a43avnfqzbjfch6pygv1td",
surge.AudienceAddContactParams{
ID: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", contact.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
contact = surge.audiences.add_contact("aud_01j9a43avnfqzbjfch6pygv1td", id: "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")
puts(contact)<?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 {
$contact = $client->audiences->addContact(
'aud_01j9a43avnfqzbjfch6pygv1td', id: 'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf'
);
var_dump($contact);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/audiences/{audience_id}/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/audiences/{audience_id}/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf\"\n}")
.asString();{
"email": "dom@toretto.family",
"first_name": "Dominic",
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"last_name": "Toretto",
"metadata": {
"car": "1970 Dodge Charger R/T"
},
"outbound_disabled": false,
"phone_number": "+18015551234"
}{
"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 audience ID to add the contact to.
Example:
"aud_01j9a43avnfqzbjfch6pygv1td"
Body
application/json
Params for adding an existing contact to a manual audience
The ID of the contact to add. The contact must belong to the same account as the audience.
Response
The contact, now a member of the audience
A contact who has consented to receive messages
Unique identifier for the object.
The contact's phone number in E.164 format.
Pattern:
^\+[1-9]\d{6,14}$Example:
"+18015551234"
The contact's email address.
The contact's first name.
The contact's last name.
Set of key-value pairs that will be stored with the object.
Show child attributes
Show child attributes
Whether outbound messaging has been manually disabled for the contact.