Update JSON Error Response Template
Endpoint
PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/json-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
{
"jsonErrorResponseTemplate": {
"jsonErrorResponseTemplateActive": true,
"jsonValue": "{\n \"fault\": {\n \"correlationId\": \"#CORRELATIONID#\",\n \"faultCode\": \"#FAULTCODE#\",\n \"faultString\": \"#FAULTMESSAGE#\",\n \"faultStatusCode\": \"#FAULTSTATUSCODE#\",\n \"responseFromApi\": \"#RESPONSEFROMAPI#\"\n }\n}",
"contentType": "application/json;charset=UTF-8",
"permitSpecialChars": false
},
"deploy": false,
"deployTargetEnvironmentNameList": []
}
Request Body Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| jsonErrorResponseTemplate | object | Yes | - | JSON 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) |
jsonErrorResponseTemplate Fields
Only the fields present in jsonErrorResponseTemplate are applied. An omitted field (or one sent as null) keeps its stored value, so a call that changes one setting never resets the others — a customised jsonValue survives a call that only flips jsonErrorResponseTemplateActive. The Default column below is what a newly created template starts with, not what an omitted field falls back to on update. An explicit false or an empty string is applied as sent. Unrecognised fields are ignored, so a client that reads the object and posts the whole thing back keeps working unchanged.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| jsonErrorResponseTemplateActive | boolean | No | false | Enable/disable JSON error template |
| jsonValue | string | No | - | JSON error response template |
| contentType | string | No | application/json;charset=UTF-8 | Content type for error response |
| permitSpecialChars | boolean | No | false | Permit special characters in template |
Template Variables
The JSON 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
{
"fault": {
"correlationId": "#CORRELATIONID#",
"faultCode": "#FAULTCODE#",
"faultString": "#FAULTMESSAGE#",
"faultStatusCode": "#FAULTSTATUSCODE#",
"responseFromApi": "#RESPONSEFROMAPI#"
}
}
Note: All fields are optional. Only the fields you send are updated; every field you leave out keeps its stored value.
Response
Success Response (200 OK)
{
"success": true
}
Response Fields
| Field | Type | Description |
|---|---|---|
| success | boolean | Indicates if the request was successful |
When deploy=true is specified:
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
| Field | Type | Description |
|---|---|---|
| deploymentResult | object | Deployment result (present when deploy=true) |
| deploymentResult.success | boolean | Overall deployment success status |
| deploymentResult.deploymentResults | array | Per-environment deployment results |
Error Response (400 Bad Request)
{
"status": "FAILURE",
"resultMessage": "Invalid JSON template"
}
Error Response (401 Unauthorized)
{
"status": "FAILURE",
"resultMessage": "Token is not valid!"
}
cURL Example
Example 1: Enable JSON Error Template
curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/json-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonErrorResponseTemplate": {
"jsonErrorResponseTemplateActive": true,
"jsonValue": "{\n \"fault\": {\n \"correlationId\": \"#CORRELATIONID#\",\n \"faultCode\": \"#FAULTCODE#\",\n \"faultString\": \"#FAULTMESSAGE#\",\n \"faultStatusCode\": \"#FAULTSTATUSCODE#\"\n }\n}",
"contentType": "application/json;charset=UTF-8"
}
}'
Example 2: Custom JSON Error Template
curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/json-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonErrorResponseTemplate": {
"jsonErrorResponseTemplateActive": true,
"jsonValue": "{\n \"error\": {\n \"id\": \"#CORRELATIONID#\",\n \"code\": \"#FAULTCODE#\",\n \"message\": \"#FAULTMESSAGE#\",\n \"status\": #FAULTSTATUSCODE#\n }\n}",
"contentType": "application/json;charset=UTF-8",
"permitSpecialChars": true
}
}'
Example 3: Save and Deploy
curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/json-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonErrorResponseTemplate": {
"jsonErrorResponseTemplateActive": true,
"jsonValue": "{\n \"fault\": {\n \"correlationId\": \"#CORRELATIONID#\",\n \"faultCode\": \"#FAULTCODE#\",\n \"faultString\": \"#FAULTMESSAGE#\",\n \"faultStatusCode\": \"#FAULTSTATUSCODE#\"\n }\n}",
"contentType": "application/json;charset=UTF-8"
},
"deploy": true,
"deployTargetEnvironmentNameList": ["production"]
}'
Example 4: Change One Field (Partial Update)
Only the field in the body is written. The stored jsonValue, permitSpecialChars and
jsonErrorResponseTemplateActive are left exactly as they were.
curl -X PATCH \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/json-error-template/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonErrorResponseTemplate": {
"contentType": "application/problem+json;charset=UTF-8"
}
}'
Notes and Warnings
- Template Variables: Use
#VARIABLE#syntax for runtime replacement - JSON Format: Template must be valid JSON (use escaped quotes in string)
- Content Type: Default is
application/json;charset=UTF-8 - Special Characters: When
permitSpecialChars=true, special characters are not escaped - Active Flag: Set
jsonErrorResponseTemplateActive=trueto enable template - REST APIs: Primarily used for REST/JSON APIs
- 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.