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.
Endpoint
PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/json-error-template/
Authentication
Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN
Request
| Header | Value | Required |
|---|
| Authorization | Bearer | 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
| 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 provided fields are updated.
Response
Success Response (200 OK)
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)
{
"error": "bad_request",
"error_description": "Invalid JSON template"
}
Error Response (401 Unauthorized)
{
"error": "unauthorized_client",
"error_description": "Invalid token"
}
Error Response (404 Not Found)
{
"error": "not_found",
"error_description": "ApiProxy (name: MyAPI) was not found!"
}
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"]
}'
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=true to 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.