#### `constructor`

Creates a new Skribby Client.

| Parameter | Default | Description |
| --- | --- | --- |
| `options` | _required_ | Options when creating a new client |
| `options.api_key` | _required_ | Skribby API Key found on [the platform](https://platform.skribby.io?to=api-keys) |
| `options.region` | `'eu'` | The region where your account and data are hosted (`'eu'` or `'jp'`). The base URL will be derived automatically based on this value. |
| `options.base_url` | `'https://platform.skribby.io/api/v1'` | Optionally override the base URL if necessary (e.g., when mocking tests or using a specialized environment). |

```ts
import { SkribbyClient } from '@skribby/sdk';

const client = new SkribbyClient({
    api_key: 'SKRIBBY_API_KEY',
    region: 'jp', // defaults to 'eu'
});
```

## Methods

> **Error Handling**
> All methods (except `getRealtimeClient`) interact with Skribby's server.
> Refer to the [SkribbyClient API Requests Throws section](./SkribbyClient.md#throws) for more information on error handling.

### `createBot`

Create a new Meeting Bot which will join the meeting right away.

#### Parameters

This method expects an object of options which is identical to the ones in the REST API Documentation.
Please refer to the [Create Bot Endpoint](/docs/rest-api/bot-operations/createbot.md) for all options.

#### Returns

[`MeetingBot`](./MeetingBot.md)

#### Example

```ts
await client.createBot({
    bot_name: 'Alex from Acme',
    meeting_url: 'https://meet.google.com/abc-defg-hij',
    service: 'gmeet',
    transcription_model: 'groq/whisper-large-v3-turbo',
    stop_options: {
        empty_meeting_timeout: 10,
        last_person_detection: 5,
        waiting_room_timeout: 10,
        time_limit: 120,
        silence_detection: 0,
    },
    custom_metadata: {
        request_id: 'req_123',
        customer_id: 'acme-42',
    },
});
```

### `scheduleBot`

Schedule a Meeting Bot for later to join.

#### Parameters

This method expects an object of options which is identical to the ones in the REST API Documentation.
Please refer to the [Create Bot Endpoint](/docs/rest-api/bot-operations/createbot.md) for all options. Additionally, `scheduled_for` is required for this method.

| Parameter | Default | Description |
| --- | --- | --- |
| `options` | _required_ | All options from `createBot` |
| `options.scheduled_for` | _required_ | The scheduled time for the bot to join |

#### Returns

[`MeetingBot`](./MeetingBot.md)

#### Example

```ts
await client.scheduleBot({
  bot_name: "Alex from Acme",
  meeting_url: "https://meet.google.com/abc-defg-hij",
  service: "gmeet",
  transcription_model: "groq/whisper-large-v3-turbo",
  scheduled_for: new Date(new Date().getTime() + 5 * 60000).toISOString(), // Join in 5 minutes
});
```

### `updateBot`

Update an existing Meeting Bot.

#### Parameters

| Parameter | Default | Description |
| --- | --- | --- |
| `botId` | _required_ | ID of the meeting bot to update |
| `options` | _required_ | Update options |

This method expects an object of options which is identical to the ones in the REST API Documentation.
Please refer to the [Update Bot Endpoint](/docs/rest-api/bot-operations/updatebot.md) for all options.

#### Returns

[`MeetingBot`](./MeetingBot.md)

#### Example

```ts
await client.updateBot('123456', {
    bot_name: 'Jamie from Acme',
    scheduled_start_time: new Date(new Date().getTime() + 10 * 60000),
    custom_metadata: {
        request_id: 'req_456',
        customer_id: 'acme-42',
    },
});

// Or force a scheduled bot to join immediately by clearing the schedule:
await client.updateBot('123456', {
    scheduled_start_time: null,
});
```

### `getScheduledBots`

Fetch all scheduled bots.

#### Returns

[`MeetingBot[]`](./MeetingBot.md)

#### Example

```ts
await client.getScheduledBots();
```

### `getBotById`

Fetch a bot with a specific ID.

#### Parameters

| Parameter | Default | Description |
| --- | --- | --- |
| `botId` | _required_ | ID of the meeting bot |

#### Returns

[`MeetingBot`](./MeetingBot.md)

#### Example

```ts
await client.getBotById('123456');
```

### `getBotPricing`

Fetch pricing data for a bot with a specific ID.

#### Parameters

| Parameter | Default | Description |
| --- | --- | --- |
| `botId` | _required_ | ID of the meeting bot |

#### Returns

`MeetingBotPricingData`

#### Example

```ts
const pricing = await client.getBotPricing('123456');

console.log(pricing.currency); // USD
console.log(pricing.total.rate_per_hour); // e.g. 0.92
console.log(pricing.total.amount); // null while in progress, number when finished
```

This method maps to the [Get Bot Pricing Endpoint](/docs/rest-api/bot-operations/getbotpricing.md).

### `createRecording`

Create a new Recording.

#### Parameters

This method expects an object of options which is identical to the ones in the REST API Documentation.
Please refer to the [Create Recording Endpoint](/docs/rest-api/recording-operations/createrecording.md) for all options.

#### Returns

[`Recording`](./Recording.md)

#### Example

```ts
await client.createRecording({
    // recording options
});
```

### `getRecordingById`

Fetch a recording with a specific ID.

#### Parameters

| Parameter | Default | Description |
| --- | --- | --- |
| `recordingId` | _required_ | ID of the recording |

#### Returns

[`Recording`](./Recording.md)

#### Example

```ts
await client.getRecordingById('123456');
```

### `apiRequest`

All SDK API requests use this method. You can also call it directly for REST endpoints that do not have a dedicated SDK method.

#### Parameters

| Parameter | Default | Description |
| --- | --- | --- |
| endpoint | _required_ | The endpoint you are trying to reach (for example, `/bot` for creating a new bot) |
| method | `GET` | Method to be used for the API Call |
| body | `{}` | Body contents to be used for the API Call |

#### Throws

If an API call has failed, then we'll throw an error depending on status code.  
Below is a list of predefined custom errors to make handling them easier:

- `UnauthorizedError` (401) - Provided API Key is invalid
- `NotFoundError` (404) - Requested entity not found
- `UnprocessableEntityError` (422) - Validation has failed (eg. required parameters were not provided)
- `ApiRequestError` - Global catch for other uncommon errors

The first 3 errors extend the `ApiRequestError`. So if you want a global catch you can simply use the `ApiRequestError`.
All errors will include the following properties:

- `status`
- `statusText`
- `responseBody`
- `url`
- `method`

#### Returns

Object data returned from the endpoint.