> ## Documentation Index
> Fetch the complete documentation index at: https://docs.authentica.sa/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting

> Fix common issues when integrating the TypeScript SDK.

> [accordion] 401 — Authentication error
>
> The SDK throws `AuthenticaAuthenticationError`: the API key is missing or invalid.
>
> * Check that `AUTHENTICA_API_KEY` is set in the process that runs your server, not only in your local shell.
> * Make sure the key has no surrounding quotes or whitespace.
> * Confirm the key is still active in the [Authentica portal](https://portal.authentica.sa/applications/).

> [accordion] 422 — Request rejected
>
> The request reached the API, but the input was rejected. The SDK throws `AuthenticaApiError` with `status` `422`.
>
> * Check required fields and formats, such as international phone numbers.
> * For OTP verification, the code may be wrong or expired. Treat it as a failed verification.
> * For face and voice verification, check that the images or audio meet the service requirements.
>
> A 422 is an API response, not an SDK bug.

> [accordion] 429 — Rate limited
>
> You are sending too many requests. The SDK throws `AuthenticaApiError` with `status` `429`.
>
> * Check `error.retryAfterSeconds`. If set, wait that long before trying again.
> * Do not resend OTPs automatically; ask the user to try again later.
>
> See [Rate limits](https://docs.authentica.sa/sdk/typescript/error-handling.md#rate-limits-http-429).

> [accordion] Connection errors
>
> The SDK throws `AuthenticaConnectionError` when no response is received.
>
> * Check that your server allows outbound HTTPS to `api.authentica.sa`.
> * Check DNS, proxy and firewall settings.
> * If you set a custom `baseUrl` or `fetch`, check those first.
> * If everything looks correct, contact [Authentica support](https://wa.me/966536553944).

> [accordion] Timeouts
>
> The SDK throws `AuthenticaTimeoutError` when a request exceeds `timeout` (30 seconds by default).
>
> * Check network latency between your server and Authentica.
> * Adjust `timeout` if needed. See [Configuration](https://docs.authentica.sa/sdk/typescript/configuration.md).
> * The operation may still have completed. Do not resend an OTP automatically.

> [accordion] Unexpected response
>
> The SDK throws `AuthenticaResponseError` when a 2xx response is empty, not valid JSON or missing expected fields.
>
> * Upgrade to the latest SDK version.
> * If it continues, contact [Authentica support](https://wa.me/966536553944) with the time of the request and the error name. Do not share API keys or user data.

> [accordion] Node.js version
>
> The SDK requires Node.js 22 or later. Check your version:
>
> ```bash theme={null}
> node --version
> ```
>
> Upgrade Node.js in every environment that runs your server, including CI and production.

> [accordion] Using the SDK in the browser
>
> The SDK throws if you create a client in a browser, because doing so would expose your API key.
>
> * Move all Authentica calls to your backend.
> * Expose your own endpoint for your frontend to call.
> * If your API key was included in a frontend bundle, rotate it immediately.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.