Getting Started
Developing against divergent Connect couldn’t be simpler with our REST API or official client libraries.
Connect is a full omnichannel communication suite. Everything you can do in PureSMS you can do here too, plus more advanced features such as templating, link shortening, inbound SMS and Client Tagging for resellers.
Setting things up
Section titled “Setting things up”To get started, you’ll need to set up your Connect Workspace properly.
-
Create a Workspace at Connect.
Open Connect -
If you’re not live, make sure you’ve verified your Test Number so that you can send from “ConnectTest”.
Please note that only UK numbers are currently supported in Test Mode.
Where do I do this?
Within Connect, head to “Settings” and then “Test Mode”.
-
If you’re live (or want to go live soon), add at least one Sender name to your Workspace and the Country that you’ll be sending to.
Where do I do this?
Within Connect, open “Senders” and then “Create a Sender”.
You’ll be asked for a Sender Name, Sample Content and at least 1 Country to register the Sender in.
-
Add a new API Key to your Workspace.
Where do I do this?
Within Connect, open “Settings” and then “API Keys”. You can then click “Add API Key”.
-
🎉 Ready to go.
Sending your first SMS
Section titled “Sending your first SMS”Choose your preferred method to send your first SMS.
Installation
Section titled “Installation”Install the Divergent.Connect package from NuGet:
dotnet add package Divergent.ConnectChoose the setup method that works best for your application:
var builder = WebApplication.CreateBuilder(args);
// Add Connect clientbuilder.AddDivergentConnect();
var app = builder.Build();Add your configuration to appsettings.json:
{ "Divergent": { "Connect": { "ApiKey": "your-api-key", "DefaultSmsSender": "YourSender" } }}public void ConfigureServices(IServiceCollection services){ services.AddDivergentConnect(Configuration);}Add your configuration to appsettings.json:
{ "Divergent": { "Connect": { "ApiKey": "your-api-key", "DefaultSmsSender": "YourSender" } }}using Divergent.Connect;
var smsClient = new ConnectClientBuilder() .WithApiKey("your-api-key") .WithDefaultSmsSender("YourSender") .BuildSmsClient();Send your first SMS
Section titled “Send your first SMS”// Inject IConnectSms into your service/controller (or use the manually built client)public class MyService(IConnectSms smsClient){ public async Task SendWelcomeSms(string phoneNumber) { await smsClient.SendSmsAsync(new ConnectSmsMessage { To = phoneNumber, // E.164 format, e.g. "+447700900123" Content = "Hello world, from Connect!" }); }}Installation
Section titled “Installation”Install the @divergent/connect package from npm:
npm install @divergent/connectSend your first SMS
Section titled “Send your first SMS”import { ConnectClient } from '@divergent/connect';
const client = new ConnectClient({ apiKey: process.env.DIVERGENT_CONNECT_API_KEY, defaultSmsSender: 'YourSender'});
const result = await client.sms.send({ to: '+447700900123', // E.164 format content: 'Hello world, from Connect!'});
console.log('SMS sent! ID:', result.id);Paste this in your favourite terminal to send your first SMS. Don’t forget to replace the placeholders.
curl -X POST https://connect-api.divergent.cloud/sms/send \ -H "X-Api-Key: { API_KEY }" \ --json '{ "sender": "{ SENDER_NAME }", "recipient": "{ RECIPIENT_NUMBER }", "content": "Hello world, from Connect!" }'