Tyk v2.2 Documentation Components

  1. Home
  2. Tyk v2.2 Documentation Components
  3. Tutorial: Create a Policy (CE)

Tutorial: Create a Policy (CE)

Adding a policy to a file-based (Community Edition) Tyk Gateway is very easy. Polices are loaded into memory on load and so need to be specified in advanced in a file called policies.json. To add a policy, simply create or edit the /policies/policies.json file and add the policy object to the object array:

{
    "POLICYID": {
        "access_rights": {
            "{API-ID}": {
                "allowed_urls": [],
                "api_id": "{API-ID}",
                "api_name": "{API-NAME}",
                "versions": [
                    "Default"
                ]
            }
        },
        "active": true,
        "name": "POLICY NAME",
        "rate": 100,
        "per": 1,
        "quota_max": 10000,
        "quota_renewal_rate": 3600,
        "tags": ["Startup Users"]
    }
}

The above creates a new policy with a policy ID that you can define, with the rate limits, and security profile that grants access to the APIs listed in the access_rights section.