Numberly
Technical Details

Error handling

The NMP API uses standard HTTP response codes to indicate the success or failure of a request. In the event of failure, the response body is always formatted in JSON and provides structured details to facilitate debugging.

Error Response Structure

The error payload follows a strict structure composed of two root objects:

  • errors (Array): A list containing one or more error objects.
    • code (String): Unique error identifier, stable and machine-readable (e.g., INVALID_RECIPIENT).
    • message (String): Textual description of the problem, intended for the developer.
    • location (String, optional): Pointer to the faulty field in the request (dot notation, e.g., body.recipients.0.email).
    • input (Mixed, optional): The provided value that caused the error.
  • metadata (Object): Contextual information regarding execution.
    • timestamp (Float): Date and time of the error (UNIX timestamp).

HTTP Status Codes

The HTTP code indicates the general category of the error.

CodeMeaningDescriptionRecommended Action
400Bad RequestRequest syntax is invalid (e.g., malformed JSON).Check your JSON syntax.
401UnauthorizedAuthentication failed.Check the presence and validity of your Bearer Token.
403ForbiddenAuthenticated, but insufficient rights.Check account or token permissions.
404Not FoundThe targeted resource is missing.Check the resource ID in the URL.
409ConflictState conflict (e.g., creating a duplicate).Check if the resource already exists.
413Payload Too LargeRequest exceeds size limit.Reduce payload or attachment size.
422Unprocessable EntitySemantic validation error.Correct fields indicated in errors.
429Rate Limit ErrorRequest quota exceeded.Implement an Exponential Backoff.
500Server ErrorUnexpected internal error.Contact support with the timestamp.

Application Error Codes (code)

The code field within the errors object allows for programmatic error handling.

Code (code)Probable CauseResolution Path
VALIDATION_ERRORMissing data or incorrect type.Consult the endpoint schema documentation.
AUTHENTICATION_ERRORToken missing, expired, or badly signed.Renew your access token.
INVALID_PERMISSIONSAttempt to access outside of scope.Check scopes associated with your token.
INVALID_CONTENTInvalid HTML or forbidden tags.Validate your HTML code or check encoding.
INVALID_METADATAUnsupported metadata keys.Respect the expected key/value structure.
INVALID_ATTACHMENTFile too large or forbidden extension.Check size limits and MIME types.
INVALID_RECIPIENTMalformed email/phone or blacklisted.Check contact format (Regex).
INTERNAL_SERVER_ERRORPlatform-side bug.Retry later or contact support.

Response Example (422 Error)

The example below illustrates a validation error where a recipient's email address is formatted incorrectly. Note the use of the location field to identify the precise index within an array.

{
  "errors": [
    {
      "code": "INVALID_RECIPIENT",
      "message": "The recipient email format is invalid.",
      "location": "body.to.0.email",
      "input": "jean.dupont@"
    }
  ],
  "metadata": {
    "timestamp": 1742294105.0
  }
}