Skip to main content

Quick Start

Send your first message in a few minutes, with a campaign: the way every new integration sends SMS, RCS and WhatsApp messages. This page sends one SMS to your own phone.

Prerequisites​

  • An active Qlara account, with enough credit for one SMS
  • An API key (from the settings section of the platform) whose operations include CAMPAIGNS and SMS
  • An SMS sender registered in the platform and approved

All the calls below go to https://api.qlara.ai/api/partner-gateway, with the key in the X-Api-Key header.

1. Find your sender​

A campaign can send only from an approved sender of your account. List yours:

curl "https://api.qlara.ai/api/partner-gateway/sms/senders" \
-H "X-Api-Key: YOUR_API_KEY"
{
"data": [
{ "sender": "MyCompany", "status": "APPROVED" },
{ "sender": "MyShop", "status": "PENDING" }
],
"totalCount": 2
}

The example shows only the fields you need. Pick a sender whose status is APPROVED and copy it exactly as listed: any other sender is refused with 403.

2. Create the campaign​

destinationType: 1 sends to the phone numbers written in destinations, in international format, without creating contacts. Put your own number there.

curl -X POST "https://api.qlara.ai/api/partner-gateway/campaigns" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My first campaign",
"sendingMode": "SMS",
"destinationType": 1,
"destinations": ["+393401234567"],
"smsSender": "MyCompany",
"smsBody": "Hello! This is my first message from Qlara.",
"readyToSend": true
}'

The API answers 201 Created with the campaign as stored. Keep its id:

{
"id": 1542,
"name": "My first campaign",
"status": "DRAFT",
"sendingMode": "SMS",
"destinationType": 1,
"destinations": ["+393401234567"],
"smsSender": "MyCompany",
"smsBody": "Hello! This is my first message from Qlara.",
"readyToSend": true
}

Nothing is sent and no credit is used yet: a campaign leaves only when you confirm it. Until then you can change it with PUT /campaigns/{id} and see what it costs with GET /campaigns/{id}/price.

3. Confirm it​

curl -X PUT "https://api.qlara.ai/api/partner-gateway/campaigns/1542/confirm" \
-H "X-Api-Key: YOUR_API_KEY"

The request has no body. 202 Accepted, with no body either, means the price was reserved on your credit and the sending is queued: with no scheduledDate, it starts at once. From now on the campaign can no longer be changed.

After a timeout, check before you retry

A campaign that is already confirmed answers 400 to a second confirmation. If the first answer got lost, read the campaign (step 4) before confirming again.

4. Read the result​

curl "https://api.qlara.ai/api/partner-gateway/campaigns/1542" \
-H "X-Api-Key: YOUR_API_KEY"
{
"id": 1542,
"name": "My first campaign",
"status": "ENDED",
"sendingMode": "SMS",
"totalDestinations": 1,
"totalSent": 1,
"totalSuccess": 1,
"totalFailed": 0,
"smsSent": 1,
"smsSuccess": 1,
"smsFailed": 0
}

After confirmation status is PRE_BILLED, and it reaches ENDED once every message has been processed. The counters fill in meanwhile: totalSuccess counts the delivered messages. Webhooks do not report the delivery of campaign messages: read it here, or export the outcome of every message (see UC-002).

The whole flow in your language​

const BASE = "https://api.qlara.ai/api/partner-gateway";
const headers = {
"X-Api-Key": process.env.QLARA_API_KEY,
"Content-Type": "application/json",
};

// 1. Create the campaign
const created = await fetch(`${BASE}/campaigns`, {
method: "POST",
headers,
body: JSON.stringify({
name: "My first campaign",
sendingMode: "SMS",
destinationType: 1,
destinations: ["+393401234567"],
smsSender: "MyCompany",
smsBody: "Hello! This is my first message from Qlara.",
readyToSend: true,
}),
});
if (created.status !== 201) throw new Error(`Create failed: ${created.status}`);
const { id } = await created.json();

// 2. Confirm it: 202 means the sending is queued
const confirmed = await fetch(`${BASE}/campaigns/${id}/confirm`, {
method: "PUT",
headers,
});
if (confirmed.status !== 202) throw new Error(`Confirm failed: ${confirmed.status}`);

// 3. Read the result
const campaign = await (await fetch(`${BASE}/campaigns/${id}`, { headers })).json();
console.log(campaign.status, campaign.totalSuccess, campaign.totalFailed);

If something goes wrong​

AnswerWhereWhat it means
401Any callThe API key is missing or wrong, or its operations do not include CAMPAIGNS (or SMS, for the sender list)
403CreatesmsSender is not an approved sender of your account
400CreateA required field is missing, or sendingMode is not a valid value: the body names the field
400ConfirmThe campaign has no valid recipient, your credit does not cover its price, or it is already confirmed

Next steps​