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

# Installation & quick start

> Install the Authentica TypeScript SDK and make your first request.

## Requirements

* Node.js 22 or later
* An [Authentica account](https://portal.authentica.sa/signUp)
* An API key from the [Authentica portal](https://portal.authentica.sa/applications/create)

## Quick start

**1. Install the SDK**

```bash theme={null}
npm install @authenticasa/sdk
```

**2. Add your API key**

Store your API key in a server-side environment variable named `AUTHENTICA_API_KEY`.

```bash .env theme={null}
# Never commit this file
AUTHENTICA_API_KEY=your-api-key
```

Creating a `.env` file is not enough on its own: plain Node.js does not read it automatically. Load it explicitly when you start your app with the `--env-file` flag (shown in the last step).

In production, use your hosting platform's environment settings or a secrets manager.

> [!WARNING]
>
> Do not use frontend-exposed variable prefixes such as `NEXT_PUBLIC_`, `VITE_`, `REACT_APP_` or `EXPO_PUBLIC_`. Bundlers copy those values into code that ships to browsers.

**3. Create an Authentica client**

```js ES modules theme={null}
import { Authentica } from '@authenticasa/sdk';

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

```js CommonJS theme={null}
const { Authentica } = require('@authenticasa/sdk');

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

The SDK sends your key in the `X-Authorization` header on every request. You do not need to set any headers yourself.

**4. Make your first request**

Choose one of these examples and save it with the filename shown:

```js index.mjs theme={null}
import { Authentica } from '@authenticasa/sdk';

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

const { balance } = await authentica.balance.get();

console.log(balance);
```

```js index.cjs theme={null}
const { Authentica } = require('@authenticasa/sdk');

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

async function main() {
  const result = await authentica.balance.get();
  console.log(result);
}

main().catch(console.error);
```

Run it, loading your `.env` file:

```bash ES modules theme={null}
node --env-file=.env index.mjs
```

```bash CommonJS theme={null}
node --env-file=.env index.cjs
```

If this prints your credit balance, your integration is working.

> [!NOTE]
>
> The `.mjs` extension selects ES modules and `.cjs` selects CommonJS, so these examples run without changing the module setting in your `package.json`. TypeScript projects can use the same SDK methods with their existing build setup.

## Next steps

> [card] [Send an OTP](https://docs.authentica.sa/sdk/typescript/otp.md)
>
> Send and verify your first one-time password.

> [card] [Handle errors](https://docs.authentica.sa/sdk/typescript/error-handling.md)
>
> Catch and handle typed SDK errors.


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