> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Connection Settings

> Updates connection settings for an API proxy. Connection settings control timeout, redirect, connection pool, and header forwarding behavior.

## Endpoint

```
PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/connection/
```

## Authentication

Requires a Personal API Access Token.

### Header

```
Authorization: Bearer YOUR_TOKEN
```

## Request

### Headers

| Header        | Value            | Required |
| ------------- | ---------------- | -------- |
| Authorization | Bearer {token}   | Yes      |
| Content-Type  | application/json | Yes      |

### Path Parameters

| Parameter    | Type   | Required | Description    |
| ------------ | ------ | -------- | -------------- |
| projectName  | string | Yes      | Project name   |
| apiProxyName | string | Yes      | API Proxy name |

### Request Body

#### Full JSON Body Example

```json theme={null}
{
  "connectTimeout": 30,
  "readTimeout": 60,
  "connectionRequestTimeout": 30,
  "validateAfterInactivity": 2000,
  "idleConnectionTimeout": 30,
  "redirectsEnabled": true,
  "maxRedirects": 50,
  "relativeRedirectsAllowed": true,
  "disableContentCompression": false,
  "enableStreaming": false,
  "ignoreRoutingError": false,
  "connectionPoolManagementType": "GENERAL",
  "customConnectionPoolSize": 8,
  "hopByHopHeaders": ["X-Custom-Internal"],
  "sendUserAgentToBackend": true,
  "userAgentValue": "Apinizer-Gateway/1.0",
  "doNotRouteZeroValueContentLength": false,
  "enableDownload": false,
  "useByteArrayForCompressedResponse": false
}
```

#### Request Body Fields

| Field                             | Type           | Required | Default | Description                                                                                                |
| --------------------------------- | -------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| connectionSettingsEnabled         | boolean        | No       | -       | Enable/disable custom connection settings                                                                  |
| connectTimeout                    | integer        | No       | -       | Connection timeout in seconds                                                                              |
| readTimeout                       | integer        | No       | -       | Read timeout in seconds                                                                                    |
| connectionRequestTimeout          | integer        | No       | -       | Connection request timeout in seconds                                                                      |
| validateAfterInactivity           | integer        | No       | 2000    | Validate connections after inactivity (milliseconds). Tune per backend load balancer keep-alive timeout.   |
| idleConnectionTimeout             | integer        | No       | 30      | Evict idle connections after this period (seconds). Tune per backend load balancer keep-alive timeout.     |
| redirectsEnabled                  | boolean        | No       | -       | Enable/disable HTTP redirects                                                                              |
| maxRedirects                      | integer        | No       | -       | Maximum number of redirects                                                                                |
| relativeRedirectsAllowed          | boolean        | No       | -       | Allow relative redirects                                                                                   |
| disableContentCompression         | boolean        | No       | -       | Disable content compression                                                                                |
| enableStreaming                   | boolean        | No       | -       | Enable streaming mode                                                                                      |
| ignoreRoutingError                | boolean        | No       | -       | Ignore routing errors                                                                                      |
| connectionPoolManagementType      | string         | No       | -       | Connection pool management type. See [EnumConnectionPoolManagementType](#enumconnectionpoolmanagementtype) |
| customConnectionPoolSize          | integer        | No\*     | -       | Custom connection pool size (required if connectionPoolManagementType=CUSTOM)                              |
| hopByHopHeaders                   | array\[string] | No       | -       | List of hop-by-hop headers to remove before forwarding to backend                                          |
| sendUserAgentToBackend            | boolean        | No       | -       | Send User-Agent header to backend                                                                          |
| userAgentValue                    | string         | No       | -       | Custom User-Agent header value (used when sendUserAgentToBackend=true)                                     |
| doNotRouteZeroValueContentLength  | boolean        | No       | -       | Do not route requests with Content-Length: 0                                                               |
| enableDownload                    | boolean        | No       | -       | Enable file download support for large response bodies                                                     |
| useByteArrayForCompressedResponse | boolean        | No       | -       | Use byte array for compressed response handling                                                            |

### EnumConnectionPoolManagementType

* `GENERAL` - General connection pool (shared pool)
* `CUSTOM` - Custom connection pool (requires customConnectionPoolSize)
* `NONE` - No connection pool

**Note:** All fields are optional. Only provided fields are updated.

## Response

### Success Response (200 OK)

```json theme={null}
{
  "success": true
}
```

#### Response Fields

| Field   | Type    | Description                             |
| ------- | ------- | --------------------------------------- |
| success | boolean | Indicates if the request was successful |

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "Custom connection pool size is required when connectionPoolManagementType is CUSTOM"
}
```

### Error Response (401 Unauthorized)

```json theme={null}
{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}
```

### Error Response (404 Not Found)

```json theme={null}
{
  "error": "not_found",
  "error_description": "ApiProxy (name: MyAPI) was not found!"
}
```

## cURL Example

### Example 1: Configure Connection Timeouts

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionSettingsEnabled": true,
    "connectTimeout": 30,
    "readTimeout": 60,
    "connectionRequestTimeout": 30
  }'
```

### Example 2: Configure Custom Connection Pool

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionSettingsEnabled": true,
    "connectionPoolManagementType": "CUSTOM",
    "customConnectionPoolSize": 20,
    "connectTimeout": 60,
    "readTimeout": 120
  }'
```

### Example 3: Configure Connection Pool Stale/Idle Handling

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionSettingsEnabled": true,
    "validateAfterInactivity": 2000,
    "idleConnectionTimeout": 30
  }'
```

### Example 4: Configure Header and Response Settings

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "hopByHopHeaders": ["X-Internal-Trace", "X-Debug-Info"],
    "sendUserAgentToBackend": true,
    "userAgentValue": "Apinizer-Gateway/1.0",
    "enableDownload": true
  }'
```

## Notes and Warnings

* **Timeouts**: Connection and read timeouts are in seconds; validateAfterInactivity is in milliseconds
* **Connection Pool**: validateAfterInactivity and idleConnectionTimeout help prevent stale connection issues; tune per backend load balancer keep-alive timeout
* **Connection Pool**: `CUSTOM` requires `customConnectionPoolSize` to be set
* **Redirects**: When `redirectsEnabled=true`, HTTP redirects are followed (max `maxRedirects`)
* **Streaming**: When `enableStreaming=true`, response is streamed instead of buffered
* **Content Compression**: When `disableContentCompression=true`, content compression is disabled
* **Hop-by-Hop Headers**: Headers listed in `hopByHopHeaders` are removed before the request is forwarded to the backend
* **User-Agent**: When `sendUserAgentToBackend=true`, the specified `userAgentValue` is sent as the User-Agent header to the backend
* **Download Mode**: When `enableDownload=true`, the gateway handles large response bodies as file downloads

## Permissions

User must have **`API_MANAGEMENT` + `MANAGE`** permission in the project.

## Related Documentation

* [Update Circuit Breaker Settings](/api-reference/api-proxies/settings/update-circuit-breaker-settings) - Update circuit breaker settings
* [Update Routing Addresses](/api-reference/api-proxies/settings/update-routing-addresses) - Update routing addresses
* [Get API Proxy](/api-reference/api-proxies/crud/get-api-proxy) - Get API proxy details
