Skip to main content

npm SDK Authentication

The Artos npm SDK uses Bearer token authentication. You’ll need your organization access token to make API calls.

Basic Authentication

Pass your access token directly to each SDK function call:
const accessToken = 'your-organization-access-token'
const baseUrl = 'https://api.artosai.com'
Store your access token in environment variables, not in your source code.
const accessToken = process.env.ARTOS_ACCESS_TOKEN
const baseUrl = process.env.ARTOS_API_URL || 'https://api.artosai.com'

Reusable API Client

For applications making frequent API calls, create a reusable API client with createApiClient:
import { createApiClient, getTemplateUrl } from '@artosai/sdk'

// Create a reusable client
const artosClient = createApiClient({
    baseUrl: 'https://api.artosai.com'
})

// Use the shared client for multiple calls
async function getMultipleTemplates(documentIds, accessToken) {
    const results = await Promise.all(
        documentIds.map(id => getTemplateUrl({
            documentId: id,
            accessToken,
            apiClient: artosClient
        }))
    )
    return results
}

createApiClient(config)

Creates a reusable API client instance. Parameters:
ParameterTypeRequiredDescription
baseUrlstringYesThe Artos API base URL
authModestringNoAuthentication mode: 'bearer' (default) or 'cookie'
Returns: ApiClient
interface ApiClient {
    call: (options: ApiCallOptions) => Promise<any>
    baseUrl: string
    authMode: string
}

Common Authentication Errors

Status CodeDescriptionRecommended Action
401UnauthorizedVerify your access token is valid and not expired
403ForbiddenConfirm you have access to the requested resource

”401 Unauthorized” Error

  1. Verify your access token is correct
  2. Check if the token has expired
  3. Contact Artos support for a new token if needed

”403 Forbidden” Error

  1. Verify the document ID is correct
  2. Confirm your organization has access to this document
  3. Contact your Artos account manager