# Configuration

LedgerCoreOptions, BankingOptions, and BankingApiOptions.

URL: https://docs.shiwake.app/docs/sdk/configuration



The SDK is configured through three `IOptions<T>` types. All can be set
via the DI extension methods or bound from `IConfiguration`.

LedgerCoreOptions [#ledgercoreoptions]

Controls the core HTTP client: where it talks to, how it authenticates,
and how long it waits.

<TypeTable
  type="{
  BaseUrl: { type: &#x22;string&#x22;, default: &#x22;\&#x22;\&#x22;&#x22;, description: &#x22;Base URL of the Shiwake API. No trailing slash&#x22; },
  ApiKey: { type: &#x22;string&#x22;, default: &#x22;\&#x22;\&#x22;&#x22;, description: <>API key sent as <code>X-Api-Key</code> on every request</> },
  ApiVersion: { type: &#x22;string&#x22;, default: &#x22;\&#x22;1\&#x22;&#x22;, description: <>Version segment in the route (<code>/api/v&#123;ApiVersion&#125;/...</code>)</> },
  TimeoutSeconds: { type: &#x22;int&#x22;, default: &#x22;30&#x22;, description: <><code>HttpClient.Timeout</code></> },
}"
/>

Both `BaseUrl` and `ApiKey` are required. The SDK does not validate them
at registration time. You'll find out they're wrong on the first request
via a `LedgerCoreException`.

Setting via code [#setting-via-code]

```csharp
builder.Services.AddLedgerCoreSdk(options =>
{
    options.BaseUrl        = "https://api.shiwake.example.com";
    options.ApiKey         = Environment.GetEnvironmentVariable("LEDGER_KEY")!;
    options.TimeoutSeconds = 60;
});
```

Binding from appsettings.json [#binding-from-appsettingsjson]

The section name is `"LedgerCore"` by default. Pass a second argument to
override it.

```json
{
  "LedgerCore": {
    "BaseUrl": "https://api.shiwake.example.com",
    "ApiKey": "sk_live_...",
    "TimeoutSeconds": 30
  }
}
```

```csharp
builder.Services.AddLedgerCoreSdk(builder.Configuration);
```

BankingApiOptions [#bankingapioptions]

Options for the full [banking API client](/docs/sdk/banking-api).
Intentionally sparse. Base URL and auth are inherited from
`LedgerCoreOptions`.

<TypeTable
  type="{
  DefaultCreatedBy: { type: &#x22;string?&#x22;, default: &#x22;null&#x22;, description: <>Default value for the <code>X-Created-By</code> header when a per-call value isn't provided</> },
}"
/>

```csharp
builder.Services.AddLedgerCoreBankingApi(options =>
{
    options.DefaultCreatedBy = "deposit-webhook";
});
```

BankingOptions [#bankingoptions]

Controls how the [simple banking client](/docs/sdk/banking) maps client
ids to account codes and which platform account funds deposits. Only
relevant if you register `IBankingClient` (the simple wrapper). The full
`IBankingApiClient` does not use these settings.

<TypeTable
  type="{
  PlatformFloatAccountCode: { type: &#x22;string&#x22;, default: &#x22;\&#x22;PLATFORM-FLOAT\&#x22;&#x22;, description: &#x22;The asset account that funds deposits and receives withdrawals&#x22; },
  ClientAccountCodePrefix: { type: &#x22;string&#x22;, default: &#x22;\&#x22;CLIENT-\&#x22;&#x22;, description: &#x22;Prefix used to derive an account code from a client id&#x22; },
  ClientAccountType: { type: &#x22;string&#x22;, default: &#x22;\&#x22;Liability\&#x22;&#x22;, description: &#x22;Account type assigned when opening a new client account&#x22; },
  ClientAccountNormalBalance: { type: &#x22;string&#x22;, default: &#x22;\&#x22;Credit\&#x22;&#x22;, description: &#x22;Normal balance for client accounts&#x22; },
}"
/>

The derivation rule is literally `$"{ClientAccountCodePrefix}{ClientId}"`.
A client id of `42` with the default prefix becomes account code `CLIENT-42`.

<Callout type="info">
  The platform float account must already exist in the tenant before
  calling `DepositAsync` or `WithdrawAsync`. The banking client does not
  create it for you. That's a one-time bootstrap step, typically done
  via the [Accounts API](/docs/api/accounts) when provisioning a tenant.
</Callout>

Setting via code [#setting-via-code-1]

```csharp
builder.Services.AddLedgerCoreBanking(options =>
{
    options.PlatformFloatAccountCode = "MAIN-FLOAT";
    options.ClientAccountCodePrefix  = "WALLET-";
});
```

Binding from appsettings.json [#binding-from-appsettingsjson-1]

`AddLedgerCoreBanking` does not have a configuration-binding overload, but
you can bind it yourself:

```json
{
  "LedgerCore": { /* ... */ },
  "LedgerCoreBanking": {
    "PlatformFloatAccountCode": "MAIN-FLOAT",
    "ClientAccountCodePrefix": "WALLET-"
  }
}
```

```csharp
builder.Services.Configure<BankingOptions>(
    builder.Configuration.GetSection("LedgerCoreBanking"));
builder.Services.AddLedgerCoreBanking();
```

Why the banking defaults are what they are [#why-the-banking-defaults-are-what-they-are]

The defaults (`PLATFORM-FLOAT`, `CLIENT-{id}`, `Liability`, `Credit`)
match the convention used throughout this documentation and the Quickstart.
If you follow the defaults, everything in the docs works as-is. If you
override them, substitute accordingly in the examples.
