Skip to main content

Custom Response

Overview

The Custom Response policy action returns a hard-coded response back to the client that made a request to your endpoint.

Example

actions:
- type: custom-response
config:
status_code: 400
content: '{"error":{"message":"Bad Request"}}'
headers:
content-type: application/json

Behavior

When executed as an inbound policy, this action bypasses the upstream server and immediately returns to the caller with the configured response. When executed as an outbound policy, the response from the upstream server is overwritten with the configured response.

If this action is executed, no further actions in the traffic policy will be executed.

Reference

Supported Directions

  • Inbound
  • Outbound

Configuration

Type
custom-response
Parameter Description
status_codeintThe status code of the response.
contentstringThe body of the response.
headersMap<string, string>Headers to be added to the response. If content-type is not included in headers, this action will attempt to infer the correct content-type.