Contact Us 1-800-596-4880

CLI for API Manager

Command Description

Creates an API instance alert

Lists alerts for an API instance

Lists the autodiscovery properties

Changes the asset version for an API instance by choosing a new version from Exchange

Classifies an API instance in a given environment

Deletes an API

Deploys an API to CloudHub, hybrid server, or Runtime Fabric

Deprecates an API instance

Shows details of an API

Downloads the API proxy ZIP file to a local directory

Edits an API instance

Lists all APIs in API Manager 2.x

Manages a new API, API version, or new API instance with an asset from Exchange

Promotes an API instance from source environment

Redeploys an API to CloudHub, Hybrid server, or Runtime Fabric

Undeprecates an API instance

Deletes a given API contract

Lists all contracts to a given API instance

Applies a policy to a given API instance

Shows the description and available configuration properties of a given policy template

Disables policy from a given API instance

Edits the policy configuration of a given API instance

Enables a policy on a given API instance

Lists policies

Removes a policy from a given API instance

Creates an SLA tier

Copies an SLA tier from source to a target API instance

Deletes an SLA tier from an API instance

Lists the SLA tiers of an API instance

api-mgr:alert:add

> api-mgr:alert:add <apiInstanceId> <name> [flags]

Creates an API instance alert with the name passed in name for the API instance ID passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--duration

Condition occurrence period duration.

--duration 60

--durationUnit

Condition occurrence period duration unit.
Supported values: days, hours, and minutes.

--durationUnit minutes

--email

Email to send alert notification to.
Pass this flag multiple times to specify multiple emails.

--enabled

Sets whether the alert is enabled. Include the flag to enable the alert.

--enabled

--operator

Condition operator that explains values in relation to threshold.
Supported values: gt, lt, eq.

--operator gt

--periods

Number of consecutive periods condition should occur for.

--periods 34

--policyId

ID of a policy applied to the API instance that triggers a policy-violation alert type.

--policyId http-basic-authentication

--recipient

Username to send alert notification to.
Pass this flag multiple times to specify multiple usernames.

--recipient mulesoftuser

--responseCode

Response codes to trigger response-code alert type.
Pass this flag multiple times to specify multiple codes.

--responseCode 400

--responseTime

Response time to trigger response-time alert type.

--responseTime 60

--severity

Alert severity.
Supported values: Info, Warning, Critical.

--severity Critical

--threshold

Condition occurrences threshold number.

--threshold 3

--type

Alert type/condition.
Supported values: request-count, response-code, policy-violation, response-time

--type response-code

This command has multi-option flags. When using multi-option flags in a command, either put the parameter before the flags or use a `-- ` (two dashes followed by a space) before the parameter.

api-mgr:alert:list

> api-mgr:alert:list [flags] <apiInstanceId>

Lists alerts for the API instance passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--limit

Number of results to retrieve, default is 10 results

--limit 5

--offset

Offsets the amount of APIs passed

--offset 3

--output

Specifies the response format
Supported values are table (default) and json

--output json

--sort

Sorts the results in the field name passed

--sort "Latest Version"

api-mgr:api:autodiscovery

> api-mgr:api:autodiscovery [flags] <apiInstanceId> <name>

This command lists the autodiscovery properties required for a gateway to track the API Instance Id passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--gatewayVersion

Specifies the gateway version to download

--gatewayVersion 4.0.1 643404 /tmp/

--output

Specifies the response format
Supported values are table (default) and json

--output table

api-mgr:api:change-specification

> api-mgr:api:change-specification [flags] <apiInstanceId> <assetVersion>

Changes the asset version for the API instance passed in <apiInstanceId> by choosing a new version from Exchange passed in <assetVersion>.

This command accepts the default flag --help.

api-mgr:api:classify

> api-mgr:api:classify [flags] <destEnvName> <apiInstanceId>

Classifies the API instance passed in <apiInstanceId> in the environment passed in <destEnvName>.

This command accepts the default flag --help.

api-mgr:api:delete

> api-mgr:api:delete [flags] <apiInstanceId>

Deletes the API instance passed in <apiInstanceId>. If the API instance is deployed, this command undeploys the API instance before deleting it.

This command accepts the default flag --help.

api-mgr:api:deploy

> api-mgr:api:deploy [flags] <apiInstanceId>

Deploys the API instance passed in '<apiInstanceId>' to the deployment target specified using the flags described next. Deploy any undeployed API using this command regardless of whether it was created using the API Manager CLI or API Manager UI.

This command is only supported for endpoints with proxy.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--applicationName

Application name

--applicationName myMuleApp 643404

--environmentName

Target environment name, only for when deploying API instances from unclassified environments

--environmentName TestEnv 643404

--gatewayVersion

The CloudHub Gateway version

--gatewayVersion: 9.9.9.9 643404

--overwrite

Update application if it exists

--overwrite 643404

--target

Hybrid or RTF deployment target ID

--target 1598794 643404

api-mgr:api:deprecate

> api-mgr:api:deprecate [flags] <apiInstanceId>

Deprecates the API instance passed in <apiInstanceId>.

This command accepts the default flag --help.

api-mgr:api:describe

> api-mgr:api:describe [flags] <apiInstanceId>

Shows details of the API instance passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the --output flag. Use the --output flag to specify the response format. Supported values are table (default) and json.

api-mgr:api:download-proxy

> api-mgr:api:download-proxy [flags] <apiInstanceId> <targetPath>

This command downloads the API proxy ZIP file of the API instance passed in <apiInstanceId> to a local directory specified in <targetPath>. You cannot download the API proxy of a Flex Gateway API instance.

In addition to the default flag --help, this command accepts the --gatewayVersion flag to specify the gateway version to download. For example: api-mgr:api:download-proxy --gatewayVersion: 4.0.1 643404 /tmp/

api-mgr:api:edit

> api-mgr:api:edit [flag] <apiInstanceId>

Edits the API instance passed in <apiInstanceId>. Editing a deployed Flex Gateway API instance redeploys the instance.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

-f, --isFlex

Indicates whether this is a Flex Gateway API instance.
Include the flag to enable it

--isFlex

-m, --muleVersion4OrAbove

Indicates whether this is a Mule 4 API instance.
Include the flag to enable it

--muleVersionOrAbove

-p, --withProxy

Indicates whether the endpoint should use a proxy.
Include the flag to enable it

--withProxy

-r, --referencesUserDomain

Indicates whether a proxy should reference a user domain.
Include the flag to enable it

--referencesUserDomain

`--apiInstanceLabel `

API instance label

--apiInstanceLabel exampleLabel

--deploymentType

Deployment type
Options: cloudhub, hybrid, rtf (required)

--deploymentType cloudhub

--endpointUri

Consumer endpoint URI (required)

--endpointUri /udp://localhost:65432

--inboundSecretGroupId

Inbound secret group ID

--inboundSecretGroupId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--inboundTlsContextId

Outbound TLS Context ID
Supply the --inboundSecretGroupId of the TLS Context’s secret group. To remove a TLS Context, apply the flag with the following value: --inboundTlsContextId "null".

--inboundTlsContextId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--outboundSecretGroupId

Outbound secret group ID.

--outboundSecretGroupId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

`--outboundTlsContextId `

Outbound TLS Context ID.
Supply the --outboundSecretGroupId of the TLS Context’s secret group. To remove a TLS Context, apply the flag with the following value: --outboundTlsContextId "null".

--outboundTlsContextId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--path

Proxy path (required)

--path /http://localhost:3000

--port

Proxy port (required)

--port 8080

--providerId

Client Identity Provider Id that the API is associated with
Default is Anypoint Platform Client Provider

--providerId 1787c36ab544466698e380131040faad

--responseTimeout

Maximum response timeout(required)

--responseTimeout 10

--scheme

Proxy scheme (required)
Supported values: http, https.

--scheme http

--serviceName

WSDL service name
Flex Gateway does not support this flag

--serviceName ExampleServerName

--serviceNamespace

WSDL service namespace. Flex Gateway does not support this flag.

--serviceNamespace exampleServiceName

--servicePort

WSDL service port
Flex Gateway does not support this flag

--servicePort 443

--updateApisInSamePort

Updates the TLS context of API instances sharing the port of this API.

--updateApisInSamePort

--uri

Implementation URI.

--uri /udp://localhost:65432

api-mgr:api:list

> api-mgr:api:list [flags]

Lists all APIs in API Manager 2.x.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--apiVersion

API version that filters results

--apiVersion 1.0.2

--assetId

Asset ID that filters results

--assetId ([group_id]/)<asset_id>/<version>

--instanceLabel

API instance label that filters results

--instanceLabel exampleLabel

--limit

Number of results to retrieve

--limit 50

--offset

Offsets the amount of APIs passed

--offset 3

--sort

Sorts the results in the field name passed

--sort "Latest Version"

api-mgr:api:manage

> api-mgr:api:manage [flags] <assetId> <assetVersion>

Manages a new API, API version, or new API instance with the Exchange asset passed in <assetId>, and the version passed in <assetVersion>.

Flex Gateway API instances created with Anypoint CLI do not support multiple upstream services. To create Flex Gateway API instances with multiple upstream services, see:

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

-f, --isFlex

Indicates whether this is a Flex Gateway API instance.
Include the flag to enable it

--isFlex

-m, --muleVersion4OrAbove

Indicates whether this is a Mule 4 API instance.
Include the flag to enable it

--muleVersionOrAbove

-p, --withProxy

Indicates whether the endpoint should use a proxy.
Include the flag to enable it

--withProxy

-r, --referencesUserDomain

Indicates whether a proxy should reference a user domain.
Include the flag to enable it

--referencesUserDomain

`--apiInstanceLabel `

API instance label

--apiInstanceLabel exampleLabel

--deploymentType

Deployment type
Options: cloudhub, hybrid, rtf (required)

--deploymentType hybrid

--endpointUri

Consumer endpoint URI (required)

--endpointUri /udp://localhost:65432

--inboundSecretGroupId

Inbound secret group ID

--inboundSecretGroupId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--inboundTlsContextId

Outbound TLS Context ID
Supply the --inboundSecretGroupId of the TLS Context’s secret group. To remove a TLS Context, apply the flag with the following value: --inboundTlsContextId "null".

--inboundTlsContextId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--outboundSecretGroupId

Outbound secret group ID.

--outboundSecretGroupId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

`--outboundTlsContextId `

Outbound TLS Context ID.
Supply the --outboundSecretGroupId of the TLS Context’s secret group. To remove a TLS Context, apply the flag with the following value: --outboundTlsContextId "null".

--outboundTlsContextId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--path

Proxy path (required)

--path /http://localhost:3000

--port

Proxy port (required)

--port 8080

--providerId

Client Identity Provider Id that the API is associated with
Default is Anypoint Platform Client Provider

--providerId 1787c36ab544466698e380131040faad

--responseTimeout

Maximum response timeout(required)

--responseTimeout 10

--scheme

Proxy scheme (required)
Supported values: http, https.

--scheme http

--serviceName

WSDL service name
Flex Gateway does not support this flag

--serviceName ExampleServerName

--serviceNamespace

WSDL service namespace. Flex Gateway does not support this flag.

--serviceNamespace exampleServiceName

--servicePort

WSDL service port
Flex Gateway does not support this flag

--servicePort 443

--type

Endpoint type
Supported options: http, raml, wsdl

--type http

--uri

Implementation URI

--uri /udp://localhost:65432

api-mgr:api:promote

> api-mgr:api:promote [flags] <apiInstanceId> <sourceEnvId>

Promotes the API instance passed in <apiInstanceId> from the source environment in <sourceEnvId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

-a, --copyAlerts

Indicates whether to copy alerts
Include the flag to enable it

--copyAlerts

-p, --copyPolicies

Indicates whether to copy policies
Include the flag to enable it

--copyPolicies

-t, --copyTiers

Indicates whether to copy tiers
Include the flag to enable it

--copyTiers

--providerId

Indicates the provider’s ID associated with the API.

--providerId 1787c36ab544466698e380131040faad

api-mgr:api:redeploy

> api-mgr:api:redeploy [flags] <apiInstanceId>

Redeploys the API instance passed in <apiInstanceId> to the deployment target set up in the flags described below.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--applicationName

Application name

--applicationName Muleapp 643404

--environmentName

Target environment name
Include to redeploy APIs from unclassified environments

--environmentName mulesoftEnvironment 643404

--gatewayVersion

CloudHub Gateway version

--gatewayVersion 9.9.9 643404

--overwrite

Update application if exists
Include the flag to enable it

--overwrite

--target

Hybrid or RTF deployment target ID

--target 1598794 643404

api-mgr:api:undeprecate

> api-mgr:api:undeprecate [flags] <apiInstanceId>

Undeprecates the API instance passed in <apiInstanceId>.

This command accepts the default flag --help.

api-mgr:contract:delete

> api-mgr:contract:delete [flags] <apiInstanceId> <clientId>

This command deletes the contract between the API instance passed in <apiInstanceId>, and the client passed in <clientId>.

This command accepts the default flag --help.

api-mgr:contract:list

> api-mgr:contract:list [flags] <apiInstanceId> [searchText]

Lists all contracts of the API passed in <apiInstanceId>.

You can specify keywords in searchText to limit results of APIs containing those specific keywords.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--limit <value>

Number of results to retrieve

--limit 2

--offset <value>

Offsets the amount of APIs passed

--offset 3

--output <value>

Specifies the response format, supported values are table (default) and json

--output json

--sort <value>

Sorts the contracts by the criteria associated with their client applications, supported values are createdDate, id, and name

--sort id

api-mgr:policy:apply

> api-mgr:policy:apply [flags] <apiInstanceId> <policyId>

Applies the policy passed in <policyId> to the API instance passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

-c, --config

Pass the configuration data as a JSON string

--config '{\"username\":\"user\",\"password\":\"teste\"}'

--configFile

Pass the configuration data as a file

--configFile ./config.json

--groupId

Mule 4 policy group ID
This value defaults to the MuleSoft group ID.

--groupId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

-p, --pointcut [dataJSON]

Pass pointcut data as JSON strings

--pointcut '[{"methodRegex":"GET|PUT","uriTemplateRegex":"/users*"}]'

--policyVersion

Mule 4 policy version.

--policyVersion 1.0.2

The following example defines a rate limit of one request every ten seconds:

{
        "rateLimits": [{
            "maximumRequests": 1,
            "timePeriodInMilliseconds": 10000
        }],
        "clusterizable": true,
        "exposeHeaders": false
    }
Even if you plan to use the default values, you must configure all required policy parameters when applying a policy with Anypoint CLI,

api-mgr:policy:describe

> api-mgr:policy:describe [flags] <policyId>

Shows the description and available base configuration properties of the policy name passed in <policyId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--groupId

Mule 4 policy group ID

+ Defaults to the MuleSoft group ID.

--groupId 1fec0a49-1551-4199-bfcc-cf0352d0f29d

--policyVersion

Mule 4 policy version

--policyVersion 1.0.2

--output

Specifies the response format
Supported values are table (default) and json.

--output json

api-mgr:policy:disable

> api-mgr:policy:disable [flags] <apiInstanceId> <policyInstanceId>

Disables the policy passed in <policyInstanceId> from the API instance passed in <apiInstanceId>.

This command accepts the default flag --help.

api-mgr:policy:edit

> api-mgr:policy:edit [flags] <apiInstanceId> <policyInstanceId>

Edits the policy configuration passed in <policyInstanceId> for the API instance passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

`-c, --config

Pass the configuration data as a JSON string

--config '{\"username\":\"user\",\"password\":\"teste\"}'`

-p, --pointcut

Pass pointcut data as JSON strings

-p '[{"methodRegex":"GET|PUT","uriTemplateRegex":"/users*"}]'

api-mgr:policy:enable

> api-mgr:policy:enable [flags] <apiInstanceId> <policyInstanceId>

Enables the policy passed in <policyInstanceId> for the API instance passed in <apiInstanceId>.

This command accepts the default flag --help.

api-mgr:policy:list

> api-mgr:policy:list [flags] [apiInstanceId]

Lists all policies for all APIs in API Manager 2.x.
Specify the --apiInstanceId flag to list the policies applied to that API instance. Without the --apiInstanceId flag, the command lists all policies for all APIs.

In addition to the default flag --help, this command accepts the -m, --muleVersion4OrAbove flag.

api-mgr:policy:remove

> api-mgr:policy:remove [flags] <apiInstanceId> <policyInstanceId>

This command removes the policy specified in <policyInstanceId> from the API instance passed in <apiInstanceId>.

This command accepts the default flag --help.

api-mgr:tier:add

> api-mgr:tier:add [flags] <apiInstanceId>

This command creates an SLA tier for the API instance passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

-a, --autoApprove

Indicates whether the SAL tier should be auto-approved
Include the flag to enable it

--autoApprove

--name

Tier name

--name muleSLAtier

--description

Tier description

--description tier example description

-l, --limit

Single instance of an SLA tier limit in the form --limit A,B,C where:

  • A is a boolean indicating whether this limit is visible to the user.

  • B is a number of requests per "C" time period.

  • C is the time period unit. Time period options are:

    • ms(millisecond)

    • sec(second)

    • min(minute)

    • hr(hour)

    • d(day)

    • wk(week)

    • mo(month)

    • yr(year)

--limit true,100,min

To create multiple limits, you can provide multiple --limit options.
For example: -l true,100,sec -l false,20,min.

api-mgr:tier:copy

> api-mgr:tier:copy [flags] <sourceAPIInstanceId> <targetAPIInstanceId>

Copies the SLA tier from the API instance passed in <sourceAPIInstanceId> to the API instance Id passed in <targetAPIInstanceId>.

This command accepts the default flag --help.

api-mgr:tier:delete

> api-mgr:tier:delete [flags] <apiInstanceId> <tierId>

This command deletes the SLA tier passed in <tierId> from API instance passed in <apiInstanceId>.

This command accepts the default flag --help.

api-mgr:tier:list

> api-mgr:tier:list [flags] <apiInstanceId> [searchText]

This command lists the SLA tiers of the API instance passed in <apiInstanceId>.

In addition to the default flag --help, this command accepts the following flags:

Flag Description Example

--limit

Number of results to retrieve

--limit 2

--offset

Offsets the amount of APIs passed

--offset 3

--output <value>

Specifies the response format, supported values are table (default) and json

--output json

--sort

Sorts the results in the field name passed

--sort "Latest Version"