---
schema_version: "1"
id: 1d2774c4be3dac51602a651d603f1485abffa92ad10770acfd91281819b5dd1f
title: Creating Completely New Custom Rulesets
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-governance/custom-rulesets-new.md
canonical_url: https://docs.mulesoft.com/api-governance/custom-rulesets-new
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2296c883f111eb7d881bafc1360cc91cce4887b8a0681ccd79de600285fb83e4
description: MuleSoft Documentation Site
latest: true
---
---
product: API Governance
---

# Creating Completely New Custom Rulesets

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

To create a completely new custom ruleset that isn’t based on an existing one, use one of the
following approaches:

- Search the [MuleSoft Ideas Portal](https://ideas.salesforce.com/s/search) for ideas for new
  rulesets. If you don’t find your idea there, consider submitting your idea in the MuleSoft Ideas
  Portal.

- Generate a ruleset using Anypoint CLI commands by scaffolding it from a specification’s data
  schema. See [Generating Rulesets from a Specification](#scaffold-rulesets).

- Create a ruleset using the ruleset development CLI commands, see
  [Create Rulesets Using the Ruleset Development CLI](#create-rulesets-using-cli).

- Create a ruleset using the ruleset modeling language, see
  [Create Rulesets Using the Modeling Language](#create-rulesets-using-code).

After you create the ruleset, see
[Validating and Publishing Custom Rulesets](https://docs.mulesoft.com/api-governance/custom-rulesets-validate-and-publish).

> [!NOTE] As with custom code and configurations, rulesets are not considered supported MuleSoft
> products. For help with issues with custom rulesets, post an issue in the
> [AMF Custom Validator Github repository](https://github.com/aml-org/amf-custom-validator).

## Generating Rulesets from a Specification

You can generate a starter ruleset from specifications' data schemas using the following command
sequence:

1.  [Inspect API Specifications for API Type](#inspect-for-api-type)

2.  [Initialize Rulesets from Data Schemas](#initialize-ruleset-from-dataschema)

### Inspect API Specifications for API Type

Use the following command to inspect API specifications for API type. This helps you determine which
data schema to use.

### governance:api:inspect

`> governance:api:inspect [flags] <api-specification>`

Inspects the API specification passed in `api-specification` and lists all its schemas, such as
headers, requests, and response payloads. You can use this schema information in the
`governance:ruleset:init` command. See [governance:ruleset:init](#governance-ruleset-init).

This command accepts the [default flags](https://docs.mulesoft.com/api-governance/#default-options).

**Example command:**

```copy
anypoint-cli-v4 governance:api:inspect my-healthcare-api.yaml
```

**Example schema**

```copy
types:
  patientmultipleBirthBoolean:
    properties:
      multipleBirthBoolean:
        description: Whether patient is part of a multiple birth
        type: boolean
  patientmultipleBirthInteger:
    properties:
      multipleBirthInteger:
        description: Whether patient is part of a multiple birth
        type: integer

        .
        .
        .

  PatientEntry:
    type: FHIR_commons.Entry
    properties:
      resource: Patient

  PatientBundle:
    type: FHIR_commons.Bundle
    properties:
      entry?: PatientEntry[]
```

**Example output:**

'patientmultipleBirthBoolean', 'PatientBundle', 'patientmultipleBirthInteger', 'PatientEntry'

### Initialize Rulesets from Data Schemas

Use the following command to initialize rulesets from data schemas.

### governance:ruleset:init

`> governance:ruleset:init [flags] <schema>`

Initializes a ruleset based on the data schema passed in the `schema` parameter.

In addition to the [default flags](https://docs.mulesoft.com/api-governance/#default-options), this command accepts the following flags:

<table><colgroup><col> <col></colgroup><thead><tr><th>Flag</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>--types &lt;types&gt;</code></p></div></div></td><td><div><div><p>The <code>types</code> flag gives the target types to export as rules. You can use the <code>governance:api:inspect</code> command to identify the types to specify for this flag. See <a href="#governance-api-inspect">governance:api:inspect</a>.</p></div></div></td></tr><tr><td><div><div><p><code>--name &lt;name&gt;</code></p></div></div></td><td><div><div><p>The <code>name</code> flag is the name of the ruleset. This defaults to <code>GeneratedRuleset</code>.</p></div></div></td></tr></tbody></table>

**Example command:**

```copy
anypoint-cli-v4 governance:ruleset:init --types patientmultipleBirthBoolean,patientBundle,patientmultipleBirthInteger --name=my-ruleset mydataschema
```

## Create Rulesets Using the Ruleset Development CLI

An open-source version of ruleset development CLI is available on npm. It is provided and documented
separately from the Anypoint CLI `governance` commands.

To create rulesets using the ruleset development CLI:

1.  Install `ruleset-development-cli` from
    [npmjs.com](https://www.npmjs.com/package/@aml-org/ruleset-development-cli).

2.  Follow the
    [AMF Rulesets tutorial](https://github.com/aml-org/amf-custom-validator/blob/develop/docs/validation_tutorial/validation.md)
    to create a ruleset.

## Create Rulesets Using the Modeling Language

To create rulesets using the modeling language, read the
[AMF Custom Validation section](https://github.com/aml-org/amf-custom-validator/blob/develop/docs/validation_tutorial/validation.md)
in the AML Open Source project to learn how to write a ruleset using the modeling language.

## See Also

- [Troubleshooting Anypoint CLI](https://docs.mulesoft.com/api-governance/cli-commands-troubleshoot)
