Careful! You are browsing documentation for an outdated version of Kong. Go here to browse the documentation for the latest version.

Adding your API

Before you start:
  1. Make sure you've installed Kong — It should only take a minute!
  2. Make sure you've started Kong.

In this section, you'll be adding your API to the Kong layer. This is the first step to having Kong manage your API. Kong exposes a RESTful Admin API for managing the details of your Kong instances.

  1. Add your API using the RESTful API

    Issue the following cURL request to add your first API (Mockbin) to Kong:

    $ curl -i -X POST \
      --url http://localhost:8001/apis/ \
      --data 'name=mockbin' \
      --data 'upstream_url=' \
      --data ''

    Note: Kong handles API configuration requests on port :8001

  2. Verify that your API has been added

    For security reasons we suggest enabling the Request Size Limiting plugin for any API you add to Kong to prevent a DOS (Denial of Service) attack.

    You should see a similar response from the initial request:

    HTTP/1.1 201 Created
    Content-Type: application/json
    Connection: keep-alive
      "request_host": "",
      "upstream_url": "",
      "id": "2eec1cb2-7093-411a-c14e-42e67142d2c4",
      "created_at": 1428456369000,
      "name": "mockbin"

    Kong is now aware of your API and ready to proxy requests.

  3. Forward your requests through Kong

    Issue the following cURL request to verify that Kong is properly forwarding requests to your API:

    $ curl -i -X GET \
      --url http://localhost:8000/ \
      --header 'Host:'

    A successful response means Kong is now forwarding requests to the upstream_url we passed in the first step and giving us the response back. Kong knows to do this through the header defined in the above cURL request:

    • Host: <request_host>

    Note: Kong handles proxy requests on port :8000

Next Steps

Now that you've got your API added to Kong lets learn how to enable plugins.

Go to Enabling Plugins ›

Keep up with the latest features