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 message of client.messages.list('acct_01j9a43avnfqzbjfch6pygv1td')) {
console.log(message.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.messages.list(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
)
page = page.data[0]
print(page.id)require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
page = surge.messages.list("acct_01j9a43avnfqzbjfch6pygv1td")
puts(page)curl --request GET \
--url https://api.surge.app/accounts/{account_id}/messages \
--header 'Authorization: Bearer <token>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.surge.app/accounts/{account_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.surge.app/accounts/{account_id}/messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.surge.app/accounts/{account_id}/messages")
.header("Authorization", "Bearer <token>")
.asString();{
"data": [
{
"attachments": [],
"blast_id": null,
"body": "Thought you could leave without saying goodbye?",
"conversation": {
"contact": {
"first_name": "Dominic",
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"last_name": "Toretto",
"phone_number": "+18015551234"
},
"id": "cnv_01j9e0dgmdfkj86c877ws0znae",
"phone_number": {
"id": "pn_01jsjwe4d9fx3tpymgtg958d9w",
"metadata": {
"location": "Downtown store"
},
"number": "+18015552345",
"type": "local"
}
},
"created_at": "2024-10-21T23:29:40Z",
"failure_reason": null,
"id": "msg_01j9e0m1m6fc38gsv2vkfqgzz2",
"status": "delivered"
}
],
"pagination": {
"next_cursor": null,
"previous_cursor": null
}
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Messages
List messages
List messages for an account with cursor-based pagination and optional conversation filtering.
GET
/
accounts
/
{account_id}
/
messages
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 message of client.messages.list('acct_01j9a43avnfqzbjfch6pygv1td')) {
console.log(message.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.messages.list(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
)
page = page.data[0]
print(page.id)require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
page = surge.messages.list("acct_01j9a43avnfqzbjfch6pygv1td")
puts(page)curl --request GET \
--url https://api.surge.app/accounts/{account_id}/messages \
--header 'Authorization: Bearer <token>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.surge.app/accounts/{account_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.surge.app/accounts/{account_id}/messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.surge.app/accounts/{account_id}/messages")
.header("Authorization", "Bearer <token>")
.asString();{
"data": [
{
"attachments": [],
"blast_id": null,
"body": "Thought you could leave without saying goodbye?",
"conversation": {
"contact": {
"first_name": "Dominic",
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"last_name": "Toretto",
"phone_number": "+18015551234"
},
"id": "cnv_01j9e0dgmdfkj86c877ws0znae",
"phone_number": {
"id": "pn_01jsjwe4d9fx3tpymgtg958d9w",
"metadata": {
"location": "Downtown store"
},
"number": "+18015552345",
"type": "local"
}
},
"created_at": "2024-10-21T23:29:40Z",
"failure_reason": null,
"id": "msg_01j9e0m1m6fc38gsv2vkfqgzz2",
"status": "delivered"
}
],
"pagination": {
"next_cursor": null,
"previous_cursor": null
}
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Authorizations
Path Parameters
Query Parameters
Response
List of messages
A paginated list of messages