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 tollFreeCampaign = await client.tollFreeCampaigns.create('acct_01j9a43avnfqzbjfch6pygv1td', {
consent_flows: [{ script: 'xxxxxxxxxxxxxxxxxxxx', type: 'verbal' }],
description: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
message_samples: ['string'],
phone_number_id: 'phone_number_id',
privacy_policy_url: 'https://example.com',
terms_and_conditions_url: 'https://example.com',
use_cases: ['two_factor_authentication'],
});
console.log(tollFreeCampaign.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
)
toll_free_campaign = client.toll_free_campaigns.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
consent_flows=[{
"script": "xxxxxxxxxxxxxxxxxxxx",
"type": "verbal",
}],
description="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
message_samples=["string"],
phone_number_id="phone_number_id",
privacy_policy_url="https://example.com",
terms_and_conditions_url="https://example.com",
use_cases=["two_factor_authentication"],
)
print(toll_free_campaign.id)require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
toll_free_campaign = surge.toll_free_campaigns.create(
"acct_01j9a43avnfqzbjfch6pygv1td",
consent_flows: [{script: "xxxxxxxxxxxxxxxxxxxx", type: :verbal}],
description: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
message_samples: ["string"],
phone_number_id: "phone_number_id",
privacy_policy_url: "https://example.com",
terms_and_conditions_url: "https://example.com",
use_cases: [:two_factor_authentication]
)
puts(toll_free_campaign)curl --request POST \
--url https://api.surge.app/accounts/{account_id}/toll_free_campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"consent_flows": [
{
"script": "<string>",
"type": "verbal"
}
],
"description": "<string>",
"message_samples": [
"<string>"
],
"phone_number_id": "<string>",
"privacy_policy_url": "<string>",
"terms_and_conditions_url": "<string>",
"use_cases": [],
"includes": [
"age_gated"
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.surge.app/accounts/{account_id}/toll_free_campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'consent_flows' => [
[
'script' => '<string>',
'type' => 'verbal'
]
],
'description' => '<string>',
'message_samples' => [
'<string>'
],
'phone_number_id' => '<string>',
'privacy_policy_url' => '<string>',
'terms_and_conditions_url' => '<string>',
'use_cases' => [
],
'includes' => [
'age_gated'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.surge.app/accounts/{account_id}/toll_free_campaigns"
payload := strings.NewReader("{\n \"consent_flows\": [\n {\n \"script\": \"<string>\",\n \"type\": \"verbal\"\n }\n ],\n \"description\": \"<string>\",\n \"message_samples\": [\n \"<string>\"\n ],\n \"phone_number_id\": \"<string>\",\n \"privacy_policy_url\": \"<string>\",\n \"terms_and_conditions_url\": \"<string>\",\n \"use_cases\": [],\n \"includes\": [\n \"age_gated\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/toll_free_campaigns")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"consent_flows\": [\n {\n \"script\": \"<string>\",\n \"type\": \"verbal\"\n }\n ],\n \"description\": \"<string>\",\n \"message_samples\": [\n \"<string>\"\n ],\n \"phone_number_id\": \"<string>\",\n \"privacy_policy_url\": \"<string>\",\n \"terms_and_conditions_url\": \"<string>\",\n \"use_cases\": [],\n \"includes\": [\n \"age_gated\"\n ]\n}")
.asString();{
"consent_flows": [
{
"script": "<string>",
"type": "verbal"
}
],
"description": "<string>",
"id": "<string>",
"includes": [
"age_gated"
],
"message_samples": [
"<string>"
],
"phone_number_id": "<string>",
"privacy_policy_url": "<string>",
"status": "active",
"terms_and_conditions_url": "<string>",
"use_cases": [
"two_factor_authentication"
]
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Toll-free Campaigns
Create toll-free campaign
Create a toll-free campaign and submit it for Surge review.
POST
/
accounts
/
{account_id}
/
toll_free_campaigns
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 tollFreeCampaign = await client.tollFreeCampaigns.create('acct_01j9a43avnfqzbjfch6pygv1td', {
consent_flows: [{ script: 'xxxxxxxxxxxxxxxxxxxx', type: 'verbal' }],
description: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
message_samples: ['string'],
phone_number_id: 'phone_number_id',
privacy_policy_url: 'https://example.com',
terms_and_conditions_url: 'https://example.com',
use_cases: ['two_factor_authentication'],
});
console.log(tollFreeCampaign.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
)
toll_free_campaign = client.toll_free_campaigns.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
consent_flows=[{
"script": "xxxxxxxxxxxxxxxxxxxx",
"type": "verbal",
}],
description="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
message_samples=["string"],
phone_number_id="phone_number_id",
privacy_policy_url="https://example.com",
terms_and_conditions_url="https://example.com",
use_cases=["two_factor_authentication"],
)
print(toll_free_campaign.id)require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
toll_free_campaign = surge.toll_free_campaigns.create(
"acct_01j9a43avnfqzbjfch6pygv1td",
consent_flows: [{script: "xxxxxxxxxxxxxxxxxxxx", type: :verbal}],
description: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
message_samples: ["string"],
phone_number_id: "phone_number_id",
privacy_policy_url: "https://example.com",
terms_and_conditions_url: "https://example.com",
use_cases: [:two_factor_authentication]
)
puts(toll_free_campaign)curl --request POST \
--url https://api.surge.app/accounts/{account_id}/toll_free_campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"consent_flows": [
{
"script": "<string>",
"type": "verbal"
}
],
"description": "<string>",
"message_samples": [
"<string>"
],
"phone_number_id": "<string>",
"privacy_policy_url": "<string>",
"terms_and_conditions_url": "<string>",
"use_cases": [],
"includes": [
"age_gated"
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.surge.app/accounts/{account_id}/toll_free_campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'consent_flows' => [
[
'script' => '<string>',
'type' => 'verbal'
]
],
'description' => '<string>',
'message_samples' => [
'<string>'
],
'phone_number_id' => '<string>',
'privacy_policy_url' => '<string>',
'terms_and_conditions_url' => '<string>',
'use_cases' => [
],
'includes' => [
'age_gated'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.surge.app/accounts/{account_id}/toll_free_campaigns"
payload := strings.NewReader("{\n \"consent_flows\": [\n {\n \"script\": \"<string>\",\n \"type\": \"verbal\"\n }\n ],\n \"description\": \"<string>\",\n \"message_samples\": [\n \"<string>\"\n ],\n \"phone_number_id\": \"<string>\",\n \"privacy_policy_url\": \"<string>\",\n \"terms_and_conditions_url\": \"<string>\",\n \"use_cases\": [],\n \"includes\": [\n \"age_gated\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/toll_free_campaigns")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"consent_flows\": [\n {\n \"script\": \"<string>\",\n \"type\": \"verbal\"\n }\n ],\n \"description\": \"<string>\",\n \"message_samples\": [\n \"<string>\"\n ],\n \"phone_number_id\": \"<string>\",\n \"privacy_policy_url\": \"<string>\",\n \"terms_and_conditions_url\": \"<string>\",\n \"use_cases\": [],\n \"includes\": [\n \"age_gated\"\n ]\n}")
.asString();{
"consent_flows": [
{
"script": "<string>",
"type": "verbal"
}
],
"description": "<string>",
"id": "<string>",
"includes": [
"age_gated"
],
"message_samples": [
"<string>"
],
"phone_number_id": "<string>",
"privacy_policy_url": "<string>",
"status": "active",
"terms_and_conditions_url": "<string>",
"use_cases": [
"two_factor_authentication"
]
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}{
"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 toll-free campaign should be created.
Example:
"acct_01j9a43avnfqzbjfch6pygv1td"
Body
application/json
Parameters for creating a toll-free campaign through Surge
Required array length:
1 element- Option 1
- Option 2
- Option 3
- Option 4
Show child attributes
Show child attributes
An explanation of how the toll-free number will be used.
Required string length:
40 - 500Required array length:
1 elementMaximum string length:
1000The toll-free phone number to register.
Maximum string length:
255Maximum string length:
255Minimum array length:
1Available options:
two_factor_authentication, account_notification, customer_care, charity, delivery_notification, fraud_alert, event, higher_education, k12_education, marketing, polling_voting, political, public_service_announcement, security_alert Available options:
age_gated Response
Created toll-free campaign
A toll-free campaign registration for a phone number.
A consent flow returned on toll-free campaign responses.
- TollFreeCampaignConsentFlow
- TollFreeCampaignConsentFlow
- TollFreeCampaignConsentFlow
- TollFreeCampaignConsentFlow
- TollFreeCampaignConsentFlow
Show child attributes
Show child attributes
The toll-free campaign ID
Available options:
age_gated The toll-free phone number ID
The current status of the toll-free campaign.
Available options:
active, canceled, created, in_review, rejected Available options:
two_factor_authentication, account_notification, customer_care, charity, delivery_notification, fraud_alert, event, higher_education, k12_education, marketing, polling_voting, political, public_service_announcement, security_alert