Atlas Forms
API Connection Setup
Form Studio connects to the Atlas Forms REST API through the AtlasFormsClient singleton. This page covers how to configure the client in your own application, tenant authentication, and the connection options available.
AtlasFormsClient Initialisation
Initialise the client once at application startup. The singleton pattern ensures all packages share the same configuration:
import { AtlasFormsClient } from '@atlas-forms/client-js';
import { IndexedDBAdapter } from '@atlas-forms/storage-js';
// Initialise once in main.tsx or App.tsx
const client = AtlasFormsClient.getInstance({
apiBaseUrl: 'https://api.bizfirstai.com',
apiTimeout: 30000, // 30 second timeout
storageAdapter: new IndexedDBAdapter(), // Large draft storage
autoValidate: true, // Validate on field change
enableLogging: false // Set true for development
});
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiBaseUrl | string | Required | Base URL for all API calls. No trailing slash. |
apiTimeout | number | 30000 | Request timeout in milliseconds. |
storageAdapter | StorageAdapter | LocalStorageAdapter | Where drafts are stored. IndexedDB for larger forms. |
controlRegistry | ControlRegistry | Built-in | Custom control registry (for custom controls). |
themeResolver | ThemeResolver | Built-in light/dark | Custom theme resolver. |
autoValidate | boolean | true | Run validation on every field change. |
enableLogging | boolean | false | Log API calls and engine events to console. |
Authentication
The Atlas Forms API uses JWT bearer tokens. Configure the token provider so the client attaches it to every request:
const client = AtlasFormsClient.getInstance({
apiBaseUrl: 'https://api.bizfirstai.com',
// Token provider called before each request
getAuthToken: async () => {
// Return current JWT token from your auth system
return authService.getAccessToken();
}
});
Multi-Tenant Setup
Every API call that lists or fetches forms requires a tenantId. Set the default tenant at initialisation to avoid passing it on every call:
const client = AtlasFormsClient.getInstance({
apiBaseUrl: 'https://api.bizfirstai.com',
defaultTenantId: 42 // Your tenant ID
});
// Now listForms() uses tenantId: 42 by default
const forms = await client.listForms();
Environment-Specific Configuration
Use environment variables (Vite-style) to switch between environments:
// vite.config.ts — set in .env files
// .env.development: VITE_API_URL=http://localhost:5000
// .env.production: VITE_API_URL=https://api.bizfirstai.com
const client = AtlasFormsClient.getInstance({
apiBaseUrl: import.meta.env.VITE_API_URL,
enableLogging: import.meta.env.DEV
});
Connection Health Check
The client exposes a health check method to verify the API is reachable:
const health = await client.checkHealth();
if (!health.connected) {
console.error('Atlas Forms API unreachable:', health.error);
// Show offline banner to user
}
Storage Fallback Chain
If
IndexedDBAdapter is not available in the browser, StorageManager automatically falls back to LocalStorageAdapter, then to an in-memory adapter. Your code does not need to handle this — it is transparent.