Skip to main content
Use hiddenlayer-apim to deploy policy fragments, apply them to APIs, inspect status, and remove them when needed.

Command Summary

Packages

Lists every fragment package built into the CLI binary, including its version, description, and the inbound/outbound fragment IDs it ships. Use this command before deploy or apply to confirm which package names are valid for --package and --packages.

Deploy

Deploy creates missing HiddenLayer APIM named values and policy fragments. It does not overwrite different existing non-secret named values or policy fragments by default. Use --overwrite only when you intentionally want to update existing HiddenLayer-managed resources:
When --overwrite would change existing named values or replace existing policy fragment XML, the command lists the affected resources and prompts for confirmation. Type yes to proceed. Secret named values are listed by name only; their values are not displayed. Deploy multiple packages with --packages:
When the package flag is omitted and multiple packages are available, deploy shows the package menu, then prints a per-resource summary as it creates named values and policy fragments.
After deploy completes, the new HiddenLayer fragments appear on the APIM service under APIs → Policy fragments. References stay at 0 until an API policy includes them.

List

list prints the API ID, display name, and path for every API in the APIM instance. Use it to find the <api-id> value to pass to apply, remove, or status.

Apply

Before updating the API policy, the command lists the inbound and outbound HiddenLayer fragments it is about to inject and prompts for confirmation. Type yes to continue, or pass --yes to skip the prompt in automated workflows:
If all of the requested fragments are already present in the policy, apply reports that and exits without changing the policy. Preview the API policy before applying it:
Apply multiple packages:
The terminal output below shows the full interactive flow: package selection, the fragment confirmation prompt, the injection step, and a generated curl test command for the affected API.
After apply, the References column on the APIM Policy fragments page increases for every fragment included in the API policy. Shared fragments such as hl-oauth-token-management show one reference per API that uses them.

Remove

Before updating the API policy, the command lists the fragment IDs it is about to remove and prompts for confirmation. Type yes to continue, or pass --yes to skip the prompt in automated workflows:
Remove multiple packages in a single command with --packages:
When multiple HiddenLayer packages are applied, remove preserves shared fragments (for example hl-oauth-token-management) that other installed packages still need. Use --all to remove every HiddenLayer fragment detected in the API policy, regardless of package:
--all cannot be combined with --package or --packages. When you omit --package, --packages, and --all, the CLI selects a package from HL_PACKAGE or, when no default is set and multiple packages are available, prompts interactively. The terminal output below shows package selection, the per-fragment confirmation list, and the removal step.
In the Azure portal, the References count for the removed fragments drops back to 0, while shared fragments still referenced by other APIs (for example hl-oauth-token-management) retain a non-zero reference count — confirming that remove preserves cross-package dependencies.

Status

Use status after deploy and apply to verify APIM resources and target API policy references.

Export Bicep

The generated bundle includes main.bicep, a starter main.bicepparam, and the package’s fragments/*.xml files. The only required Bicep parameter is apimServiceName. Deploy the exported template with:
You can also edit ./hl-bicep/main.bicepparam and pass --parameters ./hl-bicep/main.bicepparam instead. Export only inbound or outbound fragments: