> ## 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 Proxy Server Settings

> Updates proxy server settings for an API proxy. Proxy server settings configure how the API proxy connects to backend services through a proxy.

## Endpoint

```
PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/proxy-server/
```

## 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}
{
  "proxyEnabled": true,
  "proxyFromHeaderEnabled": false,
  "proxyHost": "proxy.example.com",
  "proxyPort": 8080,
  "proxyAuthorizationNeeded": true,
  "proxyUsername": "proxy-user",
  "proxyPassword": "proxy-pass",
  "deploy": false,
  "deployTargetEnvironmentNameList": []
}
```

#### Request Body Fields

| Field                           | Type           | Required | Default | Description                                                                            |
| ------------------------------- | -------------- | -------- | ------- | -------------------------------------------------------------------------------------- |
| proxyEnabled                    | boolean        | No       | -       | Enable/disable proxy server                                                            |
| proxyFromHeaderEnabled          | boolean        | No       | -       | Get proxy settings from request headers                                                |
| proxyHost                       | string         | No\*     | -       | Proxy server hostname (required if proxyEnabled=true and proxyFromHeaderEnabled=false) |
| proxyPort                       | integer        | No\*     | -       | Proxy server port (required if proxyEnabled=true and proxyFromHeaderEnabled=false)     |
| proxyAuthorizationNeeded        | boolean        | No       | -       | Require proxy authentication                                                           |
| proxyUsername                   | string         | No\*     | -       | Proxy username (required if proxyAuthorizationNeeded=true)                             |
| proxyPassword                   | string         | No\*     | -       | Proxy password (required if proxyAuthorizationNeeded=true)                             |
| deploy                          | boolean        | No       | false   | If true, deploy the API proxy after saving changes                                     |
| deployTargetEnvironmentNameList | array\[string] | No       | -       | List of environment names to deploy to (required when deploy=true)                     |

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

### Proxy from Header

When `proxyFromHeaderEnabled=true`, proxy settings are read from request headers:

* `X-Proxy-Host` - Proxy hostname
* `X-Proxy-Port` - Proxy port
* `X-Proxy-Authorization` - Proxy authorization (Basic auth token)

## Response

### Success Response (200 OK)

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

#### Response Fields

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

When `deploy=true` is specified:

```json theme={null}
{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}
```

| Field                              | Type    | Description                        |
| ---------------------------------- | ------- | ---------------------------------- |
| deploymentResult                   | object  | Only present when deploy=true      |
| deploymentResult.success           | boolean | Overall deployment success status  |
| deploymentResult.deploymentResults | array   | Per-environment deployment results |

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "Proxy host and port are required when proxy is enabled"
}
```

### 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 Proxy Server

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/proxy-server/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "proxyEnabled": true,
    "proxyFromHeaderEnabled": false,
    "proxyHost": "proxy.example.com",
    "proxyPort": 8080,
    "proxyAuthorizationNeeded": true,
    "proxyUsername": "proxy-user",
    "proxyPassword": "proxy-pass"
  }'
```

### Example 2: Configure Proxy from Headers

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/proxy-server/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "proxyEnabled": true,
    "proxyFromHeaderEnabled": true,
    "proxyAuthorizationNeeded": true
  }'
```

### Example 3: Save and Deploy

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/proxy-server/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "proxyEnabled": true,
    "proxyHost": "proxy.example.com",
    "proxyPort": 8080,
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"]
  }'
```

## Notes and Warnings

* **Proxy Host/Port**: Required when `proxyEnabled=true` and `proxyFromHeaderEnabled=false`
* **Proxy from Header**: When enabled, proxy settings are read from request headers per request
* **Authorization**: When `proxyAuthorizationNeeded=true`, provide `proxyUsername` and `proxyPassword` (or use header)
* **Password Security**: Proxy password is encrypted when stored
* **Deploy**: When `deploy=true`, the API proxy is automatically deployed to the specified environments after saving

## Permissions

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

## Related Documentation

* [Update Connection Settings](/api-reference/api-proxies/settings/update-connection-settings) - Update connection settings
* [Get API Proxy](/api-reference/api-proxies/crud/get-api-proxy) - Get API proxy details
