> ## 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.

# Configuration

> Options for creating an Authentica client.

Pass options once, when you create the client. Only `apiKey` is required.

```ts theme={null}
import { Authentica } from '@authenticasa/sdk';

const authentica = new Authentica({
  apiKey: process.env.AUTHENTICA_API_KEY!,
  timeout: 15000,
});
```

## Options

| Option | Type | Default | Description |
| - | - | - | - |
| `apiKey` | `string` | Required | Your Authentica API key. |
| `timeout` | `number` | `30000` | Request timeout in milliseconds. Must be a positive integer. Applies to every request made by this client. |
| `baseUrl` | `string` | `https://api.authentica.sa/api/v2` | API base URL. You normally do not need to change it. |
| `fetch` | `function` | Global `fetch` | A custom `fetch` implementation, for example to route requests through a proxy. |
| `sendClientIdentifier` | `boolean` | `true` | Sends the `X-Authentica-Client` header. See [Client identification](#client-identification). |

Invalid options throw an `AuthenticaValidationError` when the client is created.

> [!NOTE]
>
> The SDK does not retry requests and has no per-call cancellation. Use `timeout` to bound how long a request can take.

## Client identification

By default, every request includes this header:

```http theme={null}
X-Authentica-Client: authentica-typescript/0.1.0
```

Authentica uses it to recognize SDK traffic and see which SDK versions are in use.

* It contains only the SDK name and version.
* It contains no API key, account details or end-user data.
* It is not used for authentication. Your key is sent only in `X-Authorization`.

To turn it off:

```ts theme={null}
const authentica = new Authentica({
  apiKey: process.env.AUTHENTICA_API_KEY!,
  sendClientIdentifier: false,
});
```

Disabling the header does not change SDK behavior. Every operation, header, error and timeout works the same either way.

## Advanced options

> [accordion] Custom baseUrl
>
> `baseUrl` must use `https`. Plain `http` is allowed only for `localhost`, `127.0.0.1` and `[::1]`. It must not contain credentials, a query string or a fragment.
>
> The SDK sends your API key to whatever host you configure. Set `baseUrl` only from trusted server configuration, never from user input or tenant-editable settings.

> [accordion] Custom fetch
>
> A custom `fetch` receives every request, including your API key and request bodies. Use only implementations you control or fully trust.
>
> Your implementation must:
>
> * never log or store credentials or request bodies
> * not retry requests internally, since a retried OTP send can deliver a second message and use extra credits
> * honor `redirect: 'manual'`, so your API key is never forwarded to another host
> * return a response with `status`, `ok` and `text()`; without `headers`, `retryAfterSeconds` is never set


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