Create Or Update Plugin Associated to a Specific Route
PUT {{gateway}}/routes/:routeNameOrId/plugins/:pluginId
Create Or Update Plugin Associated to a Specific Route konghq
- Inserts (or replaces) the Plugin under the requested resource with the definition specified in the body. The Plugin will be identified via the name or id attribute.
- When the name or id attribute has the structure of a UUID, the Plugin being inserted/replaced will be identified by its id. Otherwise it will be identified by its name.
- When creating a new Plugin without specifying id (neither in the URL nor in the body), then it will be auto-generated.
- Notice that specifying a name in the URL and a different one in the request body is not allowed.
Attributes | Mandatory | Description |
---|
route name or id | required | The unique identifier or the name of the Route to update. |
plugin id | required | The unique identifier of the Plugin to update. |
Request Body
Attributes | Mandatory | Description |
---|
name | required | The name of the Plugin that’s going to be added. Currently the Plugin must be installed in every Kong instance separately. |
route | optional | If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the Route being used. Defaults to null.With form-encoded, the notation is route.id= or route.name=. With JSON, use “"route":{"id":""} or "route":{"name":""}. |
service | optional | If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched. Defaults to null.With form-encoded, the notation is service.id= or service.name=. With JSON, use “"service":{"id":""} or "service":{"name":""}. |
consumer | optional | If set, the plugin will activate only for requests where the specified has been authenticated. (Note that some plugins can not be restricted to consumers this way.). Leave unset for the plugin to activate regardless of the authenticated consumer. Defaults to null.With form-encoded, the notation is consumer.id= or consumer.username=. With JSON, use “"consumer":{"id":""} or "consumer":{"username":""}. |
config | optional | The configuration properties for the Plugin which can be found on the plugins documentation page in the Kong Hub. |
protocols | required | A list of the request protocols that will trigger this plugin. The default value, as well as the possible values allowed on this field, may change depending on the plugin type. For example, plugins that only work in stream mode will only support "tcp" and "tls". Defaults to ["grpc", "grpcs", "http", "https"]. |
enabled | optional | Whether the plugin is applied. Defaults to true. |
tags | optional | An optional set of strings associated with the Plugin, for grouping and filtering. |
Request Body
{"config"=>{"minute"=>20, "policy"=>"cluster", "month"=>nil, "redis_timeout"=>2000, "limit_by"=>"consumer", "hide_client_headers"=>false, "second"=>nil, "day"=>nil, "redis_password"=>nil, "year"=>nil, "redis_database"=>0, "hour"=>500, "redis_port"=>6379, "redis_host"=>nil, "fault_tolerant"=>true}, "service"=>nil, "enabled"=>true, "protocols"=>["https", "http"], "name"=>"rate-limiting", "consumer"=>nil, "route"=>{"id"=>"875973fd-ba3f-4c7b-8301-e9263013e6d2"}, "tags"=>["admin", "high-priority", "critical"]}
Key | Datatype | Required | Description |
---|
Content-Type | string | | |
RESPONSES
status: OK
{"config":{"minute":20,"policy":"cluster","month":null,"redis_timeout":2000,"limit_by":"consumer","hide_client_headers":false,"second":null,"day":null,"redis_password":null,"year":null,"redis_database":0,"hour":500,"redis_port":6379,"redis_host":null,"fault_tolerant":true},"service":null,"enabled":true,"protocols":["https","http"],"name":"rate-limiting","consumer":null,"route":{"id":"875973fd-ba3f-4c7b-8301-e9263013e6d2"},"tags":["admin","high-priority","critical"]}