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.contacts.create('acct_01j9a43avnfqzbjfch6pygv1td', {
phone_number: '+18015551234',
});
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.contacts.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
phone_number="+18015551234",
)
print(contact.id)require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
contact = surge.contacts.create("acct_01j9a43avnfqzbjfch6pygv1td", phone_number: "+18015551234")
puts(contact)curl --request POST \
--url https://api.surge.app/accounts/{account_id}/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "dom@toretto.family",
"first_name": "Dominic",
"last_name": "Toretto",
"metadata": {
"car": "1970 Dodge Charger R/T"
},
"outbound_disabled": false,
"phone_number": "+18015551234"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.surge.app/accounts/{account_id}/contacts",
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([
'email' => 'dom@toretto.family',
'first_name' => 'Dominic',
'last_name' => 'Toretto',
'metadata' => [
'car' => '1970 Dodge Charger R/T'
],
'outbound_disabled' => false,
'phone_number' => '+18015551234'
]),
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}/contacts"
payload := strings.NewReader("{\n \"email\": \"dom@toretto.family\",\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"metadata\": {\n \"car\": \"1970 Dodge Charger R/T\"\n },\n \"outbound_disabled\": false,\n \"phone_number\": \"+18015551234\"\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}/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"dom@toretto.family\",\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"metadata\": {\n \"car\": \"1970 Dodge Charger R/T\"\n },\n \"outbound_disabled\": false,\n \"phone_number\": \"+18015551234\"\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"
}
}Contacts
Create contact
Create a contact record identified by phone number under an account.
POST
/
accounts
/
{account_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.contacts.create('acct_01j9a43avnfqzbjfch6pygv1td', {
phone_number: '+18015551234',
});
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.contacts.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
phone_number="+18015551234",
)
print(contact.id)require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
contact = surge.contacts.create("acct_01j9a43avnfqzbjfch6pygv1td", phone_number: "+18015551234")
puts(contact)curl --request POST \
--url https://api.surge.app/accounts/{account_id}/contacts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "dom@toretto.family",
"first_name": "Dominic",
"last_name": "Toretto",
"metadata": {
"car": "1970 Dodge Charger R/T"
},
"outbound_disabled": false,
"phone_number": "+18015551234"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.surge.app/accounts/{account_id}/contacts",
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([
'email' => 'dom@toretto.family',
'first_name' => 'Dominic',
'last_name' => 'Toretto',
'metadata' => [
'car' => '1970 Dodge Charger R/T'
],
'outbound_disabled' => false,
'phone_number' => '+18015551234'
]),
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}/contacts"
payload := strings.NewReader("{\n \"email\": \"dom@toretto.family\",\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"metadata\": {\n \"car\": \"1970 Dodge Charger R/T\"\n },\n \"outbound_disabled\": false,\n \"phone_number\": \"+18015551234\"\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}/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"dom@toretto.family\",\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"metadata\": {\n \"car\": \"1970 Dodge Charger R/T\"\n },\n \"outbound_disabled\": false,\n \"phone_number\": \"+18015551234\"\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
Path Parameters
Body
application/json
Parameters for creating a contact
Response
Created contact
A contact who has consented to receive messages