> ## 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 XML Error Response Template

> Updates XML error response template for an API proxy. XML error template defines the format of error responses for SOAP/XML APIs.

## Endpoint

```
PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/xml-error-template/
```

## 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}
{
  "xmlErrorResponseTemplate": {
    "xmlErrorResponseTemplateActive": true,
    "xmlValue": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body>\n    <soap:Fault>\n      <correlationId>#CORRELATIONID#</correlationId>\n      <faultCode>#FAULTCODE#</faultCode>\n      <faultString>#FAULTMESSAGE#</faultString>\n      <faultStatusCode>#FAULTSTATUSCODE#</faultStatusCode>\n      <responseFromApi>#RESPONSEFROMAPI#</responseFromApi>\n    </soap:Fault>\n  </soap:Body>\n</soap:Envelope>",
    "contentType": "text/xml;charset=UTF-8",
    "permitSpecialChars": false
  },
  "deploy": false,
  "deployTargetEnvironmentNameList": []
}
```

#### Request Body Fields

| Field                           | Type           | Required | Default | Description                                                        |
| ------------------------------- | -------------- | -------- | ------- | ------------------------------------------------------------------ |
| xmlErrorResponseTemplate        | object         | Yes      | -       | XML error template object (see fields below)                       |
| 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) |

#### xmlErrorResponseTemplate Fields

| Field                          | Type    | Required | Default                | Description                           |
| ------------------------------ | ------- | -------- | ---------------------- | ------------------------------------- |
| xmlErrorResponseTemplateActive | boolean | No       | false                  | Enable/disable XML error template     |
| xmlValue                       | string  | No       | -                      | XML error response template           |
| contentType                    | string  | No       | text/xml;charset=UTF-8 | Content type for error response       |
| permitSpecialChars             | boolean | No       | false                  | Permit special characters in template |

### Template Variables

The XML template can use the following variables (replaced at runtime):

* `#CORRELATIONID#` - Request correlation ID
* `#FAULTCODE#` - Error fault code
* `#FAULTMESSAGE#` - Error fault message
* `#FAULTSTATUSCODE#` - HTTP status code
* `#RESPONSEFROMAPI#` - Response from backend API (if available)

### Default Template

```xml theme={null}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
        <correlationId>#CORRELATIONID#</correlationId>
        <faultCode>#FAULTCODE#</faultCode>
        <faultString>#FAULTMESSAGE#</faultString>
        <faultStatusCode>#FAULTSTATUSCODE#</faultStatusCode>
        <responseFromApi>#RESPONSEFROMAPI#</responseFromApi>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
```

**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 |

When `deploy=true` is specified:

```json theme={null}
{
  "success": true,
  "deploymentResult": {
    "deployed": true,
    "deployedEnvironments": ["Production", "Staging"],
    "failedEnvironments": []
  }
}
```

#### Deployment Response Fields

| Field                                 | Type           | Description                                               |
| ------------------------------------- | -------------- | --------------------------------------------------------- |
| success                               | boolean        | Indicates if the request was successful                   |
| deploymentResult                      | object         | Deployment result details (only present when deploy=true) |
| deploymentResult.deployed             | boolean        | Whether deployment was successful                         |
| deploymentResult.deployedEnvironments | array\[string] | List of environments where deployment succeeded           |
| deploymentResult.failedEnvironments   | array\[string] | List of environments where deployment failed              |

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "Invalid XML template"
}
```

### 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: Enable XML Error Template

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "xmlErrorResponseTemplate": {
      "xmlErrorResponseTemplateActive": true,
      "xmlValue": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body>\n    <soap:Fault>\n      <correlationId>#CORRELATIONID#</correlationId>\n      <faultCode>#FAULTCODE#</faultCode>\n      <faultString>#FAULTMESSAGE#</faultString>\n    </soap:Fault>\n  </soap:Body>\n</soap:Envelope>",
      "contentType": "text/xml;charset=UTF-8"
    }
  }'
```

### Example 2: Custom XML Error Template

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "xmlErrorResponseTemplate": {
      "xmlErrorResponseTemplateActive": true,
      "xmlValue": "<error xmlns=\"http://example.com/error\">\n  <id>#CORRELATIONID#</id>\n  <code>#FAULTCODE#</code>\n  <message>#FAULTMESSAGE#</message>\n  <status>#FAULTSTATUSCODE#</status>\n</error>",
      "contentType": "application/xml;charset=UTF-8",
      "permitSpecialChars": true
    }
  }'
```

### Example 3: Save and Deploy

```bash theme={null}
curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/xml-error-template/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "xmlErrorResponseTemplate": {
      "xmlErrorResponseTemplateActive": true,
      "xmlValue": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body>\n    <soap:Fault>\n      <correlationId>#CORRELATIONID#</correlationId>\n      <faultCode>#FAULTCODE#</faultCode>\n      <faultString>#FAULTMESSAGE#</faultString>\n      <faultStatusCode>#FAULTSTATUSCODE#</faultStatusCode>\n    </soap:Fault>\n  </soap:Body>\n</soap:Envelope>",
      "contentType": "text/xml;charset=UTF-8"
    },
    "deploy": true,
    "deployTargetEnvironmentNameList": ["Production"]
  }'
```

## Notes and Warnings

* **Template Variables**: Use `#VARIABLE#` syntax for runtime replacement
* **XML Format**: Template must be valid XML
* **Content Type**: Default is `text/xml;charset=UTF-8` for SOAP
* **Special Characters**: When `permitSpecialChars=true`, special characters are not escaped
* **Active Flag**: Set `xmlErrorResponseTemplateActive=true` to enable template
* **SOAP APIs**: Primarily used for SOAP/XML APIs
* **Deploy**: When `deploy=true`, the API proxy is automatically deployed after saving. Provide `deployTargetEnvironmentNameList` with target environment names

## Permissions

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

## Related Documentation

* [Update JSON Error Template](/api-reference/api-proxies/settings/update-json-error-template) - Update JSON error template
* [Get API Proxy](/api-reference/api-proxies/crud/get-api-proxy) - Get API proxy details
