Skip to main content
npayload is launching soon.
npayloadDocs
Resources

Error codes

Complete reference of npayload API error codes and HTTP status codes

All npayload API errors follow a consistent format:

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description of what went wrong.",
    "details": {}
  }
}

HTTP status codes

StatusMeaning
200Success
201Created
204No content (successful deletion)
400Bad request. Invalid parameters or payload
401Unauthorised. Missing or invalid credentials
403Forbidden. Valid credentials but insufficient permissions
404Not found. Resource does not exist
409Conflict. Resource already exists or state conflict
422Unprocessable entity. Validation error
429Too many requests. Rate limit exceeded
500Internal server error
503Service unavailable. Temporary outage

Authentication errors

CodeStatusDescription
AUTH_REQUIRED401No authentication credentials provided
AUTH_INVALID401Invalid client ID or HMAC secret
TOKEN_EXPIRED401Access token has expired; request a new one
TOKEN_INVALID401Access token is malformed or revoked
DPOP_INVALID401DPoP proof is invalid, expired, or does not match the request
DPOP_NONCE_INVALID401DPoP nonce has expired; use the nonce from the response header
SCOPE_INSUFFICIENT403Token does not have the required scope for this operation

Channel errors

CodeStatusDescription
CHANNEL_NOT_FOUND404Channel does not exist or has been archived
CHANNEL_ALREADY_EXISTS409A channel with this name already exists in the app
CHANNEL_ARCHIVED409Cannot modify an archived channel
CHANNEL_PAUSED409Cannot publish to a paused channel

Message errors

CodeStatusDescription
PAYLOAD_TOO_LARGE400Message payload exceeds 256 KB
BATCH_TOO_LARGE400Batch contains more than 100 messages
BATCH_PAYLOAD_TOO_LARGE400Total batch payload exceeds 10 MB
VALIDATION_ERROR422Payload does not match the channel's event catalogue schema
IDEMPOTENCY_CONFLICT409A message with this idempotency key already exists
MESSAGE_NOT_FOUND404Message does not exist

Subscription errors

CodeStatusDescription
SUBSCRIPTION_NOT_FOUND404Subscription does not exist
ENDPOINT_INVALID400Webhook URL is invalid, unreachable, or uses a non-HTTPS scheme
SUBSCRIPTION_ARCHIVED409Cannot modify an archived subscription
CIRCUIT_OPEN503Circuit breaker is open; endpoint is temporarily unavailable

DLQ errors

CodeStatusDescription
DLQ_ENTRY_NOT_FOUND404DLQ entry does not exist or has been purged
DLQ_REPLAY_FAILED500Failed to replay the DLQ entry

Rate limit errors

CodeStatusDescription
RATE_LIMITED429Request rate limit exceeded; check Retry-After header

Quota errors

CodeStatusDescription
QUOTA_EXCEEDED403Organisation or app quota reached (channels, subscriptions, or messages)
PLAN_LIMIT_REACHED403Current billing plan does not support this feature or limit

ASP errors

CodeStatusDescription
SESSION_NOT_FOUND404ASP session does not exist
SESSION_EXPIRED409Session TTL has elapsed
PARTICIPANT_NOT_FOUND404Agent is not a participant in this session
INVALID_PERFORMATIVE400Unknown or invalid performative type
COMMITMENT_NOT_FOUND404Commitment does not exist
COMMITMENT_ALREADY_FULFILLED409Commitment has already been fulfilled

Handling errors in code

import { NPayloadError, RateLimitError, AuthenticationError } from '@npayload/node';

try {
  await npayload.messages.publish({ channel: 'orders', payload: data });
} catch (error) {
  if (error instanceof RateLimitError) {
    // Wait for error.retryAfter seconds, then retry
  } else if (error instanceof AuthenticationError) {
    // Token expired: the SDK handles refresh automatically
  } else if (error instanceof NPayloadError) {
    console.error(`[${error.code}] ${error.message}`);
  }
}

Next steps

Was this page helpful?

On this page