Billing
Sending is paid for from your organization's credit balance: you top up first, and what you send is taken from the balance. Money in the API is in integer micros, where 1,000,000 micros is one unit of your organization's currency, so 55000 is €0.055. Your organization has one currency.
Check your balance
GET / answers with balanceMicros and currency. The API key needs billing:read:
curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/billing/balance" \
-H "Authorization: Bearer $CODELIA_API_KEY"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/billing/balance`,
{
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));It's the only billing call an API key can make, apart from the cost figures in Usage. Top-ups, auto top-up, invoices, your cards and your transaction history are in the portal, on the Billing screen.
Top up
Top up in the portal, by card, from €10 to €10,000 in whole euros. You can pay with a card you've added or enter a new one, and your bank may ask you to confirm the payment. VAT is added on top where it applies, and your balance gets the amount before VAT: a €50 top-up adds €50 of credit. We issue an invoice for every payment.
Auto top-up charges your default card when sending takes your balance below a threshold you choose, by an amount you choose (€10 to €10,000, in whole euros). Scheduled and recurring campaigns need it. If a charge fails, auto top-up pauses until you save its settings again.
What a message costs
Each country has a list price per part, before VAT, shown on the pricing page of our website. If your organization has an agreed rate for a country, that rate is used instead.
A message costs its country's price per part times its parts. A marketing message's parts include the unsubscribe line (see How messages are counted). Every message has its price in priceMicros.
To see what sending would cost before you send, price it first: a message or a campaign. That gives an estimated cost: when you send, the price is worked out again, and that's what you're charged.
When you're charged
- Messages and campaigns are charged when they're accepted, the whole amount at once.
- A scheduled campaign is charged when it sends, at that day's prices, not when you schedule it.
- A campaign sent now to more than 500 people is charged when it's accepted, shortly after you send it, not when the request is answered. See Large campaigns.
If your balance can't cover what you send, the request is refused with 402 and insufficient_, and nothing is sent. Sending never takes your balance below zero. If auto top-up is on, the refusal starts a top-up, but the request isn't tried again: once the credit is in, send again with a new Idempotency-Key.
A large campaign sent now is refused that way only when your balance is at or below zero and auto top-up can't add to it. Otherwise a shortfall found once it's accepted charges auto top-up once and waits about 10 minutes for the credit. If it hasn't arrived by then, the campaign becomes failed, with failureReason: "insufficient_, and nothing is charged.
Refunds
Your balance gets the money back for:
- a number that opted out, which is never charged when you send to it, and is refunded in a campaign if they opt out after it was accepted;
- messages the network refused to take, answered with
provider_;unavailable - messages of a campaign you canceled that hadn't gone out yet.
A message that was handed to the network keeps its charge, even if it's undelivered, failed or rejected later.
Usage
GET / counts the messages your organization sent and what happened to them, with usage:read:
curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/usage/summary?days=7" \
-H "Authorization: Bearer $CODELIA_API_KEY"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/usage/summary?days=7`,
{
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));totalscoverstoday,monthToDate,previousMonthandrange, the lastdaysdays. Each counts messagessent,delivered,notDelivered,notSentandpending.dailyhas one entry per day,byStatuscounts each status, andbyCountrylists up to 10 destination countries, most messages first. All three cover the lastdaysdays, today included.daysis from 1 to 90, and 30 if you leave it out. Days and months are in UTC.- What sending cost,
spendMicrosandfailedSpendMicros, isnullunless the API key also holdsbilling:read.
Activity
GET / lists what your organization's members, their connected apps and your API keys did, newest first, with activity:read:
curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/activity?limit=20" \
-H "Authorization: Bearer $CODELIA_API_KEY"const response = await fetch(
`https://api.sms.codelia.studio/v1/organizations/${process.env.CODELIA_ACCOUNT_ID}/activity?limit=20`,
{
headers: {
Authorization: `Bearer ${process.env.CODELIA_API_KEY}`,
},
},
);
console.log(response.status);
console.log(JSON.stringify(await response.json(), null, 2));- Each entry has its
action, likemessage.sent; who acted, inactorType(user,api-key,connected-apporsystem) andactorName; what it acted on, intargetTypeandtargetId; andcreatedAt. actionnarrows the list by the start of the action, so?action=contactlists everything done to contacts.fromandtonarrow it by date.limitis up to 100, and 50 if you leave it out. It pages by cursor: see Paging through results.- The entry for a message you sent says how many people it was for and its
type, never its text or what it cost.
The API reference lists every field of both answers.