***

title: Create custom governance functions in Postman
approved: 2026-03-11T00:00:00.000Z
slug: docs/api-governance/configurable-rules/configuring-custom-governance-functions
max-toc-depth: 2
----------------

<Info class="iconless-callout">
  [API Governance custom functions are available with Postman Enterprise plans.](https://www.postman.com/pricing/) If you don't have an Enterprise account, you'll be able to see the API Governance page, but you won't be able to configure custom functions.
</Info>

You can create custom governance functions and use them in your [custom API Governance rules](/docs/api-governance/configurable-rules/configuring-api-governance-rules/#add-custom-rules) that Postman applies to [API specifications](/docs/api-governance/api-definition/api-definition-warnings/) in Spec Hub.

[Super Admins](/docs/administration/roles-and-permissions/#team-roles) and [API Governance Managers](/docs/administration/roles-and-permissions/#team-roles) can manage custom governance functions for their team.

![Create custom API Governance function](https://assets.postman.com/postman-docs/v12/create-api-governance-function-v12-01.png)

## Add a custom function

You can add custom governance functions to use in your custom API Governance rules. Postman provides you with a boilerplate function to help you start writing your custom governance function. You must write custom functions in JavaScript using ES6 syntax or CommonJS syntax.

To access the configurable API Governance rules, do the following:

1. Click <img alt="Home icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-descriptive-home-stroke-small.svg#icon" width="16px" /> **Home** in the upper-left corner of the Postman app, then select <img alt="API icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-entity-api-stroke.svg#icon" width="20px" /> **API Catalog**.

2. Click <img alt="Docs icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-entity-docs-stroke.svg#icon" width="20px" /> **Governance Groups**.

3. Select the **Rule Library** tab, then select the **Functions** tab.

4. Click **Create Function**.

5. Name the function's file, then write the function in the editor. It must adhere to [custom functions guidelines](/docs/api-governance/configurable-rules/spectral/#spectral-custom-functions).

   <Tip>
     Postman prompts you with suggestions as you enter text. Select one to autocomplete your code.
   </Tip>

6. Click **Create**.

   ![New custom API Governance function](https://assets.postman.com/postman-docs/v12/new-api-governance-function-v12-01.png)

## Add a custom function to a custom rule

To add a custom function to a custom API Governance rule, [add a custom function](#add-a-custom-function), then begin the steps to [add a custom rule](/docs/api-governance/configurable-rules/configuring-api-governance-rules/#add-custom-rules).

Add the `then.function` property to the rule, and add the custom function's filename as its value to use it in your rule (for example, `function: custom_function_name`). If your custom function accepts options, add the `then.functionOptions` property. Learn more about [Spectral rule properties](/docs/api-governance/configurable-rules/spectral/#spectral-rule-properties) and [Spectral custom functions](/docs/api-governance/configurable-rules/spectral/#spectral-custom-functions).

Then click **Create** to create a custom rule that uses a custom function.

## View custom rules that use a custom function

You can view the custom rules a custom function is used in.

1. Select the **Rule Library** tab, then select the **Functions** tab.
2. Click a custom function in the **Name** column. To view only the number of custom rules each custom function is used in, you can review the values in the **Used In** column.
3. Click **Rules affected by this function** to expand the custom rules your custom function is used in. You can click an affected rule's name to view it in a new tab.

## Edit a custom function

1. Select the **Rule Library** tab, then select the **Functions** tab.
2. Click a custom function in the **Name** column.
3. Edit the function, then click **Save**.

## Remove a custom function

To remove a custom API Governance function, you must [remove the API Governance rules](/docs/api-governance/configurable-rules/configuring-api-governance-rules/#remove-rules-from-your-api-governance-configuration) that use the custom function. Then click <img alt="Delete icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-action-delete-stroke.svg#icon" width="20px" /> **Delete** next to the custom function's filename.

![Delete a custom API Governance function](https://assets.postman.com/postman-docs/v12/delete-api-governance-function-v12-01.png)
