Contact Us 1-800-596-4880

Create an API Using the CLI

After you provision the adapter, you must create an API to bind to the service. You can create an API using Anypoint Platform or Anypoint Service Mesh:

  • Create an API using Anypoint Platform

    Create APIs using Anypoint Platform when your API specification files are larger than 550 KB. If you want to upload a REST API or an OAS asset type, use a .json, .raml, .zip or .yaml file. If you want to upload a SOAP API or WSDL asset type, use a .wsdl or .xml file.

  • Create an API using the Anypoint Service Mesh autocreate feature

    You can configure Anypoint Service Mesh to automatically create an API in Anypoint Platform (no manual logging required). When creating APIs that require specification files, such as REST and SOAP APIs, ensure that the specification file is not larger than 550 KB and is available in your file system for the CLI to upload.

Create an API Using Anypoint Platform

To create an API using Anypoint Platform, perform the following steps:

  1. Go to Anypoint Platform > API Manager and select the Manage API drop-down list.

  2. Select Create new API.

    The Creating an asset page is displayed.

  3. Specify a Name value and Asset types details for the API.

    Your asset is now created in Exchange for reuse. After you create the asset, you are ready to perform endpoint configuration.

    The Endpoint Configuration window is displayed.

  4. In the Managing type field, select the Basic Endpoint radio button.

  5. In the Application type field, select the Non-Mule application radio button.

  6. Optionally, specify the Implementation URI, and click Save.

    Your API is now created.

Create an API Using the Anypoint Service Mesh Autocreate Feature

As of October 29th of 2022, the user credentials option for API autocreate feature is no longer supported. Migration to the Connected Apps approach is required. For more information, read the following section and the Obtain Connected Apps credentials page.

You can use Connected Apps credentials for authentication and authorization when creating an API using the Anypoint Service Mesh autocreate feature. This option supports users:

  • Managed by Anypoint Platform or an external IdP

  • Whether or not they have enabled multi-factor authentication

Autocreate APIs by Using Your Connected Apps Credentials

Before you configure the Anypoint Service Mesh autocreate feature, ensure that:

  • You obtain the:

  • The client credentials have the:

    • Exchange Contributor permission for publishing the API to Exchange

    • Manage API Configuration permission for managing the API in API Manager

To autocreate APIs using Connected Apps, perform the following steps:

  1. Using Anypoint Service Mesh, type the following command to create the API:

    asmctl api create \
    --name=_Kubernetes API resource name_ \
    --namespace=_namespace name_ \
    --environmentId=_environment ID_ \
    --groupId=_(Optional) group ID of the asset, for example, organization ID_ \
    --assetId=_asset ID on Exchange_ \
    --version=_asset version of the instance on exchange_ \
    --instanceLabel=_label of the instance on API Manager_ \
    --specTags=_list of comma separated tags to be added to the asset on Exchange_ \
    --instanceTags=_list of comma separated tags to be added to the instance on API Manager_ \
    --clientId=_ID of the Anypoint Platform Connected Apps, using which to create the API instance_ \
    --clientSecret=_client secret of the Anypoint Platform Connected Apps, using which to create the API instance_
    Parameter Name Description Required or Optional Default Value

    name

    The name of the Kubernetes API resource that you want to provision, for example, orders-api

    Required

    Not applicable

    namespace

    The namespace in which you want to create the API, for example, mulesoft-apps

    Required

    Not applicable

    environmentId

    The ID of the environment where you want to create your API instance

    Required

    Not applicable

    groupId

    The ID of the group of assets on Exchange, for example, the organization ID, which you can obtain from the API Manager landing page or in Access Management

    Optional

    Organization ID of the organization that contains the environment.

    assetId

    The ID of the assets that are a part of an organization, in alphanumeric characters without spaces

    Required

    Not applicable

    version

    The version of the asset on Exchange, in the semantic versioning format for major, minor, and patch releases

    Required

    Not applicable

    instanceLabel

    The ID of the API instances of an asset within a given environment, in alphanumeric characters without spaces

    Required

    Not applicable

    classifier

    The type of API asset to create: http, oas, or raml.

    Optional

    http

    mainFile

    The name of the main file in the API specification file (compliant with YAML or JSON file naming requirements), matching the primary file name for ZIP files.

    Specified for all classifiers except http

    Not applicable

    specPath

    The relative or absolute path to the API specification file.

    Required if classifier is not http

    Not applicable

    specTags

    Tags to add to the asset on Exchange

    Optional

    Not applicable

    instanceTags

    Tags to add to the API instance on API Manager

    Optional

    Not applicable

    clientId

    The client ID of the Anypoint Platform Connected App used to create the API

    Required

    Not applicable

    clientSecret

    The client secret of the Anypoint Platform Connected App used to create the API

    Required

    Not applicable

  2. Verify that the API was successfully created: asmctl api list

  3. Optionally, verify that an Exchange asset is created on Exchange and an API is created on API Manager.