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 that powers not only its own event-driven APIs used by SaaS products around the globe, but also PureSMS, our simple SMS platform.
Setting things up
Section titled “Setting things up”To get started, you’ll need to set up your Connect Workspace properly.
-
Create a Workspace.
Open PureSMS Open Connect (coming soon) -
If you’re not live, make sure you’ve verified your Test Number so that you can send from “ConnectTest”.
Please note that only numbers from UK, EU and other select countries are currently supported in Test Mode.
Where do I do this?
Within Connect or PureSMS, open “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 or PureSMS, 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 or PureSMS, open “Settings” and then “API Keys”. You can then click “Create 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.dev/connect package from npm:
npm install @divergent.dev/connectSend your first SMS
Section titled “Send your first SMS”import { ConnectClient } from '@divergent.dev/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!" }'