> ## 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 Trace Settings

> Updates trace settings for an API proxy. Trace settings allow you to enable detailed request/response tracing for a specific environment within a defined time window.

## Endpoint

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

## 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}
{
  "enableTraceLog": true,
  "startTime": "2025-01-01T00:00:00Z",
  "stopTime": "2025-01-02T00:00:00Z",
  "environmentName": "production",
  "deploy": false,
  "deployTargetEnvironmentNameList": []
}
```

#### Request Body Fields

| Field                           | Type           | Required | Default | Description                                                                    |
| ------------------------------- | -------------- | -------- | ------- | ------------------------------------------------------------------------------ |
| enableTraceLog                  | boolean        | No       | false   | Enable or disable trace logging                                                |
| startTime                       | string         | No       | -       | Start time for trace logging in ISO 8601 format (e.g., `2025-01-01T00:00:00Z`) |
| stopTime                        | string         | No       | -       | Stop time for trace logging in ISO 8601 format (e.g., `2025-01-02T00:00:00Z`)  |
| environmentName                 | string         | No       | -       | Target environment name for trace logging                                      |
| 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. Omitted fields retain their current values.

## 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 | Indicates if the overall deployment was successful |
| deploymentResult.deploymentResults | array   | List of deployment results per environment         |

### Error Response (401 Unauthorized)

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

### Error Response (400 Bad Request)

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

## cURL Example

### Example 1: Enable Trace Logging with Time Window

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/trace/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "enableTraceLog": true,
    "startTime": "2025-01-01T00:00:00Z",
    "stopTime": "2025-01-02T00:00:00Z",
    "environmentName": "production"
  }'
```

### Example 2: Disable Trace Logging

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/trace/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "enableTraceLog": false
  }'
```

### Example 3: Update Only Environment

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/trace/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "environmentName": "staging"
  }'
```

### Example 4: Save and Deploy

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/trace/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "enableTraceLog": true,
    "startTime": "2025-01-01T00:00:00Z",
    "stopTime": "2025-01-02T00:00:00Z",
    "environmentName": "production",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"]
  }'
```

## Permissions

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

## Notes and Warnings

* **Partial Update**: Only provided fields are updated. You can send just the fields you want to change
* **Time Format**: `startTime` and `stopTime` must be in ISO 8601 format with timezone (e.g., `2025-01-01T00:00:00Z`)
* **Time Window**: Trace logging is active only between `startTime` and `stopTime`. Outside this window, trace logging is automatically inactive
* **Environment-Specific**: Trace logging is scoped to a specific environment. Set `environmentName` to target the desired environment
* **Performance Impact**: Trace logging captures detailed request/response data and may impact performance. Use time-bounded windows for production environments
* **Deploy**: When `deploy=true`, the API proxy is automatically deployed to the specified environments after saving

## Related Documentation

* [Update Traffic Log Settings](/api-reference/api-proxies/settings/update-traffic-log-settings) - Configure traffic logging settings
* [Update Maintenance Mode](/api-reference/api-proxies/settings/update-maintenance-mode) - Configure maintenance mode
* [Get API Proxy Detail](/api-reference/api-proxies/crud/get-api-proxy) - Get API proxy details
* [Deploy API Proxy](/api-reference/api-proxies/deployment/deploy-api-proxy) - Deploy API proxy to apply changes
