Kong Community Edition (KongCE) - update Consumer with an API Key using REST API

by
Jeremy Canfield |
Updated: February 12 2022
| Kong Community Edition (KongCE) articles
The curl POST command can be used to configure a consumer to use the key-auth plugin.
On the Kong server
If Kong is running on docker, refer to Kong - Docker container command line for the steps on how to issue commands in the Kong Docker container. Assuming you are using the default kong.conf file, the Kong Admin API will listen on port 8001.
If issuing this command on the Kong server, this command will configure consumer john.doe to use the key-auth plugin.
curl -X POST "http://localhost:8001/consumers/john.doe/key-auth" --data "key=some_random_string"
From a remote server
If issuing this command from a remote server, this command will create a consumer for the user john.doe.
curl -X POST "http://hostname:8000/admin-api/consumers/john.doe/key-auth" --data "key=some_random_string"
Validation
If the consumer was successfully updated, something like this should be displayed.
{
"created_at":1585018492,
"consumer":{"id":"6b3f8801-a8a2-4e48-ab54-53bdb285c334"},
"id":"7fac58ad-73ac-4dd3-a1f4-513711764d26",
"tags":null,
"ttl":null,
"key":"abc123"
}
Did you find this article helpful?
If so, consider buying me a coffee over at