API ReferenceError Codes

Error Codes

Complete list of API error codes and their meanings. All errors follow a consistent format to help you handle them programmatically.

Error Response Format

All API errors return a consistent JSON structure:

{
  "statusCode": 400,
  "code": "ERR_LIMIT_001",
  "message": "PDF generation exceeded maximum page limit",
  "timestamp": "2025-12-09T10:30:00.000Z",
  "path": "/api/attachments/generate",
  "relatedInfo": {
    "actualPages": 45,
    "maxPages": 30,
    "message": "PDF generation exceeded 30 page limit. Your PDF has 45 pages."
  }
}
FieldTypeDescription
statusCodenumberHTTP status code (400, 401, 403, 404, 429, 500)
codestringUnique error code for programmatic handling
messagestringHuman-readable error message
timestampstringISO 8601 timestamp when error occurred
pathstringAPI endpoint that generated the error
relatedInfoobjectAdditional context (varies by error type)

Attachment Limit Errors

These errors occur when attachment generation exceeds “Safe Harbor” limits. All return 400 Bad Request.

See Limits & Quotas for complete limit documentation.

CodeErrorDescription
ERR_LIMIT_001PDF Page LimitPDF generation exceeded 30 page limit
ERR_LIMIT_002PDF Image LimitPDF contains more than 50 images
ERR_LIMIT_003Excel Row LimitExcel data exceeded 10,000 row limit
ERR_LIMIT_004Excel Sheet LimitWorkbook exceeded 10 sheet limit
ERR_LIMIT_005Excel Column LimitSheet exceeded 50 column limit
ERR_LIMIT_006File Size LimitGenerated file exceeds 7 MB
ERR_LIMIT_007Loop Iteration LimitLoop exceeded 1,000 iteration limit
ERR_LIMIT_008Nesting DepthTemplate exceeded 10 level nesting depth
ERR_LIMIT_009Component CountTemplate exceeded 500 component limit

Example: PDF Page Limit Error

{
  "statusCode": 400,
  "code": "ERR_LIMIT_001",
  "message": "PDF generation exceeded maximum page limit",
  "relatedInfo": {
    "actualPages": 45,
    "maxPages": 30,
    "message": "PDF generation exceeded 30 page limit. Your PDF has 45 pages."
  }
}

Example: Loop Iteration Error

{
  "statusCode": 400,
  "code": "ERR_LIMIT_007",
  "message": "Loop exceeded maximum iteration limit",
  "relatedInfo": {
    "actualIterations": 2500,
    "maxIterations": 1000,
    "loopId": "items",
    "message": "Loop \"items\" has 2,500 items but maximum is 1,000. Consider pagination or splitting data."
  }
}

Authentication Errors

CodeHTTPDescription
ERR_AUTH_001401Invalid credentials
ERR_AUTH_002401Missing authentication
ERR_AUTH_003401Invalid API key
ERR_AUTH_004401Token expired
ERR_AUTH_005403Insufficient permissions
ERR_AUTH_006401Invalid refresh token
ERR_AUTH_007429Too many login attempts

Template Errors

CodeHTTPDescription
ERR_TMPL_001404Template not found
ERR_TMPL_002404Template version not found
ERR_TMPL_003400Invalid template schema
ERR_TMPL_004400Variable validation failed
ERR_TMPL_005400Invalid component type
ERR_TMPL_006400Duplicate component ID
ERR_TMPL_007400Invalid slug format
ERR_TMPL_008409Slug already exists

Email Errors

CodeHTTPDescription
ERR_EMAIL_001400Invalid recipient email
ERR_EMAIL_002400Missing required variable
ERR_EMAIL_003400Invalid sender address
ERR_EMAIL_004402Insufficient email credits
ERR_EMAIL_005404Email log not found
ERR_EMAIL_006400Recipient on suppression list
ERR_EMAIL_007400Batch size exceeded

Rate Limit Errors

CodeHTTPDescription
ERR_QUOTA_001429Rate limit exceeded
ERR_QUOTA_002402Monthly quota exceeded
ERR_QUOTA_003429Concurrent request limit

Example: Rate Limit Error

{
  "statusCode": 429,
  "code": "ERR_QUOTA_001",
  "message": "Rate limit exceeded. Please retry after 45 seconds.",
  "retryAfter": 45
}

Validation Errors

CodeHTTPDescription
ERR_VALID_001400Missing required field
ERR_VALID_002400Invalid field type
ERR_VALID_003400Field exceeds max length
ERR_VALID_004400Invalid enum value
ERR_VALID_005400Invalid date format

OAuth Errors

CodeHTTPDescription
ERR_OAUTH_001400Invalid client ID
ERR_OAUTH_002400Invalid redirect URI
ERR_OAUTH_003400Invalid scope
ERR_OAUTH_004400Invalid authorization code
ERR_OAUTH_005401Client authentication failed
ERR_OAUTH_006400Invalid grant type
ERR_OAUTH_007403Insufficient scope

System Errors

CodeHTTPDescription
ERR_SYS_001500Internal server error
ERR_SYS_002503Service temporarily unavailable
ERR_SYS_003504Request timeout
ERR_SYS_004500Database connection error

Handling Errors

JavaScript/TypeScript

try {
  const response = await formamail.emails.send(payload);
} catch (error) {
  if (error.code === 'ERR_LIMIT_007') {
    // Handle loop iteration limit
    console.log(`Loop "${error.relatedInfo.loopId}" has too many items`);
    // Consider pagination or splitting data
  } else if (error.code === 'ERR_QUOTA_001') {
    // Handle rate limit
    await sleep(error.retryAfter * 1000);
    // Retry the request
  } else if (error.statusCode === 400) {
    // Handle validation errors
    console.log('Validation error:', error.message);
  }
}

Best Practices

  1. Check error codes programmatically - Don’t rely on error messages, they may change
  2. Handle rate limits gracefully - Implement exponential backoff
  3. Validate data client-side - Check array sizes before calling API
  4. Log relatedInfo - Contains valuable debugging context

Back to API Reference