Creating REST APIs

In webMethods Integration, you can trigger project workflows or flow services through API endpoints by using the REST APIs. You can build custom APIs or export existing ones, link them to your project workflows or flow services, and make API requests to run those workflows or services remotely. The Rest API builder feature works at the project level.

About this task

Explore the steps and learn how to create APIs in webMethods Integration. Select one of the following methods to create the REST APIs:
  • Create from scratch/Design new API
  • Import API/I have an existing API
  • Import API using URL

Procedure

  1. Go to the project where you want to create an API and click the APIs tab.
    You are redirected to the REST APIs page, where you see a list of any existing REST APIs for that project.
  2. Click Create API to go to the New API page and select Create from scratch/Design new API and click Next.
    The Basic Info page appears.
    • Provide a suitable name for the API you want to create in the Name field.
    • Provide a short description for the API in the Description field.
    • Provide a unique version number for this API in the Version field.
    • Mark the API as public or private in the Access option. The default value is Public. When you mark the API as Public, the API details page shows the API endpoints as two distinct URLs, Public URL and Internal URL.
      1. A Public URL is a public endpoint that is accessible externally with the internet. You can view and copy the URL details by using the icons alongside or from the JSON and YAML files under the Documentation field.
      2. The Internal URL is an internal endpoint that is accessible only from webMethods network. You can view and copy the URL details using the icons alongside or from the JSON and YAML files under the Documentation field.

      When the API is marked as Private, the API details page shows the API endpoints as two distinct URLs, Private URL and Internal URL.

      1. The Private URL is a private endpoint that is used when a private network is configured. Access is limited exclusively to your private network, preventing any outside access, including from your webMethods network or webMethods applications within your tenant. You can view and copy the URL details by using the icons alongside or from the JSON and YAML files under the Documentation field.
      2. The Internal URL is an internal endpoint that is accessible only from webMethods network. You can view and copy the URL details using the icons alongside or from the JSON and YAML files under the Documentation field.
  3. Select the content type that the API can use in the Consumes field. Currently, only application/json is supported.
  4. Select the content type that the API can produce in the Produces field. Currently, only application/json is supported. Click Save.
  5. Click Add Resource and add resources and methods to the API. Enter the resource path by using allowed special characters (The maximum path length is limited to 2048 characters.). The API resource path supports these special characters:(_) Underscore, (-) Hyphen, (.) Period, ($) Dollar sign, (!) Exclamation mark, (~) Tilde, (=) Equals sign, (:) Colon, (') Apostrophe or single quotation mark, (*) Asterisk, and (,) Comma. These characters are accepted. Ensure that the resulting API URL complies with the standard API guidelines.
  6. Choose an HTTP method like POST, GET, PUT, DELETE, or PATCH, and add a short description.
  7. Select a workflow or flow service to run with the API. Review the Parameters section to see webhook payload keys and their sources, and add descriptions. If the path includes parameters like /postdata/{n1}/{n2}, its values come from the workflow.
    • Only workflows with a webhook and tested Auto connect Return Sync on Webhook appear.
    • You can also select the flow service instead of workflow. This example describes steps that use a workflow.
  8. After you select a workflow, enter the following details:
    1. In Parameters, provide the webhook payload keys along with their sources that are associated with the selected workflow are listed in the Parameters section. In the Description field, optionally you can add a description for these keys.
      For Workflows, if the path URL has parameters in the format /postdata/{n1}/{n2}, the values of n1 and n2 are derived from the workflow parameters.
    2. In Responses, enter response statuses for failed calls and add more if needed.
      You can update and delete the existing success response code. However, if there is only one response code, it cannot be deleted.
  9. Click Done.
    The Resources and Methods page is displayed.

    You can select more than one HTTP method for a resource path in an API. For example, to use the same resource path /sample for POST and GET HTTP methods.

  10. Click Save.
    The API is successfully created.
    Note:
    • To enable the execution of an API from webMethods API Gateway, use the Internal URL under the API Endpoints, which is displayed on the Rest API page.
    • Support for domains with -internal is being deprecated soon. Reconfigure the alias in webMethods API Gateway by using the Internal URL provided under API Endpoints on the REST or SOAP API details page.
    • In an existing API, when you change the selected value for the Access field from Private to Public or Public to Private, the changes take a while to propagate for the ongoing API executions.

What to do next

Set up and enable REST APIs for your projects. First, you create a workflow that defines the process. All workflows that you want to run through API endpoints must contain both Webhook trigger and Auto connect Return Sync on Webhook action in it. After configuration, ensure you test the Auto connect Return Sync on Webhook action. Otherwise, the workflow does not appear in the list of workflows available for execution through REST APIs. Use the API that is created to expose that workflow. Finally, you run the workflow by using API calls. These steps help you connect and automate your project tasks efficiently.