Exchange API
Asset Creation
The Exchange API v1 can create these asset types:
REST APIs
- An API specification that can be represented in RAML format or OAS (Swagger) format.SOAP APIs
- An API specification in WSDL format.HTTP APIs
- A placeholder for an endpoint for use by private Exchange users who want to manage the endpoint with API Manager.API Groups
- A set of APIs bundled into a single asset.Instead of requesting access to multiple APIs to satisfy a use case, a developer can access the group in one step.
API Spec Fragments
- A RAML document that has a version and an identifier, but is not a complete RAML specification.API spec fragments are also known as RAML fragments.
Custom
- A description and an optional file to explain aspects of your system, to provide instructional videos, or to describe a product or organizational documentation.
The following sections show examples of uploading each asset type.
Create an Asset
Before executing the examples, follow the instructions in the Anypoint Platform Token
section to get a token. In each cURL example, replace ANYPOINT_TOKEN
with your token.
You can send HTTP commands with cURL, Postman, or another application. These examples use cURL.
Before executing the examples, be sure you understand all the multipart request fields.
Fields that are common to all asset types:
organizationId
: Organization where the asset is created.groupId
: Group ID of the asset.assetId
: Asset ID of the asset.version
: Version of the asset in semantic versioning (SEMVER) format.name
: The visible name of the asset.classifier
: The classifier is used to identify the type of asset. The examples show the classifiers for publishing each asset type.
Fields that are used for only some assets:
asset
: The full path of the asset file that is uploaded.main
: The name of the main asset file in the root directory of the uploaded zip file.apiVersion
: The API version of the asset. Used only for API asset types.assetLink
: The URL of an external API.
IMPORTANT
: The property asset
must always be the last field sent in the multipart request.
When creating an asset of any type, the maximum file size is 5 MB
.
RAML
This example creates an asset of type RAML
.
Download the file used in this example here:
Replace /Users/llucas/Downloads/training-american-flights-api-1.0.0-raml.zip
with the local path of the downloaded file.
Change these fields:
organizationId
groupId
assetId
version
name
apiVersion
Change the field main
only if another file is uploaded.
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="raml-asset-flight" \
-F version="1.0.0" \
-F name="raml asset name" \
-F main="american-flights-api.raml" \
-F apiVersion="v1" \
-F classifier="raml" \
-F asset=@/Users/llucas/Downloads/training-american-flights-api-1.0.0-raml.zip \
https://anypoint.mulesoft.com/exchange/api/v1/assets
OAS API (Swagger)
This example creates an asset of type OAS
.
Download the file used in this example here:
Replace /Users/llucas/Downloads/verato-1.0.0-oas.zip
with the local path of the downloaded file.
Change these fields:
organizationId
groupId
assetId
version
name
apiVersion
Change the field main
only if another file is uploaded.
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="oas-asset" \
-F version="1.0.0" \
-F name="oas asset name" \
-F main="verato.json" \
-F apiVersion="v1" \
-F classifier="oas" \
-F asset=@/Users/llucas/Downloads/verato-1.0.0-oas.zip \
https://anypoint.mulesoft.com/exchange/api/v1/assets
SOAP API (WSDL)
This example creates an asset of type WSDL
.
Change these fields:
organizationId
groupId
assetId
version
name
assetLink
apiVersion
Change the field main
only if another file is uploaded.
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="wsdl-asset-with-link" \
-F version="1.0.0" \
-F name="wsdl asset name" \
-F assetLink="http://www.my-wsdl-url.com" \
-F apiVersion="v1" \
-F classifier="wsdl" \
https://anypoint.mulesoft.com/exchange/api/v1/assets
This example creates a SOAP API using asset
and not assetLink
:
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="wsdl-asset-with-file" \
-F version="1.0.0" \
-F name="wsdl asset name" \
-F main="main.wsdl" \
-F apiVersion="v1" \
-F classifier="wsdl" \
-F asset=@/Users/llucas/Downloads/wsdl.zip \
https://anypoint.mulesoft.com/exchange/api/v1/assets
HTTP API
This example creates an asset of type HTTP
.
Increase the major version for each new version of an HTTP API. For example, increase from 1.0.0
to 2.0.0
.
Change these fields:
organizationId
groupId
assetId
version
name
assetLink
apiVersion
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="http-asset-3" \
-F version="1.0.0" \
-F name="http asset name" \
-F assetLink="http://www.my-http-api-url.com" \
-F apiVersion="v1" \
-F classifier="http" \
https://anypoint.mulesoft.com/exchange/api/v1/assets
RAML Fragment
This example creates an asset of type RAML Fragment
.
Download the file used in this example here:
Replace /Users/llucas/Downloads/training-oauth20-security-scheme-1.0.2-raml-fragment.zip
with the local path of the downloaded file.
Change these fields:
organizationId
groupId
assetId
version
name
Change the field main
only if another file is uploaded.
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="raml-fragment-asset" \
-F version="1.0.0" \
-F name="raml fragment asset name" \
-F main="OAuth2.raml" \
-F classifier="raml-fragment" \
-F asset=@/Users/llucas/Downloads/training-oauth20-security-scheme-1.0.2-raml-fragment.zip \
https://anypoint.mulesoft.com/exchange/api/v1/assets
Custom
This example creates an asset of type Custom
.
Download the file used in this example here:
Replace /Users/llucas/Downloads/two-factor-auth-policy-1.0.0-custom.zip
with the local path of the downloaded file.
Change these fields:
organizationId
groupId
assetId
version
name
curl -v \
-H "Authorization: Bearer ANYPOINT_TOKEN" \
-F organizationId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F groupId="fa7b266c-3817-4cbb-ae49-7f3cc6c8cd9e" \
-F assetId="custom-asset" \
-F version="1.0.0" \
-F name="custom asset name" \
-F classifier="custom" \
-F asset=@/Users/llucas/Downloads/two-factor-auth-policy-1.0.0-custom.zip \
https://anypoint.mulesoft.com/exchange/api/v1/assets
Note: the file is not necessary to be uploaded when the asset type is "Custom"
API Group
To know how to create an API Group from API Manager, please visits this link