Skip to main content

Error Handling Library

Every error the Dripcel API returns, with its HTTP status, error.code and error.message, and how to fix the common ones.

What an error looks like​

An unsuccessful request gets a 4xx or 5xx status and a JSON body with ok: false and an error field. Depending on where the request failed, error takes one of three shapes:

ShapeExampleReturned for
A string"Campaign not found"Most errors. There is no error.code: use the HTTP status and the message.
An object{ "code": "rate_limit_exceeded", "message": "Rate limit exceeded", ... }Rate limits, API key access, sales, exchange transactions and call outcomes. Most have a message, some extra fields.
A validation issue{ "code": "invalid_enum_value", "path": ["country"], "message": "...", ... }A request body that doesn't match the endpoint's fields. See Validation errors.

In the tables on this page, — in the error.code column means error is a plain string, and "none" means error is an object without that field. <id> and similar stand for a value from your request.

Handle all three shapes:

const response = await fetch("https://api.dripcel.com/send/sms", {
method: "POST",
headers: {
Authorization: "Bearer <key>",
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});

const body = await response.json();

if (!body.ok) {
const { error } = body;

// A string error has no code
const code = typeof error === "string" ? undefined : error.code;
const message =
typeof error === "string" ? error : error.message ?? JSON.stringify(error);

console.error(response.status, code, message);
}
Match on the status and the code

Many messages include the ID or field involved, like Campaign not found: 64f1c0..., so they differ between requests. Branch on the HTTP status and error.code, and log or show the message.

Two responses are not JSON:

  • A path that doesn't exist returns 404 with an empty body. Check the method and the path.
  • An unexpected failure on our side returns 500 with the plain-text body Internal Server Error.

HTTP status codes​

StatusMeaning
400 Bad RequestThe request is invalid: a field is missing, has the wrong type or a value that isn't allowed, or the request can't be carried out as asked. A few endpoints also use 400 for "not found" and for failures on our side. They are listed below.
401 UnauthorizedThe API key is missing or wrong.
402 Payment RequiredNot enough credit for this request.
403 ForbiddenThe API key may not do this: it lacks a permission or access to the resource, or your organisation or tier doesn't allow it.
404 Not FoundThe campaign, contact, tag, template or offer doesn't exist in your organisation, or the path doesn't exist.
409 ConflictYou already submitted this.
429 Too Many RequestsYou hit the rate limit, your tier's contact limit, or an exchange offer's cap. Check error before retrying.
500 Internal Server ErrorSomething failed on our side. Retry later, and contact support if it continues.

A request is checked in this order, and the first failure is returned:

  1. The API key: 401 or 403
  2. The rate limit: 429
  3. The request body is JSON: 400
  4. The body's fields: 400
  5. The endpoint's own checks: errors by endpoint

Errors on every endpoint​

Authentication and permissions​

Statuserror.codeerror.messageWhat to do
401—No Authorization header providedSend your key in the Authorization header as Bearer <key>.
401—Invalid Authorization scheme. Must be 'Bearer'Start the header value with Bearer .
401—No token providedPut your key after Bearer .
401—No key providedGET /sales/create and GET /exchange/buyer/transaction/create take the key as a key query parameter.
401—API Key must be provided in either the Authorization header as a Bearer token, or as a query param (key={key})Send the key in the header, or as a key query parameter.
401—Invalid keyThe key doesn't exist, or was deleted. Generate one on the API keys page.
403—Organisation blockedThis API key is blocked. Contact support.
403—Insufficient permissions. Must have the '<permission>' permission(s). Note: Permission changes can take up to 3 minutes to take effect.Give the key the permission(s) named, on the API keys page.
403insufficient_resource_idsnoneThe key is limited to certain campaigns, tags or contact fields. Use one it can access, or widen its access. missing lists the rest.

An insufficient_resource_ids error lists, for each kind of resource, the IDs the key can't access. "all" means the request needs every one of that kind.

403
{
"ok": false,
"error": {
"code": "insufficient_resource_ids",
"missing": {
"campaign_ids": ["64f1c0e5a2b3c4d5e6f7a8b9"]
}
}
}
note

A few endpoints spell this code Insufficient resource IDs: opting a contact out, adding or removing a contact's tags, and searching contacts. They are listed under errors by endpoint.

Rate limit​

Statuserror.codeerror.messageWhat to do
429rate_limit_exceededRate limit exceededWait until resetsAt, or for the number of seconds in Retry-After.
429
{
"ok": false,
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded",
"resetsAt": 1763550000000,
"remaining": 0
}
}
  • resetsAt: when the limit resets, as a Unix timestamp in milliseconds.
  • remaining: what's left until then. Some endpoints count as more than one request, so this can be above 0.
  • The Retry-After response header gives the seconds until the limit resets. It may have a fraction.

POST /contacts/call-outcomes has its own limit, separate from the rest of the API.

Request body​

Endpoints that take a JSON body return these before checking its fields:

Statuserror.codeerror.messageWhat to do
400—No bodySend a JSON body.
400—Body must be JSONSet the Content-Type: application/json header.
400—Invalid JSONThe body isn't valid JSON. Check for trailing commas and quotes.

Server errors​

Statuserror.codeerror.messageWhat to do
500—Internal Server Error (plain text, not JSON)Retry later. Contact support if it continues.
500—Organisation not foundYour key isn't linked to an organisation. Contact support.
500—No org_id on apiKeyYour key isn't linked to an organisation. Contact support.

Validation errors​

When the JSON body doesn't match the endpoint's fields, the status is 400 and error describes the first problem found. Fix it and send the request again to find any others.

For example, POST /send/sms with "country": "za" returns:

400
{
"ok": false,
"error": {
"received": "za",
"code": "invalid_enum_value",
"options": ["ZA", "NA", "GB", "AU", "IE", "IT", "US"],
"path": ["country"],
"message": "Invalid enum value. Expected 'ZA' | 'NA' | 'GB' | 'AU' | 'IE' | 'IT' | 'US', received 'za'"
}
}

Every validation issue has:

FieldDescription
codeThe kind of problem. See the table below.
pathWhere in the body, as a list of field names and array indexes. ["contacts", 2, "cell"] is the cell of the third contact. Empty for the body itself.
messageWhat's wrong, in words.

Other fields depend on the code:

codeMeaningExtra fieldsExample error.message
invalid_typeA required field is missing, or has the wrong typeexpected, receivedRequired, Expected boolean, received string
invalid_enum_valueThe value isn't one of the allowed values. Values are case-sensitive.options (the allowed values), receivedSee the example above
invalid_union_discriminatorA kind field isn't one of the allowed kindsoptionsInvalid discriminator value. Expected 'manual' ...
invalid_literalThe field must be one exact valueexpected, receivedInvalid literal value, expected "manual"
invalid_stringA string isn't in the required format, like an ID or an email addressvalidation (e.g. regex, email)Invalid email
too_smallToo short, too few items, or below the minimumminimum, type, inclusive, exactContent cannot be empty
too_bigToo long, too many items, or above the maximummaximum, type, inclusive, exactArray must contain at most 1000 element(s)
invalid_dateNot a valid datenoneInvalid date
invalid_unionMatches none of the accepted formsunionErrors (why each form failed)Invalid input
unrecognized_keysA field the endpoint doesn't acceptkeysUnrecognized key(s) in object: 'foo'
customA rule specific to the endpointnoneMust specify at least one filter in 'find'

An ID that isn't valid fails with invalid_string and the message Invalid ObjectId. Must be a 24-character hex string. Ensure you're using the resource_id and not the resource_name.

These are Zod validation issues. Zod's reference lists the rarer codes.

Where validation errors differ​

  • POST /contacts/search and POST /contacts/update return every problem at once. error is { "issues": [...], "name": "ZodError" }, and each item in issues is a validation issue as above.
  • Query string and URL path parameters come back as a string: the message, then at and the parameter. For example, Invalid date at from. When a parameter has a list of allowed values, they follow the message: ... (options: Zapier, DripCrm).
  • GET /sales/create and GET /exchange/buyer/transaction/create return only the message, as a string.
  • POST /contacts/call-outcomes returns invalid_call_outcome, with the path and message joined: 3.cell: Invalid cell number....
  • POST /exchange/seller/lead returns a problem with the contact as invalid_lead, or invalid_msisdn for its cell.
  • POST /contacts and PUT /contacts don't fail on a contact that isn't valid. It comes back in invalidContacts with its row and issue, and the rest are uploaded.

Errors by endpoint​

These are the errors each endpoint adds to the errors on every endpoint and validation errors, grouped as in the API reference.

Balance​

GET /balance returns only the errors on every endpoint.

Call outcomes​

POST /contacts/call-outcomes

Statuserror.codeerror.messageWhat to do
400invalid_call_outcome<path>: <reason>, e.g. 3.cell: Invalid cell number...Fix the field named. Nothing in the request was recorded.
403—Insufficient permissions. Must have the 'contact.create' permission to use create_missing_contact. ...Give the key contact.create, or stop sending create_missing_contact.
429—Too many contacts. Count after upload: ... Max allowed by tier: ...Creating the missing contacts would pass your tier's contact limit. Nothing was recorded; send without create_missing_contact.
500—Could not record the call outcomesRetry: nothing was recorded.

Campaigns​

GET /campaigns and GET /campaigns/v2

Statuserror.codeerror.messageWhat to do
400—Invalid enum value. Expected ..., received '...' (options: Zapier, DripCrm)Leave out format, or use one of the options.

GET /campaigns/:campaign_id and GET /campaigns/v2/:campaign_id

Statuserror.codeerror.message
400—Invalid ObjectId. Must be a 24-character hex string. ... at campaign_id
403insufficient_resource_idsnone
404—Campaign not found

Compliance​

POST /compliance/send

Statuserror.codeerror.messageWhat to do
400—Invalid ObjectId. ... at campaign_idCheck the campaign_id query parameter.
400—Invalid cell (row 3, 1-based). ...Fix that cell number. The details follow the row number.
402—Insufficient balanceBuy more credits.
404—Organisation not foundContact support.

Contacts​

GET /contacts/:cell

Statuserror.codeerror.messageWhat to do
400—Invalid cell number. Must be a valid number in international (MSISDN) format. at cellUse the international (MSISDN) format.
403insufficient_resource_idsnoneThe key needs access to every contact field.
404—Contact not found

POST /contacts/search

Statuserror.codeerror.messageWhat to do
400nonenoneValidation failed. error is { "issues": [...], "name": "ZodError" }.
400—An error occuredThe search failed or took longer than 30 seconds. Narrow it down.
402Insufficient balanceInsufficient balance. Atleast 10 credits required.Each search costs 10 credits. Buy more credits.
403Insufficient resource IDsYour API Key does not have access to ...resource_ids.missing lists what the key can't read, and resource_ids.has what it can. Narrow your projection or filter to those.
404Organisation not foundnoneContact support.
500Internal server errornoneRetry later.

DELETE /contacts/:cell

Statuserror.codeerror.message
400—Invalid cell number. Must be a valid number in international (MSISDN) format. at cell

Deleting a contact that doesn't exist is not an error: deletedCount is 0.

POST /contacts/:cell/optOut

Statuserror.codeerror.message
400—Invalid cell number. Must be a valid number in international (MSISDN) format. at cell
400—Invalid campaign_ids: <ids>
400—Must provider either campaign_ids or set 'all' flag to true
403Insufficient resource IDsnone. missing lists the campaigns the key can't access.
403Action not allowed on current tierContact deduping is not enabled on your current tier

PUT /contacts/:cell/optOut

Statuserror.codeerror.message
400—Invalid cell number. Must be a valid number in international (MSISDN) format. at cell
400—Invalid campaign_id
400—Must provider either campaign_id or set 'all' flag to true
403Insufficient resource IDsnone. missing lists the campaigns the key can't access.
403Action not allowed on current tierContact deduping is not enabled on your current tier

PUT /contacts/:cell/tag/add and PUT /contacts/:cell/tag/remove

Statuserror.codeerror.messageWhat to do
400—Invalid cell number. Must be a valid number in international (MSISDN) format. at cell
400—No tags to addNo tags were sent, or none of them exist. Also when removing.
403Insufficient resource IDsnone. missing lists the tags the key can't access.

POST /contacts and PUT /contacts

Statuserror.codeerror.messageWhat to do
400—Welcome send campaign not foundCheck send.campaign_id.
400—Welcome send template is not one of the campaign's templatesUse one of the campaign's templates.
404—Org not foundContact support.
429—Too many contacts. Count after upload: ... Max allowed by tier: ...This is your tier's contact limit, not the rate limit, so retrying won't help. Delete contacts, or upgrade.
500—Internal Server ErrorRetry later.

POST /contacts/update

Statuserror.codeerror.messageWhat to do
400nonenoneValidation failed. error is { "issues": [...], "name": "ZodError" }. Besides field problems, the custom issues are Must specify at least one filter in 'find', Must specify at least one update in 'update' and Cannot add and remove tag_ids in the same request.
400—An error occuredThe update failed or took longer than 60 seconds. Narrow find.
403insufficient_permissionsnonerequired lists the permissions this update needs.
403insufficient_resource_idsnonemissing lists the tags or campaigns the key can't access.
500—Internal Server ErrorRetry later.

Deliveries​

GET /deliveries

Statuserror.codeerror.message
400—A query parameter isn't valid, e.g. Invalid date at from or Number must be less than or equal to 1000 at limit
400—From date cannot be later than to date

Email templates​

GET /email/templates

Statuserror.codeerror.message
500—Internal error

Exchange transactions​

POST /exchange/buyer/transaction and GET /exchange/buyer/transaction/create

Statuserror.codeerror.message
400invalid_msisdnInvalid cell number: <cell>
404campaign_not_foundNo matching marketplace offer for: <resource_ids>, Campaign not found: <id>, Campaign(s) not found: <ids>, No matching Campaigns found for these Send IDs: <ids> or No matching Campaigns found for these Click IDs: <ids>
500internal_server_errorFailed to create one or more lead transactions

POST /exchange/buyer/transaction/search

Statuserror.codeerror.message
400—Cannot use afterId together with _id
400internal_server_errorSomething went wrong

PUT /exchange/buyer/transaction/:id/status

Statuserror.codeerror.message
400transaction_not_foundTransaction not found: <id>
400transaction_invalid_kindTransaction kind does not match expected: <id>
400transaction_errorBuyer Org ID does not match transaction Buyer Org ID: <id>
400transaction_errorOnly "pending" transactions (or re-approving a "rejected" one) can be updated
400org_not_foundOrganization not found: <id>
400internal_server_errorFailed to update transaction status.

POST /exchange/seller/lead

Statuserror.codeerror.message
400invalid_leadcontact.<field>: <reason>, or contact is missing field(s) this offer requires: <fields>
400invalid_msisdncontact.cell: <reason>
400offer_not_per_leadThis offer pays per <kind>, not per lead
402offer_buyer_insufficient_balanceThe offer's buyer has insufficient balance
403insufficient_resource_idsnone. missing lists the campaigns the key can't access.
403org_blockedOrganisation blocked
403org_not_verifiedYour organisation is not verified yet
403offer_api_leads_disabledThis offer does not accept leads via the API
403offer_inactiveMarketplace offer is inactive
403offer_pausedMarketplace offer is paused by its schedule: <reason>
403offer_permission_deniedYour organisation may not run this offer
404org_not_foundOrganisation not found
404campaign_not_foundNo exchange campaign found: <campaign_id>
404offer_not_foundMarketplace offer not found: <offer_id>
409duplicate_resourceA lead with resource_id "<resource_id>" was already submitted
429offer_cappedMarketplace offer cap reached
500internal_server_errorCould not check the offer's caps, Failed to check the lead or Failed to create the lead transaction

See Submit a Lead for what to do about each.

Replies​

POST /replies/search

Statuserror.codeerror.message
400internal_server_errorSomething went wrong

Sales​

POST /sales and GET /sales/create

Statuserror.codeerror.message
400invalid_msisdnInvalid cell number: <cell>
404campaign_not_foundCampaign not found: <id>, Campaign(s) not found: <ids>, No matching Campaigns found for these Send IDs: <ids> or No matching Campaigns found for these Click IDs: <ids>
500internal_server_errorInternal server error

A duplicate sale is not an error. It is skipped, and the request still succeeds.

Send​

POST /send/sms

Statuserror.codeerror.messageWhat to do
400invalid_enum_valueInvalid enum value. Expected ..., received '...'country or deliveryMethod isn't one of the options. Values are case-sensitive.
400too_smallContent cannot be emptySend some content.
400—Invalid ZA cell number.cell isn't a valid number for the country.
400—Invalid country/deliveryMethod. ZA does not offer transactional delivery method.Use a delivery method the country offers.
400Action not allowed on current tierReverse-billed messaging is not allowed on your current org tierUse another deliveryMethod, or upgrade.
400—Marketplace offer cap exceededExchange campaigns only. Stop sending until the cap resets.
400—Marketplace buyer has insufficient balanceExchange campaigns only. Try again later.
400—Marketplace offer is paused by its schedule: <reason>Exchange campaigns only. Send when the offer's schedule allows.
note

POST /send/sms answers before the SMS is sent. Problems found while sending, like an insufficient balance, an unverified organisation or spam, aren't in the response. If an SMS doesn't appear in your send logs, check those first.

POST /send/email

Statuserror.codeerror.messageWhat to do
404—Campaign not found (campaign_id:<id>)Check campaign_id.
400—Org not verifiedGet verified.
400—Org blockedContact support.
400—Org not foundContact support.
400—Insufficient balanceBuy more credits.
400—campaign is not activeActivate the campaign.
400—No template found (template_id:<id>)Use one of your email templates.
400—No email templates on campaign (campaign_id:<id>)Add an email template to the campaign.
400—no best template foundUse another template.kind until the campaign has enough sends.
400—No contacts found (campaign_id:<id>)No contact in your org has this email address. Upload them first.
400—No contacts to send toAs above.
400—Your org has reached its daily email limit. It resets at midnight.Send again after midnight.
400—Email send failed: <reason> or Email send failedCheck the from address is a verified email identity, then retry.
400—Marketplace offer not found (offer_id:<id>)Exchange campaigns only.
400—marketplace offer is not activeExchange campaigns only.
400—marketplace offer is paused by its schedule: <reason>Exchange campaigns only.
400—marketplace buyer has insufficient balanceExchange campaigns only.
400—Marketplace permission denied (offer_id:<id>)Exchange campaigns only.

POST /send/email/bulk returns only the errors on every endpoint and validation errors. The emails are queued, so problems sending them aren't in the response.

Send logs​

GET /send-logs/:send_id

Statuserror.codeerror.message
400—Invalid ObjectId. ... at send_id
400resource_not_foundNo send logs found for send_id: <send_id>

POST /send-logs/search returns only the errors on every endpoint and validation errors.

Tags​

GET /tags

Statuserror.codeerror.message
400—Invalid enum value. Expected ..., received '...' (options: Zapier, DripCrm)

GET /tags/:tag_id and DELETE /tags/:tag_id

Statuserror.codeerror.message
400—Invalid ObjectId. ... at tag_id (GET only)
403insufficient_resource_idsnone
404—Tag not found

Messages in the Dripcel app​

Errors you may see when sending from the Dripcel app, and how to fix them.

Insufficient balance​

You do not have enough credits to send the SMS. Please purchase more credits or reduce the number of contacts.

Your organisation is not verified yet. Our team will be in touch soon​

Please contact us if your organisation is not verified.

Insufficient permissions​

You do not have the relevant permissions to perform the action. Please contact your administrator for permissions.

Campaign not found​

The campaign you are trying to access cannot be found. The campaign has been removed.

Campaign inactive​

Please activate the campaign in the campaign settings.

No contacts match the campaign's distribution criteria​

There are not enough contacts available in the reachability window, tags and/or segments that you have selected.

No content found. Please add content, or change the Selection method on the campaign​

Please add content to your SMS content or change the Selection method. You can choose best maximise performance, first content, random copy or least sent content.

Spam detected. Please contact support​

Spam was detected in your SMS content. Please contact us.

No best time with enough sends​

Please send more using the "random time" feature so Dripcel can analyse your data and recommend a best time.

No start/end hours for random time​

Please add a start and end time for random time.