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.create('acct_01j9a43avnfqzbjfch6pygv1td', {
conversation: { contact: { phone_number: '+18015551234' } },
});
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.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
conversation={
"contact": {
"phone_number": "+18015551234"
}
},
)
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.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.MessageNewParams{
OfMessagesWithConversation: &surge.MessageNewParamsMessageParamsMessageParamsWithConversation{
Conversation: surge.MessageNewParamsMessageParamsMessageParamsWithConversationConversation{
Contact: surge.MessageNewParamsMessageParamsMessageParamsWithConversationConversationContact{
PhoneNumber: "+18015551234",
},
},
},
},
)
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.create(
"acct_01j9a43avnfqzbjfch6pygv1td",
message_params: {conversation: {contact: {phone_number: "+18015551234"}}}
)
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->create(
'acct_01j9a43avnfqzbjfch6pygv1td',
conversation: [
'contact' => [
'phoneNumber' => '+18015551234',
'email' => 'dom@toretto.family',
'firstName' => 'Dominic',
'lastName' => 'Toretto',
'metadata' => ['car' => '1970 Dodge Charger R/T'],
'outboundDisabled' => false,
],
'phoneNumber' => '+18015556789',
],
attachments: [['url' => 'https://toretto.family/coronas.gif']],
body: 'body',
metadata: ['foo' => 'string'],
sendAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
settings: ['linkShortening' => 'enabled'],
to: '+18015551234',
from: '+18015552345',
);
var_dump($message);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"attachments": [
{
"url": "https://toretto.family/coronas.gif"
}
],
"body": "Thought you could leave without saying goodbye?",
"conversation": {
"contact": {
"first_name": "Dominic",
"last_name": "Toretto",
"phone_number": "+18015551234"
}
},
"metadata": {
"external_id": "12345"
},
"settings": {
"link_shortening": "enabled"
}
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attachments\": [\n {\n \"url\": \"https://toretto.family/coronas.gif\"\n }\n ],\n \"body\": \"Thought you could leave without saying goodbye?\",\n \"conversation\": {\n \"contact\": {\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"phone_number\": \"+18015551234\"\n }\n },\n \"metadata\": {\n \"external_id\": \"12345\"\n },\n \"settings\": {\n \"link_shortening\": \"enabled\"\n }\n}")
.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"
}
}Send message
Queue an SMS or MMS message from a phone number to be sent to a recipient, asynchronously.
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.create('acct_01j9a43avnfqzbjfch6pygv1td', {
conversation: { contact: { phone_number: '+18015551234' } },
});
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.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
conversation={
"contact": {
"phone_number": "+18015551234"
}
},
)
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.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.MessageNewParams{
OfMessagesWithConversation: &surge.MessageNewParamsMessageParamsMessageParamsWithConversation{
Conversation: surge.MessageNewParamsMessageParamsMessageParamsWithConversationConversation{
Contact: surge.MessageNewParamsMessageParamsMessageParamsWithConversationConversationContact{
PhoneNumber: "+18015551234",
},
},
},
},
)
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.create(
"acct_01j9a43avnfqzbjfch6pygv1td",
message_params: {conversation: {contact: {phone_number: "+18015551234"}}}
)
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->create(
'acct_01j9a43avnfqzbjfch6pygv1td',
conversation: [
'contact' => [
'phoneNumber' => '+18015551234',
'email' => 'dom@toretto.family',
'firstName' => 'Dominic',
'lastName' => 'Toretto',
'metadata' => ['car' => '1970 Dodge Charger R/T'],
'outboundDisabled' => false,
],
'phoneNumber' => '+18015556789',
],
attachments: [['url' => 'https://toretto.family/coronas.gif']],
body: 'body',
metadata: ['foo' => 'string'],
sendAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
settings: ['linkShortening' => 'enabled'],
to: '+18015551234',
from: '+18015552345',
);
var_dump($message);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"attachments": [
{
"url": "https://toretto.family/coronas.gif"
}
],
"body": "Thought you could leave without saying goodbye?",
"conversation": {
"contact": {
"first_name": "Dominic",
"last_name": "Toretto",
"phone_number": "+18015551234"
}
},
"metadata": {
"external_id": "12345"
},
"settings": {
"link_shortening": "enabled"
}
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attachments\": [\n {\n \"url\": \"https://toretto.family/coronas.gif\"\n }\n ],\n \"body\": \"Thought you could leave without saying goodbye?\",\n \"conversation\": {\n \"contact\": {\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"phone_number\": \"+18015551234\"\n }\n },\n \"metadata\": {\n \"external_id\": \"12345\"\n },\n \"settings\": {\n \"link_shortening\": \"enabled\"\n }\n}")
.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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The account from which the message should be sent.
"acct_01j9a43avnfqzbjfch6pygv1td"
Body
- MessageParamsWithConversation
- SimpleMessageParams
Create a message while including parameters for the conversation in which the message should be sent.
Params for selecting or creating a new conversation. Either the id or the Contact must be given.
Show child attributes
Show child attributes
{
"contact": {
"first_name": "Dominic",
"last_name": "Toretto",
"phone_number": "+18015551234"
},
"phone_number": "+18015556789"
}
Show child attributes
Show child attributes
The message body.
Set of key-value pairs that will be stored with the object.
Show child attributes
Show child attributes
An optional datetime for scheduling message up to a couple of months in the future.
Per-message setting overrides.
Show child attributes
Show child attributes
{ "link_shortening": "enabled" }
Response
Created message
A Message is a communication sent to a Contact.
Show child attributes
Show child attributes
The ID of the blast this message belongs to, if any. This can be used to attribute messages back to a specific blast.
The message body.
A conversation with a Contact
Show child attributes
Show child attributes
{
"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"
}
}
Unique identifier for the object.
Set of key-value pairs that will be stored with the object.
Show child attributes
Show child attributes