
A consumer is typically thought of as a person that has been associated with one or more plugins, as a way to allow a request to be submitted to a route and then onto a service. For example, a consumer could be associated wtih the API Key and ACL Group plugins, so that the consumer must present a certain API Key and be a member of the ACL group to be allowed to submit a request onto the route and then onto the service.
The curl POST command can be used to create a consumer.
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 create a consumer for the user john.doe.
curl -X POST "http://localhost:8001/consumers/" --data "username=john.doe"
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/" --data "username=john.doe"
Validation
If the consumer was successfully created, something like this should be displayed.
{
"custom_id":null,
"created_at":1584590186,
"id":"e86ef3ad-54c7-4bde-b8f7-5cf8235e2653",
"tags":null,
"username":"john.doe"
}
Did you find this article helpful?
If so, consider buying me a coffee over at