Ana içeriğe atla

Endpoint

PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/custom-message/

Authentication

Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Request Body

Full JSON Body Example

{
  "buildCustomMessage": true,
  "customMessageTemplate": "{\"status\": \"ok\", \"message\": \"Service is running\"}",
  "customMessageContentType": "application/json",
  "customMessageHttpStatusCode": 200
}

Request Body Fields

FieldTypeRequiredDefaultDescription
buildCustomMessagebooleanNofalseEnable custom response message building
customMessageTemplatestringNo-Response body template (supports variables)
customMessageContentTypestringNo-Content-Type header for the custom response
customMessageHttpStatusCodeintegerNo-HTTP status code for the custom response
Note: All fields are optional. Only provided fields are updated.

Response

Success Response (200 OK)

{
  "success": true
}

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 Custom JSON Response

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/custom-message/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "buildCustomMessage": true,
    "customMessageTemplate": "{\"status\": \"ok\", \"version\": \"1.0\"}",
    "customMessageContentType": "application/json",
    "customMessageHttpStatusCode": 200
  }'

Example 2: Enable Custom XML Response

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/custom-message/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "buildCustomMessage": true,
    "customMessageTemplate": "<response><status>ok</status><message>Service healthy</message></response>",
    "customMessageContentType": "application/xml",
    "customMessageHttpStatusCode": 200
  }'

Example 3: Disable Custom Message (Resume Normal Routing)

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/custom-message/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "buildCustomMessage": false
  }'

Notes and Warnings

  • Custom Message Mode: When buildCustomMessage=true, the gateway returns the custom response template instead of routing to backend
  • Template Variables: The template supports Apinizer variables (e.g., ${request_httpMethod}, ${request_uri}) that are resolved at runtime
  • Content Type: Set customMessageContentType to match your template format (e.g., application/json, application/xml, text/plain)
  • HTTP Status Code: The customMessageHttpStatusCode overrides the default 200 status code
  • Use Cases: Health check endpoints, mock responses, maintenance responses, API versioning redirects

Permissions

User must have API_MANAGEMENT + MANAGE permission in the project.