Documentation
Knowledge BaseKnowledge BaseAPI UsageHandling API Errors

Handling API Errors

Common error codes, what they mean, and how to handle them in your integration.

Enrich Layer uses standard HTTP status codes. Here's how to handle the most common ones.

Error codes

StatusMeaningWhat to do
400Bad request — invalid parametersCheck your query parameters. The response body includes details.
401Unauthorized — invalid or missing API keyVerify your API key in the Authorization header.
403Forbidden — insufficient credits or plan limitsCheck your credit balance. Upgrade your plan if needed.
404Not found — no profile matched the queryThe person or company wasn't found. This is expected for some lookups.
429Rate limited — too many requestsWait and retry. See Rate Limits.
500Server error — something went wrong on our endRetry after a few seconds. If persistent, contact support.
async function enrichProfile(url) {
  const response = await fetch(
    `https://enrichlayer.com/api/v2/profile?profile_url=${encodeURIComponent(url)}`,
    { headers: { Authorization: `Bearer ${API_KEY}` } }
  );

  if (response.status === 404) {
    return null; // Profile not found — expected for some lookups
  }

  if (response.status === 429) {
    // Rate limited — wait and retry
    const retryAfter = response.headers.get('Retry-After') || '60';
    await new Promise(r => setTimeout(r, parseInt(retryAfter) * 1000));
    return enrichProfile(url); // Retry
  }

  if (!response.ok) {
    throw new Error(`API error: ${response.status}`);
  }

  return response.json();
}
JSjavascript

404 is not always an error

A 404 response from a lookup endpoint means the person or company wasn't found in the data source. This is normal — not every profile URL resolves to a profile, and not every email has a matching person.

Handle 404 as a valid "no result" case, not as an error.