Contact Free trial Login

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

You can use any of the following options for authentication and authorization when creating an API using the Anypoint Service Mesh autocreate feature:

  • Using user credentials (username and password)

    This option supports only those users that are managed by Anypoint Platform.

  • Using Connected Apps credentials

    (Recommended) This option supports users regardless of where they are managed—​Anypoint Platform or an external IdP.

Autocreate APIs by Using Your User Credentials

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

  • Environment ID and organization ID

    To obtain these details, go to API Manager > Environment Information.

  • Manage APIs Configuration permission for the environment where you are creating the API instance

  • Exchange Contributor permission for the business group in which you are creating the asset

To autocreate APIs using user credentials, 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_ \
    --classifier=_(Optional) type of API specification, for example, oas_ \
    --mainFile=_(Optional) name of the main file in the API specification_ \
    --specPath=_(Optional) path to the API specification file_ \
    --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_ \
    --user=_username of the Anypoint Platform user, creating the API instance_ \
    --password=_password of the Anypoint Platform user, creating 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 adapter, 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.

    Optional

    ID of the organization that contains the environment

    assetId

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

    Required

    Not applicable

    version

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

    Required

    Not applicable

    instanceLabel

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

    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

    The tags to add to the asset on Exchange.

    Optional

    Not applicable

    instanceTags

    The tags to add to the API instance on API Manager.

    Optional

    Not applicable

    user

    The username credential of the Anypoint Platform user who creates the API.

    Required

    Not applicable

    password

    The password of the Anypoint Platform user who creates the API.

    Required

    Not applicable

  2. Verify the API status using the following command: asmctl api list

    The API that was created is displayed.

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

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.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub