# Config

This class defines the [[Bkper]] API Config.

### agentIdProvider()?

```ts
optional agentIdProvider: () => Promise<string | undefined>;
```

Provides the agent ID to identify the calling agent for attribution purposes.

This ID is sent via the `bkper-agent-id` header with each API request,
allowing the server to attribute actions to the correct agent.

#### Returns

`Promise`\<`string` \| `undefined`\>

***

### apiKeyProvider()?

```ts
optional apiKeyProvider: () => Promise<string>;
```

Optional API key for dedicated quota limits.

If not provided, requests use a shared managed quota via the Bkper API proxy.
Use your own API key for dedicated quota limits and project-level usage tracking.

API keys are for project identification only, not for authentication or agent attribution.
Agent attribution is handled separately via the `agentIdProvider`.

#### Returns

`Promise`\<`string`\>

***

### oauthTokenProvider()?

```ts
optional oauthTokenProvider: () => Promise<string | undefined>;
```

Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.

If omitted or if it returns undefined, requests are sent without an Authorization header.
This supports environments where authentication is injected outside bkper-js, such as
Bkper Platform outbound for server-side app routes.

#### Returns

`Promise`\<`string` \| `undefined`\>

***

### requestErrorHandler()?

```ts
optional requestErrorHandler: (error) => any;
```

Custom request error handler

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `error` | `any` | The error object of the failed request. |

#### Returns

`any`

***

### requestHeadersProvider()?

```ts
optional requestHeadersProvider: () => Promise<{
[key: string]: string;
}>;
```

Provides additional headers to append to the API request

#### Returns

`Promise`\<\{
\[`key`: `string`\]: `string`;
\}\>

***

### requestRetryHandler()?

```ts
optional requestRetryHandler: (status?, error?, attempt?) => Promise<void>;
```

Custom request retry handler.

This function is called when a request fails and needs to be retried.
It provides the HTTP status code, error message, and the number of retry attempts made so far.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `status?` | `number` | - |
| `error?` | `any` | The error object of the failed request. |
| `attempt?` | `number` | The number of retry attempts made so far. |

#### Returns

`Promise`\<`void`\>
