# Configuration

> Point the React SDK at your backend with configureSommatic, send a Veripass token with each service, and tune timeouts and debug logs.

Source: https://docs.sommatic.ai/en/sdks/react/configuration/ (updated 2026-11-26)

The SDK needs to know one thing before it can talk to Sommatic AI: where to send its requests. Everything else (tokens,
timeouts) is set per service instance.

## Set the base URL

```javascript
// main.jsx
import { configureSommatic } from '@sommatic/react-sdk';

configureSommatic({ baseUrl: 'https://api.sommatic.ai' });

createRoot(document.getElementById('root')).render(<App />);
```

`configureSommatic({ baseUrl })` points **every** service and stream of the SDK at that address. Use the Sommatic AI API,
or a backend of yours that forwards requests to it.

Call it **once, before the first render**. Each service reads the base URL when it is created, so a service created
before the call keeps the old value.

| Situation                                   | Base URL used                                                |
| ------------------------------------------- | ------------------------------------------------------------ |
| `configureSommatic({ baseUrl })` was called | That `baseUrl`.                                              |
| It was not called                           | `import.meta.env.VITE_APP_BACKEND_URL` from your Vite build. |
| Neither is set                              | An empty string: requests go to your app's own origin.       |

`resolveSommaticBaseUrl()` returns the value currently in use, useful when you build your own requests next to the SDK.

## Send a token

Services send `Authorization: Bearer <token>` when you create them with an `apiKey`:

```javascript
import { WorkManagementTaskService } from '@sommatic/react-sdk';

const tasks = new WorkManagementTaskService({ apiKey: accessToken });
const inbox = await tasks.getByParameters({ queryselector: 'inbox', user_id: userIdentity, page: 1, pageSize: 25 });
```

The token is the one Veripass issues for your organization; see [Authentication](https://docs.sommatic.ai/en/api/authentication.md). The
helpers `fetchEntityCollection`, `createEntityRecord`, `updateEntityRecord` and `deleteEntityRecord` take the same
`apiKey` and pass it to the service they instantiate.

> **Warning: Never ship a long-lived secret to the browser**
>
> Anything in a `VITE_` variable is readable by whoever loads your app. Pass the signed-in person's token at runtime,
> or route the SDK through a backend of yours that adds the credentials.

## Timeouts

Each service accepts `settings` with a `timeout` in milliseconds. The default is 31,000 ms; the Git Sync service uses
180,000 ms because a preview or an apply can take longer.

```javascript
const definitions = new WorkflowOrchestrationFlowDefinitionService({ apiKey: accessToken, settings: { timeout: 60000 } });
```

When a create, update, delete or post times out, the service does not throw: it returns
`{ success: false, isTimeout: true, message, code }`.

## Debug logs of the Command Center

Set `VITE_COMMAND_CENTER_DEBUG=true` in your development environment to log every plan the Command Center receives and
every step it runs in the browser console.

## Next steps

- [Services](https://docs.sommatic.ai/en/sdks/react/services.md): The service classes and what each one reads and writes.
- [Authentication](https://docs.sommatic.ai/en/api/authentication.md): How to get and send a token.
