Skip to main content
GET
/
messages
/
{id}
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 message = await client.messages.retrieve('msg_01j9e0m1m6fc38gsv2vkfqgzz2');

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
)
message = client.messages.retrieve(
"msg_01j9e0m1m6fc38gsv2vkfqgzz2",
)
print(message.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"),
)
message, err := client.Messages.Get(context.TODO(), "msg_01j9e0m1m6fc38gsv2vkfqgzz2")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", message.ID)
}
require "surge_api"

surge = SurgeAPI::Client.new(api_key: "My API Key")

message = surge.messages.retrieve("msg_01j9e0m1m6fc38gsv2vkfqgzz2")

puts(message)
<?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 {
$message = $client->messages->retrieve('msg_01j9e0m1m6fc38gsv2vkfqgzz2');

var_dump($message);
} catch (APIException $e) {
echo $e->getMessage();
}
curl --request GET \
--url https://api.surge.app/messages/{id} \
--header 'Authorization: Bearer <token>'
HttpResponse<String> response = Unirest.get("https://api.surge.app/messages/{id}")
.header("Authorization", "Bearer <token>")
.asString();
{
  "attachments": [
    {
      "id": "att_01j9e0m1m6fc38gsv2vkfqgzz2",
      "type": "image",
      "url": "https://api.surge.app/attachments/att_01jbwyqj7rejzat7pq03r7fgmf"
    }
  ],
  "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",
  "metadata": {
    "external_id": "12345"
  }
}
{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}

Authorizations

Authorization
string
header
required

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

Path Parameters

id
string
required

The ID of the message to retrieve.

Example:

"msg_01j9e0m1m6fc38gsv2vkfqgzz2"

Response

Message

A Message is a communication sent to a Contact.

attachments
Attachment · object[]
blast_id
string | null

The ID of the blast this message belongs to, if any. This can be used to attribute messages back to a specific blast.

body
string | null

The message body.

conversation
Conversation · object

A conversation with a Contact

Example:
{
"contact": {
"first_name": "Dominic",
"id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"last_name": "Toretto",
"phone_number": "+18015551234"
},
"id": "cnv_01j9e0dgmdfkj86c877ws0znae",
"phone_number": {
"id": "pn_01jsjwe4d9fx3tpymgtg958d9w",
"name": "(801) 555-2345",
"number": "+18015552345",
"type": "local"
}
}
id
string

Unique identifier for the object.

metadata
Metadata · object

Set of key-value pairs that will be stored with the object.