# Webhooks AppSettings.json

> The `appsetting.json` file (`C:\Program Files (x86)\UiPath\Orchestrator\Webhooks`) contains the out-of-the-box settings for the Webhooks Service. It is recommended to configure your custom settings in the `appsetting.Production.json`. This file overrides any pre-existing settings within `appsetting.json` after each installation process.

The `appsetting.json` file (`C:\Program Files (x86)\UiPath\Orchestrator\Webhooks`) contains the out-of-the-box settings for the Webhooks Service. It is recommended to configure your custom settings in the `appsetting.Production.json`. This file overrides any pre-existing settings within `appsetting.json` after each installation process.

:::note
It is recommended that only administrators change the values of these parameters. Additionally, it is recommended that you shut down the IIS server in order to modify `appsetting.Production.json` settings under any circumstances. Parameters that are not documented in this page should not be changed. All parameters are **case sensitive**.
:::

## Settings Priority

Settings can be configured in multiple places. Here are the priorities used by Webhooks Service when determining the value of a setting, listed from high (1) to low (3):

1. Value within the `appsettings.Production.json` file
2. Value within the `appsettings.json` file
3. Default value setting within the code. Used only if a specific setting can't be found within `appsettings.Production.json` or `appsettings.json`.

## Settings

The `appsettings.json` file has an internal structure composed of multiple json sections separated by a comma.

### Orchestrator SQL Client Settings

```
"OrchestratorSqlClientSettings": {
    "ConnectionString": "<OrchestratorConnectionString>",
    "Enabled": true
  },
```

#### `ConnectionString`

The connection string as generated by the Orchestrator instance you want to connect to.

### Webhook Service Config

```
"WebhookServiceConfig": {
    "MaxWorkerCount": 10,
    "HttpClientUserAgent": "UiPath-WebhookService/Webhooks",
    "RequestTimeout": "0.00:01:00",
    "RetryAfter": [
      "0.00:00:0",
      "0.00:00:45",
      "0.00:02:30",
      "0.00:05:00"
    ],
    "MaxRetryRequests": 2    
    "SubscriberCircuitBreakerExpirationSeconds": 600
  },
```

#### `RequestsTimeout`

The amount of time after which each HTTP request is canceled. Please note that each request that times out is retried, according to the `RetryAfter` value. By default, the timeout time is set to 1 minute.

#### `RetryAfter`

The amount of time, in seconds, after each failed request is retried. By default, there are four retries defined as follows:

* The first retry request is executed immediately after the first attempt failed.
* The second retry is executed 45 seconds after the first retry fails.
* The third retry is executed 2 minutes and 30 seconds after the second one fails.
* The fourth retry is executed 5 minutes after the third one fails.

You can change the number of delays, if you list fewer entries or if you set the value of `MaxRetryRequests` to a smaller value. We **recommend** that you always set the first retry to 0, and never set time amounts greater than 300 seconds (5 minutes) in between retries.

#### `MaxRetryRequests`

The maximum number of retries to be performed on a failed request.

#### `MaxWorkerCount`

The maximum number of webhooks that can be enabled per tenant. By default, it is set to 10.

#### `SubscriberCircuitBreakerExpirationSeconds`

The amount of time, in seconds, during which webhooks stops sending messages to the subscriber that reported a failure. By default, the value is set to 600. If the value of the parameter is set to 0, this feature is disabled and failures are ignored. More information about how this pattern works can be found [here](https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker#:~:text=The%20Circuit%20Breaker%20pattern%20prevents%20an%20application%20from%20performing%20an%20operation%20that%20is%20likely%20to%20fail.%20An%20application%20can%20combine%20these%20two%20patterns%20by%20using%20the%20Retry%20pattern%20to%20invoke%20an%20operation%20through%20a%20circuit%20breaker.).

### Ledger Configuration

```
"LedgerConfiguration": {
    "Enabled": true,
    "Subscribers": [
      {
        "LedgerComponentType": 0,
        "ComponentId": "WebhookSubscriber",
        "Topics": null,
        "ConnectionString": "<OrchestratorConnectionString>",
        "EstablishNewConnection": false,
        "LedgerSubscriberDeliveryType": 1,
        "LedgerSubscriberReliability": 1,
        "Enabled": true,
        "LedgerComponentClassType": 2,
        "Context": "{\"BatchSize\": 500, \"DeliveriesBatchSize\": 500}"
      }
    ]
  },
```

:::note
The logging infrastructure is identical to that of the Orchestrator service.
:::

#### `ConnectionString`

The connection string as generated by the Orchestrator instance you want to connect to.

```
"ApplicationInsights": {
    "InstrumentationKey": "<AI_InstrumentationKey>"
  },
```

#### `InstrumentationKey`

Required if you are using Application Insights.

For more details, refer to the official [Create an Application Insights resource](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource) documentation.
