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)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"),
)
page, err := client.Messages.List(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.MessageListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
page = surge.messages.list("acct_01j9a43avnfqzbjfch6pygv1td")
puts(page)<?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 {
$page = $client->messages->list(
'acct_01j9a43avnfqzbjfch6pygv1td', after: 'after', before: 'before'
);
var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request GET \
--url https://api.surge.app/accounts/{account_id}/messages \
--header 'Authorization: Bearer <token>'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",
"number": "+18015552345",
"type": "local"
}
},
"id": "msg_01j9e0m1m6fc38gsv2vkfqgzz2"
}
],
"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)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"),
)
page, err := client.Messages.List(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.MessageListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
page = surge.messages.list("acct_01j9a43avnfqzbjfch6pygv1td")
puts(page)<?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 {
$page = $client->messages->list(
'acct_01j9a43avnfqzbjfch6pygv1td', after: 'after', before: 'before'
);
var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request GET \
--url https://api.surge.app/accounts/{account_id}/messages \
--header 'Authorization: Bearer <token>'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",
"number": "+18015552345",
"type": "local"
}
},
"id": "msg_01j9e0m1m6fc38gsv2vkfqgzz2"
}
],
"pagination": {
"next_cursor": null,
"previous_cursor": null
}
}{
"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 ID to list messages for.
Example:
"acct_01j9a43avnfqzbjfch6pygv1td"
Query Parameters
Cursor for forward pagination. Use the next_cursor from a previous response.
Cursor for backward pagination. Use the previous_cursor from a previous response.
Response
List of messages
A paginated list of messages
⌘I