SDK & Widget · Mobile

Errors

How the SDK endpoints, the socket and the React Native client report problems, and what to do about each one.

Every SDK endpoint answers errors with a JSON body that has "success": false and a human-readable error. Some errors add a machine-readable code; branch on that when it is present, and on the HTTP status otherwise.

json
{
  "success": false,
  "error": "Human-readable message",
  "code": "TOKEN_EXPIRED"
}

HTTP errors

StatusTypical errorWhat to do
400name is requiredidentify: send a name.
400text or mediaUrl is requiredmessages: send text, a media URL, or both.
400token is required · platform must be "ios" or "android"device-token: fix the body.
401API key required. Pass it in X-API-Key header.init: add the X-API-Key header.
401Invalid or inactive API key · API key has expiredCreate a new key in the Developer Hub.
401SDK session token required…Send Authorization: Bearer <sessionToken>.
401code TOKEN_EXPIREDCall /sdk/init again (same userId), then retry.
401Invalid session token.The token is malformed or from another environment. Re-init.
403Missing permission: widgetUse a key that has the widget permission.
403code FEATURE_LOCKEDYour plan does not include the feature. The body also has feature, currentTier and requiredPlan.
404Chat not found · Workspace not foundThe chatId does not belong to this visitor, or the workspace is unavailable.
429Rate limit exceeded. Max 60 requests per minute.Wait for Retry-After seconds. Call init once per launch, not per message.
500Failed to …Retry with backoff. If it persists, contact support with the time and endpoint.

Handling an expired session

javascript
async function sdkFetch(path, options = {}) {
  let res = await call(path, options);
  if (res.status === 401) {
    const body = await res.clone().json().catch(() => ({}));
    if (body.code === 'TOKEN_EXPIRED') {
      await initSession();            // POST /sdk/init with the same userId
      res = await call(path, options); // retry once with the new token
    }
  }
  return res;
}

Socket errors

The socket reports problems with a widget_error event: { code, message }.

codeMeaningWhat to do
JOIN_FAILEDThe join could not be processed.Retry widget_join after a short delay.
SESSION_NOT_FOUNDA message arrived for a visitor that has not joined on this server.Emit widget_join again, then resend the message (or send it over REST).
INVALID_EMAILwidget_set_email received an invalid address.Validate the email and resend.

React Native SDK errors

The SDK throws regular Error objects; wrap calls in try / catch.

MessageCause
InboxiChat.init() requires appId and apiKeyOne of the two was empty.
Call InboxiChat.init() firstA method was called before init, or after logout.
name is required for identify()identify was called without a name.
SESSION_EXPIREDThe session token expired. Call InboxiChat.init() again and retry.
Init failed with status …init was rejected: check the key, its permissions and your plan.
The stock ChatScreen renders a short notice instead of crashing when the SDK was never initialized, so a blank chat usually means init failed. Log the error it threw.

Getting help