Tyk v2.2 Documentation Components

HomeTyk v2.2 Documentation ComponentsTutorial: Create API (CE: REST)

Tutorial: Create API (CE: REST)

In order to use the REST API you will need an API key for your gateway and one command to create the API and make it live.

Step 1: Make sure you know your API Secret:

Your Tyk Gateway API Secret is stored in your tyk.conf file, the property is called secret, you will need to use this as a header called x-tyk-authorization to make calls to the Gateway API.

Step 2. Create an API

To create the API, lets send a definition to the admin endpoint:

curl -H "x-tyk-authorization: {your-secret}"
 -H "Content-Type: application/json"
 -d '{
    "name": "Test API",
    "slug": "test-api",
    "api_id": "1",
    "org_id": "1",
    "auth": {
        "auth_header_name": "Authorization"
    "definition": {
        "location": "header",
        "key": "x-api-version"
    "version_data": {
        "not_versioned": true,
        "versions": {
            "Default": {
                "name": "Default",
                "use_extended_paths": true
    "proxy": {
        "listen_path": "/test-api/",
        "target_url": "http://httpbin.org/",
        "strip_listen_path": true
    "active": true
}' https://{your-tyk-host}:{port}/tyk/apis/ | python -mjson.tool

If the command succeeds, you will see:

    "action": "added",
    "key": "1",
    "status": "ok"

What did we just do?

We just sent an API Definition to the Tyk /apis endpoint, API Definitions are discussed in detail in the API Section of this documentation. These objects encapsulate all of the settings for an API within Tyk Gateway.

Was this article helpful to you? Yes No