import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const blast = await client.blasts.create('acct_01j9a43avnfqzbjfch6pygv1td');
console.log(blast.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
)
blast = client.blasts.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
)
print(blast.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"),
)
blast, err := client.Blasts.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.BlastNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", blast.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
blast = surge.blasts.create("acct_01j9a43avnfqzbjfch6pygv1td")
puts(blast)<?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 {
$blast = $client->blasts->create(
'acct_01j9a43avnfqzbjfch6pygv1td',
attachments: [['url' => 'https://example.com/image.jpg']],
body: 'Join us for our grand opening!',
contacts: ['ctc_01jxwtp1vse91twb5bj977gav9'],
from: '+18015552345',
name: 'Grand Opening Announcement',
segments: ['aud_01jxwtwzqhfykb31dt6mvpsa9k'],
sendAt: new \DateTimeImmutable('2024-02-01T15:00:00Z'),
to: [
'aud_01j9dy8mdzfn3r0e8x1tbdrdrf',
'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf',
'+18015551234',
'+18015555678',
],
);
var_dump($blast);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/blasts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"attachments": [
{
"url": "https://example.com/image.jpg"
}
],
"body": "Join us for our grand opening!",
"from": "+18015552345",
"name": "Grand Opening Announcement",
"send_at": "2024-02-01T15:00:00Z",
"to": [
"aud_01j9dy8mdzfn3r0e8x1tbdrdrf",
"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"+18015551234",
"+18015555678"
]
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/blasts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attachments\": [\n {\n \"url\": \"https://example.com/image.jpg\"\n }\n ],\n \"body\": \"Join us for our grand opening!\",\n \"from\": \"+18015552345\",\n \"name\": \"Grand Opening Announcement\",\n \"send_at\": \"2024-02-01T15:00:00Z\",\n \"to\": [\n \"aud_01j9dy8mdzfn3r0e8x1tbdrdrf\",\n \"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf\",\n \"+18015551234\",\n \"+18015555678\"\n ]\n}")
.asString();{
"attachments": [
{
"url": "https://example.com/image.jpg"
}
],
"body": "Join us for our grand opening!",
"id": "bst_01j9dy8mdzfn3r0e8x1tbdrdrf",
"name": "Grand Opening Announcement",
"send_at": "2024-02-01T15:00:00Z"
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Create blast
Send a message to a list of recipients or an audience in a single API call.
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const blast = await client.blasts.create('acct_01j9a43avnfqzbjfch6pygv1td');
console.log(blast.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
)
blast = client.blasts.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
)
print(blast.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"),
)
blast, err := client.Blasts.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.BlastNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", blast.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
blast = surge.blasts.create("acct_01j9a43avnfqzbjfch6pygv1td")
puts(blast)<?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 {
$blast = $client->blasts->create(
'acct_01j9a43avnfqzbjfch6pygv1td',
attachments: [['url' => 'https://example.com/image.jpg']],
body: 'Join us for our grand opening!',
contacts: ['ctc_01jxwtp1vse91twb5bj977gav9'],
from: '+18015552345',
name: 'Grand Opening Announcement',
segments: ['aud_01jxwtwzqhfykb31dt6mvpsa9k'],
sendAt: new \DateTimeImmutable('2024-02-01T15:00:00Z'),
to: [
'aud_01j9dy8mdzfn3r0e8x1tbdrdrf',
'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf',
'+18015551234',
'+18015555678',
],
);
var_dump($blast);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/blasts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"attachments": [
{
"url": "https://example.com/image.jpg"
}
],
"body": "Join us for our grand opening!",
"from": "+18015552345",
"name": "Grand Opening Announcement",
"send_at": "2024-02-01T15:00:00Z",
"to": [
"aud_01j9dy8mdzfn3r0e8x1tbdrdrf",
"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
"+18015551234",
"+18015555678"
]
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/blasts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attachments\": [\n {\n \"url\": \"https://example.com/image.jpg\"\n }\n ],\n \"body\": \"Join us for our grand opening!\",\n \"from\": \"+18015552345\",\n \"name\": \"Grand Opening Announcement\",\n \"send_at\": \"2024-02-01T15:00:00Z\",\n \"to\": [\n \"aud_01j9dy8mdzfn3r0e8x1tbdrdrf\",\n \"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf\",\n \"+18015551234\",\n \"+18015555678\"\n ]\n}")
.asString();{
"attachments": [
{
"url": "https://example.com/image.jpg"
}
],
"body": "Join us for our grand opening!",
"id": "bst_01j9dy8mdzfn3r0e8x1tbdrdrf",
"name": "Grand Opening Announcement",
"send_at": "2024-02-01T15:00:00Z"
}{
"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 for which the blast should be sent.
"acct_01j9a43avnfqzbjfch6pygv1td"
Body
Parameters for creating a Blast
Show child attributes
Show child attributes
The message body.
Deprecated. Use to instead.
The phone number from which to send the blast. This can be either the phone number in E.164 format or a Surge phone number id. If not provided, the account's default phone number is used.
^\+[1-9]\d{6,14}$|^\d{5,6}$|^pn_[[:alnum:]]{26}$"+18015552345"
Optional name for the blast.
Deprecated. Use to with audience IDs instead.
When to send the blast. If not provided, sends immediately.
List of recipients to whom the blast should be sent. This can be a combination of contact IDs, audience IDs, and phone numbers.
"ctc_01jxwtp1vse91twb5bj977gav9"