# Configure the client

Canonical page: https://docs.ovok.com/web-sdk/core/client-configuration

Create `Ovok` from the package root and pass the API origin and tenant code:

```ts
import { Ovok } from '@ovok/core';

const ovok = new Ovok({
  baseUrl: 'https://api.sandbox.ovok.com',
  tenantCode: 'your-tenant',
  fhirPath: 'fhir/R4',
});
```

`baseUrl` must be an absolute HTTP(S) URL. `tenantCode` is required. `fhirPath` defaults to `fhir`; leading and trailing slashes are removed before requests.

## Storage and requests [#storage-and-requests]

- **Session storage:** the session lives in memory by default. Pass any `OvokStorage` (`localStorage`, AsyncStorage, or your own `getItem`/`setItem`/`removeItem`) to keep users signed in across restarts.
- **Requests:** `timeoutMs` and `maxNetworkRetries` tune every request; `fetch` replaces the runtime `fetch`.
- **Sign-out notice:** `onUnauthenticated` runs when a refresh token is refused and the user has been signed out.
- **Outbox:** `outboxStore` keeps unsent measurements (memory by default; `IndexedDbOutboxStore` in a browser), `connectivity` and `lifecycle` tell it when to send, `outboxRequestBudget` caps its requests per 30 seconds (40 by default) and `logger` receives its structured log entries. See [ovok.outbox](./namespaces/outbox.mdx).

Every option, its type and its default is listed in the [Ovok client reference](./reference/core/ovok-client.mdx). Keep persisted session data protected as your app's security requirements demand.

## Machine credentials [#machine-credentials]

Server applications may supply both `clientId` and `clientSecret` for machine authentication. Never put `clientSecret` in browser or mobile application code; the client rejects it when running in a browser.

A server that only reads published CMS content can pass `cmsApiKey` instead: a read-only key sent as `x-api-key` on `ovok.cms` reads, with no session. It is a secret too, and rejected in a browser the same way. See [ovok.cms](./namespaces/cms.mdx).

## Use a resource namespace [#use-a-resource-namespace]

The client groups operations by API domain. For example, FHIR searches use `ovok.fhir`:

```ts
const patients = await ovok.fhir.search('Patient', { _count: 10 });
```

## See also [#see-also]

- [The Ovok client](./next-client.mdx): paging and request options.
- [Errors and retries](./errors-and-retries.mdx): error classes.
- [Ovok client reference](./reference/core/ovok-client.mdx)
