Skip to Content
P4A Documentation
Guides

Publishing a ruleset

Publish an approved ruleset to your Anypoint Exchange from P4A and, optionally, add it to an API Governance profile.

Overview

An approved ruleset in the P4A catalog can be published to the Anypoint Exchange of your own organization. API Governance reads rulesets from Exchange, so this is the step that makes a ruleset usable for your APIs. P4A does it through a registered Anypoint connection, so you don't need the Anypoint CLI. You can also add the new ruleset to a governance profile in the same step.

Approved, published rulesets can be published to Exchange by anyone. While a ruleset is under review, only its invited reviewers (including its submitter) and platform admins can publish it, so they can try it before it's approved. Everyone else sees a disabled Publish to Exchange button with a tooltip that says so. A rejected ruleset can't be published.

Before you start

Permissions

P4A acts as your Connected App, so the Connected App needs these permissions, not your user. Assign each one in the business group you pick in the dialog: the one you publish into, or the one that owns the profile.

What you do in P4AAnypoint permission
Publish or unpublish a rulesetExchange Contributor (with Exchange Creator and Exchange Viewer, as for policies). See Connecting your Anypoint ORG.
See the list of existing profilesAPI Governance: Governance Viewer or Governance Administrator
Create a profileAPI Governance: Governance Administrator
Add rulesets to an existing profileAPI Governance: Governance Administrator. P4A reads the profile first so it can keep its current rulesets, which this permission also covers.

Governance Viewer alone can't change profiles. Without it, P4A can't list the profiles and asks you for a profile ID instead. Adding to that profile still needs Governance Administrator. MuleSoft's own rulesets are public in Exchange, so referencing their GAVs needs no extra Exchange permission.

For what each permission allows in Anypoint, see Getting Started with Anypoint API Governance and CLI commands for API Governance.

Publishing

Open the ruleset's detail page and click Publish to Exchange. A dialog opens.

Fields in the dialog

  • Workspace and Anypoint Connection: where the credentials come from. The workspace controls which shared connections you can pick. See Using workspaces.
  • Target business groups: the Anypoint business groups to publish into. Each one you select becomes its own publish, and they run in parallel.
  • Exchange asset ID: the asset's identifier in Exchange, lowercase letters, digits and hyphens. It's prefilled from the ruleset's exchange.json or its name. Leave it blank to use the ruleset's default.
  • Version: optional, in the form 1.2.3 (three numbers, no v prefix). Leave it blank to use the version in the ruleset's exchange.json, or 1.0.0 when there isn't one.
  • Source: optional Branch (plus an optional commit on it), Tag, or Commit to publish from. Leave it blank to publish the commit a reviewer approved. Rulesets approved before P4A recorded commits use the ruleset's own ref, as before. The Source section is a gray card that starts collapsed, with a one-line summary of the selection in its header (for example Approved commit abc1234 on main); click the header to change it. The card shows the branch and the approved commit, and the dialog warns, outside the card and even while it is collapsed, when the branch has newer commits that aren't approved yet. The card opens by itself if the selection has an error. Any other ref still publishes, but the deployment gets an Unapproved source badge and is recorded in the history. See The approved commit.
  • Apply to a governance profile: optional. See Adding it to a governance profile.

Exchange versions are immutable. You can't overwrite a version that already exists. To publish a change, give the ruleset a new version, either in the dialog or in its exchange.json. Publishing a version that already exists fails with a message telling you to bump the version.

If deployments are paused, the dialog shows a banner and the button stays disabled until they resume.

Following the job

After you click Publish, the ruleset's detail page shows a Deployments card with one row per business group. Each row shows the status, streams the build log while it runs, and offers Open in Exchange once it's published. You're also notified of the outcome. You can see the same rows on the connection's page, and with list_deployments and get_deployment over MCP. Once it's live, the ruleset also appears on the Rulesets tab of the workspace whose connection you used. See Using workspaces.

Publishing from an agent works the same way: deploy_ruleset asks you to confirm, then returns one deployment ID per business group. Track each with get_deployment. See the MCP tools reference.

Adding it to a governance profile

A governance profile decides which APIs a ruleset checks. Tick Apply to a governance profile to do this as part of the publish:

OptionWhat it does
CreateMakes a new profile with the Profile name you give. Set its Filter criteria the same way as in Anypoint: under General, tick the API Types it governs (REST API, AsyncAPI, HTTP API, Agent, MCP, gRPC; none ticked means every type) and add optional Tags and Categories (name:value). Under API Instance, choose All APIs, Include only APIs with instances (then an Environment type: Any, Production or Sandbox), or Only APIs without instances.
UpdateAdds the ruleset to an existing profile. Pick the profile from the list of the first target business group's profiles. If P4A can't list them (for example the connection lacks API Governance access), enter the profile ID instead. The profile keeps the rulesets it already has.
NotificationsOptional. Tick API contact and API publisher, or list Other recipients by email, to be emailed when an API fails conformance. See Notifications.
Additional rulesetsOptional group/asset/version entries to attach alongside yours, for example a MuleSoft ruleset's GAV. See Rulesets in P4A.

The profile step runs after the upload. If it fails, for example because the connection can't manage profiles, the ruleset stays published, because the asset is already in Exchange and can't be re-uploaded. The row shows governance profile not applied with the reason on hover. Fix the permission, then use Add to profile on that row of the Deployments card, or add the ruleset to the profile in Anypoint. When it works, the row shows the profile name.

Adding a ruleset that's already published

You don't need to publish again to add a ruleset to a profile. You can start from:

  • Add to governance profile on a MuleSoft ruleset's page, next to its GAV, or
  • Add to profile on a published row of the Deployments card of a ruleset you've published.

From the GAV block, pick the workspace, connection and the business group that owns the profile. From a deployment row, they're fixed to where that version was published, and shown read-only. If that connection or business group is no longer available to you, the dialog says so and you can't submit. Then either choose an existing profile or create a new one. The Rulesets field is prefilled with the ruleset's group/asset/version and accepts up to 20 comma-separated entries. Nothing is uploaded to Exchange. You're told when the profile is updated, or why it failed.

From an agent, list_governance_profiles lists a business group's profiles and attach_ruleset_to_profile adds the rulesets. It asks you to confirm first. Adding to a profile counts toward your daily deploy limit.

Notifications

API Governance can email people when an API fails the profile's rules. In the Notifications box, choose who:

  • API contact: the contact on the API's Exchange page.
  • API publisher: whoever published the API.
  • Other recipients: up to 20 email addresses, comma separated.

When you create a profile and leave the box empty, it sends no notifications. When you add to an existing profile and leave it empty, the profile keeps its current notifications. If you set any recipient, it replaces the profile's recipient list. To change other notification settings, edit the profile in Anypoint API Governance.

Profile rules are evaluated by API Governance, not P4A. For criteria, notifications and how conformance is reported, see Creating Governance Profiles and Finding and Fixing Conformance Issues.

Deploying a workspace ruleset

A ruleset you build in the guided editor is a workspace ruleset, saved in one of your workspaces. You can publish it to your own Exchange without a repository and without review. A workspace ruleset never appears in the public catalog.

On the Workspace tab of the Rulesets page, click the row's Deploy button, or open the workspace ruleset and click Deploy in the editor. A deploy always publishes the saved YAML, so the editor saves any unsaved changes first. The dialog is the same as above, with these differences:

  • Workspace is fixed to the ruleset's workspace. A workspace ruleset deploys only through connections shared into that workspace.
  • Exchange asset ID is read-only. It comes from the ruleset's asset ID, or a slug of its name, and the first deploy stores it on the ruleset. Change it in the ruleset's details before the first deploy.
  • Version is prefilled with the next patch above the versions this workspace ruleset already used, else its default version, else 1.0.0.
  • There is no Source ref.

Any active member of the workspace can deploy a workspace ruleset. The YAML must pass the structural check first. If it doesn't, the dialog lists the errors and nothing is queued. If someone else saved the ruleset after you opened it, the deploy is refused and the editor offers to reload their version or overwrite it with yours.

Each deploy keeps a copy of the published YAML. It appears in the ruleset's History tab, marked Deploy. Its Deployments tab lists its deployments with the same status, logs, Add to profile and Unpublish actions as above. On the connection's page, a workspace ruleset deployment carries a Workspace badge that links back to the ruleset.

From a script, use POST /api/ruleset-drafts/{id}/deployments with the revision you loaded as expectedRevision, and GET /api/ruleset-drafts/{id}/deployments to list them. See the API reference.

Unpublishing

Use Unpublish on a deployment row to remove the ruleset version from Exchange, then confirm in the dialog that opens. P4A deletes the version and, when Exchange won't allow a delete, deprecates it instead. The row then shows as deleted.

If a governance profile still uses the ruleset, the unpublish fails. Remove the ruleset from those profiles in Anypoint first, then try again.

Troubleshooting

MessageCauseFix
Version already exists, bump the versionThat version is already in Exchange for the asset IDPublish again with a new Version.
Asset ID or version rejected in the dialogThe asset ID has uppercase letters or other characters, or the version isn't 1.2.3Use lowercase letters, digits and hyphens, and three dot-separated numbers.
Ruleset does not conform to the dialectThe profile fails validationFix the YAML. See Authoring a ruleset and run an authoritative validate_ruleset.
Unauthorized or forbiddenThe connection can't publish in that business groupCheck the Connected App's Exchange scopes and business group access. See Connecting your Anypoint ORG.
Cannot unpublish: in use by a governance profileA profile references the rulesetRemove it from the profile, then unpublish.
Governance profile not appliedThe profile step failed after a good uploadCheck the permissions and the profile name or ID, then use Add to profile on the row.
Profile list shows a profile ID fieldP4A couldn't list the business group's profiles, or there are noneGive the Connected App Governance Viewer (or Governance Administrator) in that business group, or enter the profile ID from Anypoint.
Unauthorized or forbidden when adding to a profileThe Connected App lacks Governance Administrator in the profile's business groupAssign it. See Permissions.
exchange.json is not valid JSON, or its version is not MAJOR.MINOR.PATCHThe ruleset's exchange.json can't be read, or its version has a v prefix or a suffixFix the file in the repository, or set Version in the dialog to override it.
A validation or publish fails with no rule messages, only a sign-in, network or timeout errorThe Anypoint CLI couldn't reach Anypoint with the connection, so it never checked the rulesetCheck the connection's credentials and scopes, then try again. For the CLI's own error messages, see Troubleshooting CLI commands.
This draft was saved by someone elseA teammate saved the ruleset after you opened itReload their version, or overwrite it with yours, then deploy again.
The workspace ruleset is not validThe ruleset's YAML fails the structural checkFix the errors the dialog lists, save, then deploy.
Publish button disabledThe ruleset isn't approved yet and you aren't one of its reviewers, or deployments are pausedWait for approval or for the pause to end.

References

On this page