This documentation is for WSO2 API Manager 2.0.0. View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

API creation is the process of linking an existing backend API implementation to the API Publisher so that you can manage and monitor the API's lifecycle, documentation, security, community and subscriptions. Alternatively, you can provide the API implementation in-line in the API Publisher itself.

Click the following topics for a description of the concepts that you need to know when creating an API:

The steps below show how to create a new API.

  1. Log in to the API Publisher.
  2. In the APIS menu, click Add New API.
  3. Select the option to design a new API and click Start Creating.
  4. Give the information in the table below and click Add to add the resource.

    FieldSample value

    API context is used to uniquely identify the API by the gateway. API context should be unique. This context is the API's root context when invoking the API through gateway.

    Tip: You can define the API's version as a parameter of its context by adding the {version} into the context. For example, {version}/phoneverify. The API Manager assigns the actual version of the API to the {version} parameter internally. For example, https://localhost:8243/1.0.0/phoneverify. Note that the version appears before the context, allowing you to group your APIs according to versions.


    phone, checkNumbers

    Tags can be used to filter out APIs matching some search criteria. We recommend adding tags which explain the functionality and purpose of the API. Subscribers can search APIs based on tags.

    ResourcesURL patternCheckPhoneNumber
    Request types


    The selection of HTTP method should match with the actual back end resource. For example, if the actual back end contains the GET method to get details of an phone number, then that resource should be matched with an GET resource type and with proper context

    Import or Edit API definition

    To import an existing swagger definition from a file or a URL, click Import. Click Edit Source to manually edit the API swagger definition.

  5. After the resource is added, expand its GET method and update the Produces to application/xml and Consumes to application/json

    We define MIME types in the resource definition. Consumes refers to the MIME type of request accepted by the backend service and Produces refers to the MIME type of response produced by the backend service which you define as the endpoint of the API.

     Next, add the following parameters. You use these parameters to invoke the API using our integrated API Console in later tutorials. 

    Parameter NameDescriptionParameter TypeData TypeRequired
    PhoneNumberGive the phone number to be validatedQueryStringTrue
    LicenseKeyGive the license key as 0 for testing purposeQueryStringTrue

    You can define the following parameter types for resource parameters you are adding.

    Parameter TypeDescription
    queryContains the fields added as a Part of the invocation URL that holds data to be used to call the backend service.
    headerContains the case-sensitive names followed by a colon (:) and then by it's value which carries additional information with the request which defines the operating parameters of the transaction.
    formDataContains a property list of attribute names and values which includes in Message body.
    bodyAn arbitrary amount of data of any type which sends with a POST message

    And you can use following as Data type categories supported by swagger.

    1. primitive (input/output)
    2. containers (as arrays/sets) (input/output)
    3. complex (as models) (input/output)
    4. void (output)
    5. File (input)


    By design HTTP POST method specifies that the web server accepts data enclosed within the body of the request, hence when adding a POST method API manager adds the payload parameter to the POST method by default.

    Import or edit API definition

    The “Import" button allows to define resources of the API using an existing swagger definition. Once the swagger is imported as file or from URL, the resources will be automatically added. And "Edit Source" button allows to edit the API swagger definition.

    Once done, click Next: Implement > Alternatively, click Save to save all the changes made to the API. You can come back later to edit it further by selecting the API and clicking Edit. For details about the states of the API see Manage the API Lifecycle .

  6. Click the Managed API option.

  7. The Implement tab opens. Give the information in the table below.

    FieldSample value
    Endpoint typeHTTP/REST endpoint
    Production endpoint

    This sample service has two operations as CheckPhoneNumber and CheckPhoneNumbers. Let's use CheckPhoneNumber here.

    To verify the URL, click the Test button next to it.  (This is the actual endpoint where the API implementation can be found)

    Sandbox endpoint

    This sample service has two operations as CheckPhoneNumber and CheckPhoneNumbers. Let's use CheckPhoneNumber here.

    To verify the URL, click the Test button next to it.

    You can deploy your API as a Prototyped API in the Implement tab. A prototyped API is usually a mock implementation made public in order to get feedback about its usability. You can implement it Inline or by specifying an endpoint.

    Users can invoke the API without a subscription after publishing the API to the Store. For more information refer Deploy and Test as a Prototype.

  8. Click Next: Manage > and give the information in the table below.

    FieldSample valueDescription
    TransportsHTTP and HTTPS

    The transport protocol on which the API is exposed. Both HTTP and HTTPS transports are selected by default. If you want to limit API availability to only one transport (e.g., HTTPS), un-check the other transport.

    You can only try out HTTPS based APIs via the API Console, because the API Store runs on HTTPS.

    Subscription TiersSelect allThe API can be available at different levels of service. They allow you to limit the number of successful hits to an API during a given period.

    Make Default Version

    Make this the default version makes the api available in the gateway without version in the production and sandbox urls. This feature allows you to create a new version of API and make it as default version and in the client applications you can invoke the same resources without changing the API gateway URL. This allows to create new versions of API with changes and make it allow for existing clients application without client have to change the URLs.

    See Working with Throttling for more information about maximum backend throughput and advanced throttling policies.

  9. Click Save & Publish. This publishes the API that you just created to the API Store so that subscribers can use it.

    You can save partially complete APIs or save completed APIs without publishing them. Select the API and click on the Lifecycle tab to manage the API Lifecycle. For more details about the states of the API see API lifecycle.

You have created an API.

  • No labels