---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-igaming/interfaces/SportsbookApi.md
---
[Reference](../../../index.md) / [@getenginex/sdk-igaming](../index.md) / SportsbookApi

# SportsbookApi

FIRST sportsbook (`GET /first/session`). The provider and the configuration come from
the core's `enginex.config.getSportsbook()`.

## Methods

### createSession()

> **createSession**(`params?`, `options?`): `Promise`<[`SportsbookSession`](SportsbookSession.md)>

Creates the FIRST session for the logged-in player: returns the sportsbook URL (with the
operator token) to load in an iframe. Requires login. There is no cache in the SDK: each call generates a new
token; reuse the session until `expiresAt - 30_000` and call
`enginex.config.getSportsbook()` first to confirm `enabled && provider === 'first'`.

**The returned URL carries the operator token.** The SDK delivers it only in the return value: no hook
(`onRequest`/`onResponse`/`onError`) nor `onValidationIssue` receives it, and the response is always
validated in strict mode. The separate token (`operator_token`) is never exposed. Do not log the URL
to logs, analytics or error tracking.

#### Parameters

##### params?

[`NoParams`](../../sdk/type-aliases/NoParams.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`SportsbookSession`](SportsbookSession.md)>

#### Example

```ts
const sb = await enginex.config.getSportsbook()
if (sb.enabled && sb.provider === 'first') {
  const { launchUrl, expiresAt } = await igaming.sportsbook.createSession()
  iframe.src = launchUrl
}
```

#### Throws

`UNAUTHENTICATED` without a session; the gateway envelope's code when FIRST
is not enabled for the operator (HTTP 400) and `UNAVAILABLE` (503) when the FIRST configuration is
incomplete, the session service is down or the bets service's sportsbook configuration
is not available; `VALIDATION_ERROR` if `launch_url` is not an
absolute http(s) URL or `expires_in_seconds` is not greater than zero.
