---
schema_version: "1"
id: 0ffa353926762ea257646611eba17787a1962bfcfa2f35fc15f8d8c810e26322
title: Traits & policies concepts of RAML/OAS based APIs
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-manager/latest/prepare-raml-task.md
canonical_url: https://docs.mulesoft.com/api-manager/latest/prepare-raml-task
source_site: docs.mulesoft.com
content_type: documentation
content_hash: dc2a46c6ad069bd1262813b4733420259a8d2d20480cd22b3da9f02ccf31d604
description: MuleSoft Documentation Site
release: 2.x
latest: true
---
---
product: API Manager
version: 2.x
is-latest-version: true
---

# Traits & policies concepts of RAML/OAS based APIs

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

If your API exposes a RAML or OAS definition that users might need to reference, then the API
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:

```yaml
traits:
  - client-id-required:
      queryParameters:
        client_id:
          type: string
        client_secret:
          type: string
```

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

```yaml
/products:
  get:
    is: [client-id-required]
    description: Gets a list of all the inventory products.
```

## Getting Policies Specification Snippets

1.  Click **Policies** on the API dashboard.

    In the list of policies, the RAML snippet link contains the RAML trait or OAS components you
    need to add to the API specification.

    ![The API Manager Policies page.](/mulesoft/current/en-us/api-manager/latest/_images/raml-snippet.png)

2.  Click **API Specification Snippet**.

3.  Select the API type to match your specification:

    - RAML 0.8 or RAML 1.0 to match the API RAML version.

      ![The API Specification Snippet page with RAML 0.8 selected.](/mulesoft/current/en-us/api-manager/latest/_images/snippet-rate-limiting.png)

    - Or OAS 2.0 to match the API OAS version.

      ![The API Specification Snippet page with OAS 2.0 selected.](/mulesoft/current/en-us/api-manager/latest/_images/prepare-raml-task-2b676.png)

      OAS Snippets are not displayed for all policy versions.  
      See the table below to see the policies and the versions that display their OAS snippets:

      <table><colgroup><col> <col></colgroup><thead><tr><th>Policy</th><th>Version</th></tr></thead><tbody><tr><td><div><div><p>Rate limiting - SLA based</p></div></div></td><td><div><div><p>since v1.1.2</p></div></div></td></tr><tr><td><div><div><p>OAuth 2.0 access token enforcement using Mule OAuth provider</p></div></div></td><td><div><div><p>since v1.1.3</p></div></div></td></tr><tr><td><div><div><p>OpenAM access token enforcement</p></div></div></td><td><div><div><p>since v1.1.3</p></div></div></td></tr><tr><td><div><div><p>OpenId Connect access token enforcement</p></div></div></td><td><div><div><p>since v1.1.3</p></div></div></td></tr><tr><td><div><div><p>PingFederate access token enforcement</p></div></div></td><td><div><div><p>since v1.1.3</p></div></div></td></tr><tr><td><div><div><p>Client ID enforcement</p></div></div></td><td><div><div><p>since v1.1.3</p></div></div></td></tr></tbody></table>

4.  Edit the API to add the code.

5.  Redeploy the API.

## See Also

- [Provided Policies](https://docs.mulesoft.com/gateway-home/)

- [Custom Policies](https://docs.mulesoft.com/gateway/latest/policies-custom-overview)
