Skip to main content
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);
}
{
  "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
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

account_id
string
required

The account ID to list messages for.

Example:

"acct_01j9a43avnfqzbjfch6pygv1td"

Query Parameters

after
string

Cursor for forward pagination. Use the next_cursor from a previous response.

before
string

Cursor for backward pagination. Use the previous_cursor from a previous response.

Response

List of messages

A paginated list of messages

data
Message · object[]
required

The list of messages

pagination
Pagination · object
required

Cursor-based pagination information

Example:
{
"next_cursor": "g3QAAAABZAACaWRtAAAAGnBuXzAxamtzY2s5eDdkeW0wZnBxZjdjYmRyeQ==",
"previous_cursor": null
}