π¬ Send SMS
Send SMS with Pingram without using Twilio or other third parties. Setup is quick and simple: hereβs how.
Install the SDK:
npm install pingram pip install pingram-python composer require pingram/php go get github.com/pingram-io/pingram-go dotnet add package Pingram Add the Pingram dependency to your pom.xml. Check Maven Central for the latest version.
<dependencies>
<dependency>
<groupId>io.pingram</groupId>
<artifactId>pingram</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies> gem install pingramOr add to your Gemfile: gem 'pingram'
Now, send an SMS notification from your backend:
TIP
Use your API key (pingram_sk_...). You can find it in the Environments
section of the Pingram dashboard.
import { Pingram } from 'pingram';
// Initialize with API key
const pingram = new Pingram({
apiKey: 'pingram_sk_...' // Your secret API key
});
// Send SMS notification
await pingram.send({
type: 'welcome_sms',
to: {
number: '+16175551212' // Replace using format [+][country code][area code][local number]
},
sms: {
message: 'Welcome to Acme Corp! Thanks for joining.'
}
}); import asyncio
from pingram import Pingram
async def send_sms():
async with Pingram(api_key="pingram_sk_...") as client:
await client.send({
"type": "welcome_sms",
"to": {
"number": "+16175551212" # Replace using format [+][country code][area code][local number]
},
"sms": {
"message": "Welcome to Acme Corp! Thanks for joining."
}
})
# Run the async function
asyncio.run(send_sms()) use Pingram\Client;
use Pingram\Model\SenderPostBody;
$client = new Client('pingram_sk_...');
$body = new SenderPostBody([
'type' => 'welcome_sms',
'to' => [
'id' => 'user123',
'number' => '+16175551212' // Replace using format [+][country code][area code][local number]
],
'sms' => [
'message' => 'Welcome to Acme Corp! Thanks for joining.'
]
]);
$client->send($body); package main
import (
"context"
"log"
pingram "github.com/pingram-io/pingram-go"
)
func main() {
client := pingram.NewClient("pingram_sk_...") // Your secret API key
body := pingram.SenderPostBody{
Type: pingram.PtrString("welcome_sms"),
User: &pingram.GetUsersResponseUsersInner{
Id: "user123",
Number: pingram.PtrString("+16175551212"), // Replace using format [+][country code][area code][local number]
},
Sms: &pingram.SenderPostBodySms{
Message: pingram.PtrString("Welcome to Acme Corp! Thanks for joining."),
},
}
_, _, err := client.DefaultAPI.Send(context.Background()).SenderPostBody(body).Execute()
if err != nil {
log.Fatal(err)
}
} using Pingram;
using Pingram.Model;
var client = new PingramClient("your_api_key");
var body = new SenderPostBody
{
Type = "welcome_sms",
To = new SenderPostBodyTo { Id = "user123", Number = "+16175551212" }, // Replace using format [+][country code][area code][local number]
Sms = new SenderPostBodySms { Message = "Welcome to Acme Corp! Thanks for joining." }
};
await client.SendAsync(body); package com.example;
import io.pingram.Pingram;
import io.pingram.model.*;
public class Example {
public static void main(String[] args) {
Pingram pingram = new Pingram("pingram_sk_..."); // Your secret API key
SenderPostBodyTo to = new SenderPostBodyTo()
.id("user123")
.number("+16175551212"); // Replace using format [+][country code][area code][local number]
SenderPostBody body = new SenderPostBody()
.type("welcome_sms")
.to(to)
.sms(new SenderPostBodySms()
.message("Welcome to Acme Corp! Thanks for joining.")
);
SenderPostResponse response = pingram.send(body);
System.out.println("Tracking ID: " + response.getTrackingId());
}
} require 'pingram'
client = Pingram::Client.new(api_key: 'pingram_sk_...')
body = Pingram::SenderPostBody.new(
type: 'welcome_sms',
to: { id: 'user123', number: '+16175551212' },
sms: { message: 'Welcome to Acme Corp! Thanks for joining.' }
)
client.send(body) Youβre All Set!
π Congrats! Youβre now sending SMS notifications!
For more advanced features like sender numbers, A2P 10DLC registration, and SMS best practices, check out our SMS Channel documentation.