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:
| Parameter | Type | Required | Description |
|---|
baseUrl | string | Yes | The Artos API base URL |
authMode | string | No | Authentication mode: 'bearer' (default) or 'cookie' |
Returns: ApiClient
interface ApiClient {
call: (options: ApiCallOptions) => Promise<any>
baseUrl: string
authMode: string
}
Common Authentication Errors
| Status Code | Description | Recommended Action |
|---|
| 401 | Unauthorized | Verify your access token is valid and not expired |
| 403 | Forbidden | Confirm you have access to the requested resource |
”401 Unauthorized” Error
- Verify your access token is correct
- Check if the token has expired
- Contact Artos support for a new token if needed
”403 Forbidden” Error
- Verify the document ID is correct
- Confirm your organization has access to this document
- Contact your Artos account manager