This plugin terminates incoming requests with a specified status code and message. This allows to (temporarily) block an API or Consumer.


Configuration

Configuring the plugin is straightforward, you can add it on top of an API by executing the following request on your Kong server:

$ curl -X POST http://kong:8001/apis/{api}/plugins \
    --data "name=request-termination" \
    --data "config.status_code=403" \
    --data "config.message=So long and thanks for all the fish!"

api: The id or name of the API that this plugin configuration will target

form parameter default description
name The name of the plugin to use, in this case: request-termination.
config.status_code
optional
503 The response code to send.
config.message
optional
The message to send, if using the default response generator.
config.body
optional
The raw response body to send, this is mutually exclusive with the config.message field.
config.content_type
optional
application/json; charset=utf-8 Content type of the raw response configured with config.body.

You can also apply it for every API or only on a specific Consumer by using the http://kong:8001/plugins/ endpoint. Read the Plugin Reference for more information.

Once applied, every request (within the configured plugin scope of an API, Consumer, or global) will be immediately terminated by sending the configured response.


Example Use Cases

  • Temporarily disable an API (ex: maintenance mode).
  • Temporarily disable a Consumer (ex: excessive consumption).
  • Block anonymous access with multiple auth plugins in a logical OR setup.

Keep up with the latest features