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

# npm SDK Authentication

> Authenticate the Artos npm SDK with an Okta access-token JWT.

# npm SDK Authentication

The Artos npm SDK sends your Okta access token as a Bearer token on protected
API requests.

## Install

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

If your organization uses GitHub Packages, configure `.npmrc` first:

```text theme={null}
@artosai:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
```

## Configure the token

Obtain an access token by signing in through your organization's Okta
application. Use the access token issued for the Artos API—not an ID token.

```javascript theme={null}
const accessToken = process.env.OKTA_ACCESS_TOKEN
const baseUrl = process.env.ARTOS_API_URL || 'https://api.artosai.com'
```

<Warning>Keep tokens in environment variables or a secure secret store. Never commit, log, or put them in browser URLs.</Warning>

<Warning>Keep the token in an environment variable or secure secret store. Never commit it, log it, or put it in a browser URL.</Warning>

Pass the token to protected SDK methods:

```javascript theme={null}
import { getTemplateResource } from '@artosai/sdk'

const template = await getTemplateResource({
    documentId: 'document-id',
    accessToken,
    baseUrl
})

console.log(template.templateResourceId)
```

## Reuse an API client

```javascript theme={null}
import { createApiClient, getDocumentSections } from '@artosai/sdk'

const apiClient = createApiClient({ baseUrl })

const result = await getDocumentSections({
    documentId: 'document-id',
    accessToken,
    apiClient
})
```

The SDK sends the token as:

```text theme={null}
Authorization: Bearer <access-token>
```

## Common authentication errors

| Status | Meaning                                                             | Action                                  |
| ------ | ------------------------------------------------------------------- | --------------------------------------- |
| `401`  | The token is missing, invalid, expired, or intended for another API | Obtain a fresh Okta access token        |
| `403`  | The token is valid, but the user cannot access the resource         | Ask your Artos administrator for access |
