New: every plan now includes free incoming texts and rollover credits. See pricing →
Search Help Center Documentation

Guide

Errors

A failed request gets an HTTP status and a JSON body with a stable code you can branch on.

The error body#

Every error has the same shape. code is stable and safe to branch on; message is plain English you can show to a person; details carries extra facts for some codes.

Response ยท 402
{
  "error": {
    "code": "insufficient_credits",
    "message": "This send needs 1,290 credits and you have 850.",
    "details": {
      "needed": 1290,
      "available": 850,
      "recipients": 1284
    },
    "requestId": "req_8Fk2LqZ9xW1v"
  }
}
errorobjectrequired
Child fields
codestringrequired

A stable, machine-readable code such as invalid_phone or insufficient_credits. Each operation lists the codes it can return.

messagestringrequired

A plain-English explanation, safe to show to a person.

detailsobject

Extra facts for some errors, such as needed and available credits for insufficient_credits.

Any keys.

requestIdstringrequired

The id of this request, the same as the X-Request-Id header. Quote it when you contact support.

Status codes#

StatusMeaningWhat to do
400 Bad requestSomething in the request is not valid.Fix the request. Sending it again unchanged gets the same answer.
401 UnauthorizedNo API key, or one that is wrong or revoked.Check the key, or create a new one.
402 Payment requiredSending is blocked: not enough credits, or the trial or plan has ended.Add credits or choose a plan in the dashboard.
404 Not foundSomething named in the path or body is not in your account.Check the id.
409 ConflictThe request clashes with how things are now: an opted-out contact, a campaign already sent, a request with the same Idempotency-Key still running.Read the code. Most need a change on your side; idempotency_in_progress just needs a moment.
413 Payload too largeThe body is larger than the endpoint accepts.Send fewer rows at a time.
422 UnprocessableAn Idempotency-Key was already used for a different request.Use a new key for each new request.
429 Too many requestsOver the rate limit.Wait for the seconds in Retry-After, then retry.
500 Server errorSomething went wrong on our side.Retry with backoff. With the same Idempotency-Key a POST is safe to retry.

Each endpoint in the reference lists the exact codes it can return under each status.

Request ids#

Every answer, success or error, has an X-Request-Id header (req_...). Errors repeat it as error.requestId. Log it with failures and quote it when you contact support: it lets us find the request.

Handling errors in code#

  • Branch on error.code, never on message: messages can be reworded.
  • Retry only what can succeed later: 429 (after Retry-After), 5xx, network failures and idempotency_in_progress. Other errors need a change first.
  • Retry POSTs with the same Idempotency-Key, so a retry never does the work twice.
const res = await fetch('https://app.smsblast.net/v1/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ to: '+14155550101', body: 'Your order is ready.' }),
});

if (!res.ok) {
  const { error } = await res.json();
  switch (error.code) {
    case 'unsubscribed':
      // they opted out: stop texting them from your system too
      break;
    case 'insufficient_credits':
      console.warn(`Need ${error.details.needed} credits, have ${error.details.available}`);
      break;
    default:
      console.error(`${res.status} ${error.code}: ${error.message} (${error.requestId})`);
  }
}
import os
import uuid

import requests

res = requests.post(
    "https://app.smsblast.net/v1/messages",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"to": "+14155550101", "body": "Your order is ready."},
)

if not res.ok:
    error = res.json()["error"]
    if error["code"] == "unsubscribed":
        pass  # they opted out: stop texting them from your system too
    elif error["code"] == "insufficient_credits":
        print(f"Need {error['details']['needed']} credits, have {error['details']['available']}")
    else:
        print(f"{res.status_code} {error['code']}: {error['message']} ({error['requestId']})")

Every error code#

All 66 codes the API can return, from the reference. The meaning shown is from the first endpoint that lists it; follow the links for the exact wording.

CodeStatusMeaningReturned by
batch_too_large400More than 5,000 rows.Send a batch of rows
body_too_long400body is longer than 1,600 characters.
5 endpointsSend a text, Create a campaign draft, Update a campaign draft, Text someone from the inbox, Reply in a conversation
consent_required400consent.attested is not true.Add a contact, Import contacts, Start an import job
empty_body400body is missing or empty. (wording varies by endpoint)
6 endpointsSend a text, Create a campaign draft, Send a test text, Update a campaign draft, Text someone from the inbox, Reply in a conversation
empty_reply400reply is missing or empty.Set up a keyword
invalid_action400action is not one of the four.Act on many contacts
invalid_consent400consentText does not mention STOP.Create a signup form, Update a signup form
invalid_cursor400cursor is not one this API gave out.List texts
invalid_date400since or until is not a date.List texts
invalid_direction400direction is not inbound or outbound.List texts
invalid_email400email does not look like an email address.Sign up with a form (public)
invalid_events400events is empty or has an unknown type (details.allowed lists them). (wording varies by endpoint)Create a webhook, Update a webhook
invalid_fields400fields is not a list, or names an unknown field.Create a signup form, Update a signup form
invalid_from400from is not one of your approved sending numbers.Send a text
invalid_idempotency_key400The Idempotency-Key header is longer than 200 characters.
28 endpointsSend a text, Preview a message, Add a contact, Import contacts, Act on many contacts, Start an import job, Send a batch of rows, Finish an import job, Create a list, Create a segment, Count a segment before saving, Create a campaign draft, Estimate a campaign, Send a test text, Duplicate a campaign, Stop a campaign, Make a campaign recurring, Send or schedule a campaign, Create a workflow, Enroll contacts in a workflow, Create a signup form, Text someone from the inbox, Reply in a conversation, Set up a keyword, Create a webhook, Rotate the signing secret, Send a test event, Send a delivery again
invalid_json400The body is not a JSON object.
32 endpointsSend a text, Preview a message, Add a contact, Update a contact, Import contacts, Act on many contacts, Start an import job, Send a batch of rows, Create a list, Rename a list, Create a segment, Count a segment before saving, Update a segment, Create a campaign draft, Estimate a campaign, Send a test text, Update a campaign draft, Make a campaign recurring, Send or schedule a campaign, Create a workflow, Update a workflow, Enroll contacts in a workflow, Create a signup form, Update a signup form, Sign up with a form (public), Text someone from the inbox, Update a conversation, Reply in a conversation, Set up a keyword, Create a webhook, Update a webhook, Update your account
invalid_keyword400word is not one word of up to 20 letters or numbers.Set up a keyword
invalid_media400A mediaUrls entry is not an https address. (wording varies by endpoint)Send a text, Create a campaign draft, Send a test text, Update a campaign draft
invalid_name400name is missing or empty. (wording varies by endpoint)
5 endpointsStart an import job, Create a list, Rename a list, Create a segment, Update a segment
invalid_phone400phone is not a valid US or Canada mobile number. (wording varies by endpoint)
6 endpointsSend a text, List texts, Add a contact, Send a test text, Sign up with a form (public), Text someone from the inbox
invalid_range400from or to is missing or not a date, from is after to, or the range is longer than 400 days.Audience growth, Campaign activity, Texts sent and received
invalid_recurrence400The schedule is not valid (the message says what to fix), or it has no dates left.Make a campaign recurring
invalid_rule400A rule has an unknown field or operator, or a missing or invalid value. The message says which. (wording varies by endpoint)Create a segment, Count a segment before saving, Update a segment
invalid_send_at400sendAt is not a date and time, or is more than a year ahead. (wording varies by endpoint)Send a text, Send or schedule a campaign
invalid_steps400A step is not valid (the message says which and why), or there are more than 30. (wording varies by endpoint)Create a workflow, Update a workflow
invalid_timezone400timezone is not one we recognise.Update a contact, Update your account
invalid_trigger400trigger is missing or not valid (an unknown type, a list that does not exist, an empty keyword, or a birthday hour outside 8 to 20). (wording varies by endpoint)Create a workflow, Update a workflow
invalid_url400url is not a full public https address (or the host cannot be found). (wording varies by endpoint)Create a webhook, Update a webhook
invalid_welcome400welcomeText does not mention STOP.Create a signup form, Update a signup form
no_audience400Neither contactIds (a list) nor audience (an object) was sent.Enroll contacts in a workflow
no_contacts400contacts is missing or empty. (wording varies by endpoint)Import contacts, Act on many contacts, Send a batch of rows
no_rules400rules is missing or empty.Create a segment, Update a segment
no_steps400enabled is true but there are no steps. (wording varies by endpoint)Create a workflow, Update a workflow, Enroll contacts in a workflow
reserved_keyword400word already means opt out, help or opt in (STOP, HELP, START, ...).Set up a keyword
too_many_contacts400More than 50,000 contacts.Import contacts
too_many_rules400More than 20 rules.Create a segment, Update a segment
unauthorized401No API key, or one that is not valid or has been revoked.
78 endpointsSend a text, List texts, Get a text, Preview a message, List incoming texts, List contacts, Add a contact, Get a contact, Update a contact, Get consent history, Import contacts, Act on many contacts, Export contacts as CSV, List import jobs, Start an import job, Get an import job, Send a batch of rows, Finish an import job, List lists, Create a list, Get a list, Rename a list, Delete a list, List segments, Create a segment, Count a segment before saving, Get a segment, Update a segment, Delete a segment, List campaigns, Create a campaign draft, Estimate a campaign, Send a test text, Get a campaign report, Update a campaign draft, Delete a campaign draft, Duplicate a campaign, Stop a campaign, Make a campaign recurring, Stop a recurring campaign, Send or schedule a campaign, List workflows, Create a workflow, Get a workflow, Update a workflow, Delete a workflow, List people in a workflow, Enroll contacts in a workflow, List signup forms, Create a signup form, Get a signup form, Update a signup form, Delete a signup form, List conversations, Text someone from the inbox, Count conversations by folder, Get a conversation, Update a conversation, Reply in a conversation, List keywords, Set up a keyword, Delete a keyword, List webhooks, Create a webhook, Get a webhook, Update a webhook, Delete a webhook, Rotate the signing secret, Send a test event, List deliveries, Send a delivery again, Get your account, Update your account, Headline numbers, Audience growth, Campaign activity, Texts sent and received, Inbox workload
insufficient_credits402Your credit balance is too low for this. error.details has needed and available. (wording varies by endpoint)
5 endpointsSend a text, Send a test text, Send or schedule a campaign, Text someone from the inbox, Reply in a conversation
plan_required402Your paid plan has ended. Choose a plan on the Billing page of the dashboard to keep sending.
5 endpointsSend a text, Send a test text, Send or schedule a campaign, Text someone from the inbox, Reply in a conversation
trial_ended402The 14-day free trial is over. Choose a plan on the Billing page of the dashboard to keep sending.
5 endpointsSend a text, Send a test text, Send or schedule a campaign, Text someone from the inbox, Reply in a conversation
form_not_found404There is no form with that public id, or it is switched off.Show a form (public), Sign up with a form (public)
no_sending_number404The number in fromNumberId does not exist.Create a campaign draft, Update a campaign draft
not_found404No campaign with that id in your account. (wording varies by endpoint)
50 endpointsGet a text, List contacts, Add a contact, Get a contact, Update a contact, Get consent history, Import contacts, Act on many contacts, Export contacts as CSV, Start an import job, Get an import job, Send a batch of rows, Finish an import job, Get a list, Rename a list, Delete a list, Get a segment, Update a segment, Delete a segment, Create a campaign draft, Estimate a campaign, Get a campaign report, Update a campaign draft, Delete a campaign draft, Duplicate a campaign, Stop a campaign, Make a campaign recurring, Stop a recurring campaign, Send or schedule a campaign, Get a workflow, Update a workflow, Delete a workflow, List people in a workflow, Enroll contacts in a workflow, Create a signup form, Get a signup form, Update a signup form, Delete a signup form, Get a conversation, Update a conversation, Reply in a conversation, Set up a keyword, Delete a keyword, Get a webhook, Update a webhook, Delete a webhook, Rotate the signing secret, Send a test event, List deliveries, Send a delivery again
already_sent409The campaign is not a draft: it was already sent, scheduled or stopped.Send or schedule a campaign
blocked409The number is blocked on SMSBlast (by SMSBlast staff, for every account) and cannot be texted.Send a text, Send a test text, Text someone from the inbox, Reply in a conversation
idempotency_in_progress409A request with the same Idempotency-Key is still running. Try again in a moment.
28 endpointsSend a text, Preview a message, Add a contact, Import contacts, Act on many contacts, Start an import job, Send a batch of rows, Finish an import job, Create a list, Create a segment, Count a segment before saving, Create a campaign draft, Estimate a campaign, Send a test text, Duplicate a campaign, Stop a campaign, Make a campaign recurring, Send or schedule a campaign, Create a workflow, Enroll contacts in a workflow, Create a signup form, Text someone from the inbox, Reply in a conversation, Set up a keyword, Create a webhook, Rotate the signing secret, Send a test event, Send a delivery again
import_finished409The import has already been finished.Send a batch of rows
keyword_in_use409This keyword starts a workflow; details.workflows names them.Delete a keyword
list_in_use409A workflow starts from this list or uses it in a step; details.workflows names them.Delete a list
no_active_number409You have no approved sending number yet. (wording varies by endpoint)Send a text, Send a test text, Text someone from the inbox, Reply in a conversation
no_recipients409Nobody subscribed is in the audience.Send or schedule a campaign
no_sending_number409You have no sending number yet.Set up a keyword
not_a_contact409The number is not one of your contacts. (wording varies by endpoint)Send a text, Text someone from the inbox, Reply in a conversation
not_a_draft409The campaign has already been sent, scheduled or stopped. (wording varies by endpoint)Update a campaign draft, Delete a campaign draft, Make a campaign recurring
not_recurring409The campaign is not recurring.Stop a recurring campaign
not_sending409The campaign is not scheduled or going out (it is a draft, a recurring campaign, already sent, or already stopped).Stop a campaign
number_not_active409The campaign's number is not approved yet (details.numberStatus says what it is), or you have no number.Send or schedule a campaign
recurring409It is a recurring campaign, which only sends on its schedule. Stop the schedule (DELETE /v1/campaigns/{id}/recurring) to send it by hand.Send or schedule a campaign
test_recipient409to is neither a teammate's own mobile number nor a subscribed contact.Send a test text
too_many_forms409You already have 50 forms.Create a signup form
too_many_webhooks409You already have 10 webhooks.Create a webhook
unsubscribed409The contact has opted out. (wording varies by endpoint)Send a text, Send a test text, Text someone from the inbox, Reply in a conversation
too_large413The body is larger than 12 MB.Start an import job, Send a batch of rows, Finish an import job
idempotency_key_reused422This Idempotency-Key was already used for a different request (another path or body) in the last 24 hours.
28 endpointsSend a text, Preview a message, Add a contact, Import contacts, Act on many contacts, Start an import job, Send a batch of rows, Finish an import job, Create a list, Create a segment, Count a segment before saving, Create a campaign draft, Estimate a campaign, Send a test text, Duplicate a campaign, Stop a campaign, Make a campaign recurring, Send or schedule a campaign, Create a workflow, Enroll contacts in a workflow, Create a signup form, Text someone from the inbox, Reply in a conversation, Set up a keyword, Create a webhook, Rotate the signing secret, Send a test event, Send a delivery again
rate_limited429Too many requests with this API key. (wording varies by endpoint)
79 endpointsSend a text, List texts, Get a text, Preview a message, List incoming texts, List contacts, Add a contact, Get a contact, Update a contact, Get consent history, Import contacts, Act on many contacts, Export contacts as CSV, List import jobs, Start an import job, Get an import job, Send a batch of rows, Finish an import job, List lists, Create a list, Get a list, Rename a list, Delete a list, List segments, Create a segment, Count a segment before saving, Get a segment, Update a segment, Delete a segment, List campaigns, Create a campaign draft, Estimate a campaign, Send a test text, Get a campaign report, Update a campaign draft, Delete a campaign draft, Duplicate a campaign, Stop a campaign, Make a campaign recurring, Stop a recurring campaign, Send or schedule a campaign, List workflows, Create a workflow, Get a workflow, Update a workflow, Delete a workflow, List people in a workflow, Enroll contacts in a workflow, List signup forms, Create a signup form, Get a signup form, Update a signup form, Delete a signup form, Sign up with a form (public), List conversations, Text someone from the inbox, Count conversations by folder, Get a conversation, Update a conversation, Reply in a conversation, List keywords, Set up a keyword, Delete a keyword, List webhooks, Create a webhook, Get a webhook, Update a webhook, Delete a webhook, Rotate the signing secret, Send a test event, List deliveries, Send a delivery again, Get your account, Update your account, Headline numbers, Audience growth, Campaign activity, Texts sent and received, Inbox workload
test_limit429You have sent 20 tests in the last 24 hours.Send a test text