Skip to content
Last updated

Errors

The iClosed API uses standard HTTP status codes and returns a JSON body on every error response.


Error Response Shapes

Errors come in two shapes depending on the type of failure.

Authentication / server errors (401, 403, 404, 500)

{
  "message": "API key is required",
  "code": "MISSING_API_KEY"
}
FieldTypeDescription
messagestringHuman-readable description
codestringOptional machine-readable code (present on some 401s)

Validation errors (400)

{
  "message": {
    "status": 400,
    "details": {
      "formErrors": [],
      "fieldErrors": {
        "email": ["Invalid email format"],
        "phoneNumber": ["Must be E.164 format"]
      }
    },
    "endpoint": "/v1/contacts",
    "method": "POST"
  }
}
FieldTypeDescription
message.statusnumberAlways 400
message.details.formErrorsarrayGlobal validation errors not tied to a specific field
message.details.fieldErrorsobjectMap of field name → array of error messages
message.endpointstringThe endpoint that returned the error
message.methodstringThe HTTP method used

Unified Inbox validation errors (400)

Unified Inbox returns message as a string, with the field errors next to it:

{
  "message": "chatId is required",
  "details": {
    "formErrors": ["chatId is required"],
    "fieldErrors": {}
  }
}

Rate limit errors (429)

{
  "code": "RATE_LIMIT_EXCEEDED",
  "message": "Too many requests, please try again later.",
  "retryAfter": 3,
  "limit": {
    "points": 20,
    "windowSec": 10
  }
}

HTTP Status Codes

CodeMeaningCommon CauseAction
200OKRequest processed normallyRead response body
201CreatedResource created successfullyRead data in response body
400Bad RequestMissing required field, wrong type, or failed validationRead message.details.fieldErrors
401UnauthorizedMissing, expired, or revoked API keyCheck Authorization header
403ForbiddenKey exists but lacks permissionCheck key scope or plan
404Not FoundResource ID doesn't exist or wrong endpoint URLVerify IDs and path
429Too Many RequestsRate limit exceededRead retryAfter and wait
500Internal Server ErrorUnexpected server-side failureRetry with backoff; contact Support if persistent

Application-Level Error Codes

Authentication

message valuecodeCauseResolution
"API key is required"MISSING_API_KEYAuthorization header missing or token doesn't start with iclosed_Add Authorization: Bearer iclosed_<key>
"Invalid API key"—Key unknown, revoked, or malformedCreate a new key in Settings
"API key expired"—Key has passed its expiration dateRotate to a new key

Contact Errors

ErrorCauseResolution
email field error: "Invalid email format"Email value fails format validationProvide a valid email address
phoneNumber field error: "Must be E.164 format"Phone not in E.164 (e.g. +15551234567)Use international format with country code
"Resource not found!"contactId doesn't exist in this accountCreate the contact first with POST /v1/contacts

Invitee Answer Errors

ErrorCauseResolution
"INVALID_INVITEE_QUESTION_TYPE"inviteeQuestionAnswers[].type doesn't match any question on the eventAlign type with event invitee questions. Valid values: EMAIL, PHONE_NO, NAME, FIRST_NAME, LAST_NAME
"Record not found!"linkPrefix doesn't match any live eventVerify format is username/event-name and the event is active

Booking Errors

ErrorCauseResolution
Slot unavailable (400)dateTime in POST /v1/eventCalls is no longer openRe-fetch POST /v1/events/eventDates and let user pick again
"Resource not found!"eventCallId doesn't existVerify the call ID is correct

Rate Limit

code valueCauseResolution
RATE_LIMIT_EXCEEDEDMore than the plan limit for this endpoint. Startup is 20 requests per 10 seconds. Business is 100Read retryAfter in the response body and wait before retrying

Handling Errors in Code

Python

import time
import requests

def make_request(method, url, headers, **kwargs):
    response = getattr(requests, method)(url, headers=headers, **kwargs)

    if response.status_code == 400:
        errors = response.json().get('message', {}).get('details', {})
        print("Validation errors:", errors.get('fieldErrors'))
        return None

    if response.status_code == 401:
        body = response.json()
        print(f"Auth error: {body.get('message')} (code: {body.get('code')})")
        return None

    if response.status_code == 429:
        retry_after = response.json().get('retryAfter', 5)
        time.sleep(retry_after)
        return make_request(method, url, headers, **kwargs)  # retry once

    response.raise_for_status()
    return response.json()

Node.js

async function makeRequest(url, options = {}) {
  const response = await fetch(url, options);

  if (response.status === 400) {
    const { message } = await response.json();
    console.error('Validation errors:', message?.details?.fieldErrors);
    return null;
  }

  if (response.status === 401) {
    const { message, code } = await response.json();
    console.error(`Auth error: ${message} (${code})`);
    return null;
  }

  if (response.status === 429) {
    const { retryAfter = 5 } = await response.json();
    await new Promise(r => setTimeout(r, retryAfter * 1000));
    return makeRequest(url, options); // retry once
  }

  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  return response.json();
}

See Also