Contact Free trial Login

Traits & policies concepts of RAML based APIs

If your API exposes a RAML definition that users might need to reference, then the RAML definition should reliably detail every element that is expected in calls to your API. For example when applying a client ID-based policies implies that all requests coming to your API include a client ID and client Secret (by default expected as query parameters). To prevent user requests from being rejected, create a trait in the RAML root and then reference this trait in every operation of your API. The trait might look like this:

  - client-id-required:
          type: string
          type: string

And then you can apply this trait in each individual operation like this:

    is: [client-id-required]
    description: Gets a list of all the inventory products.
  1. Click Policies on the API dashboard.

    In the list of policies, the RAML snippet link contains the RAML code you need to add to the RAML.

    raml snippet
  2. Click RAML Snippet.

    snippet rate limiting
  3. Select RAML 0.8 or RAML 1.0 to match the API RAML version.

  4. Edit the API to add the code.

  5. Redeploy the API.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.