---
parser: v2
auto_validation: true
time: 20
tags: [ tutorial>beginner, software-product>sap-business-technology-platform, software-product>sap-btp--cloud-foundry-environment]
primary_tag: software-product>sap-integration-suite
author_name: Melanie Cueppers
author_profile: https://github.com/MelanieCueppers
slug: cp-starter-isuite-api-management
canonical_url: https://developers.sap.com/tutorials/cp-starter-isuite-api-management
---

# Expose Integration Flow Endpoint as API and Test the Flow
<!-- description --> Define the endpoint of the integration flow developed in the last tutorial as an application programming interface (API).

## Prerequisites
 You've created and deployed an integration flow that reads product details using an OData connection. For more information, see [Design and Deploy Your First Integration Flow](cp-starter-integration-cpi-design-iflow).

## You will learn
  - How to define and expose an integration flow endpoint as an API
  - How to assign a policy to your API

## Context
In this tutorial, you will define the endpoint of the integration flow developed in the last tutorial as an application programming interface (API).

## Intro
In addition, you will assign a policy template to the API to define how the API is called. A policy defines, for example, how an API can be called. In this tutorial, you assign a policy that defines an authentication of the API according to OAuth 2.0 client credentials grant. It is a secure way to control access to an API.

After you've performed these steps, finally, you will call the API to fetch the product details.

---

### Get endpoint of the integration flow

In this step, you copy the endpoint address of the integration flow.

1. Open your integration flow.

2. In the **Deployment Status** tab of the property sheet, choose the navigation link.

    ![Access Deployed Artifact](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/1-2-access-deployed-artifacts.png)

3. In the **Endpoints** tab, choose the **Copy** icon.

    ![Endpoint URL](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/1-3-copy-endpoint-url.png)




### Define the API

In this step, you define and expose an integration flow endpoint as an application programming interface (API).

1. To provision the API Management capability, go to **Settings** > **Runtimes** and choose **Activate**. The provisioning might take a few seconds to complete. After the provisioning is complete, refresh your webpage.
> The page is available only if you're provisioning the capability as a **first-time user**. If API Management is already provisioned in your subaccount, continue with the next step.

2. Go to **Configure** > **APIs** and choose **Create** to create an API proxy.

3. On the **Create API** dialog, next to **Select**, select **URL** and specify the following parameters:

    >**IMPORTANT**: Paste only the endpoint URL until **`/http/products`**. Otherwise, the scenario will not run correctly.

    |  Parameter    | Settings
    |  :------------- | :-------------
    |  URL           | Paste the integration flow endpoint address you have copied in **step 1**. It ends with **`/http/products/details`**. Paste the endpoint URL only until **`/http/products`** instead of **`/http/products/details`**.
    |  Name           | **`RequestProductDetails`**
    |  Title    | **`Product Details API`**
    |  API Base Path          | **`/products`**

    ![Create API](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/2-4-create-api-new.png)

    Select **Create**.

4. On the landing page, go to the **Resources** tab and choose **Add**.

    ![Add resources](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/2-5-create-api-resources.png)

5. In the field **Tag**, enter **`Product Details`**, and in the field **Path Prefix** enter **`/details`**.  

    ![Add details](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/2-6-add-resources.png)

6. Under **Operations**, delete all tabs except the **POST** tab and choose **OK**.

    ![Add operations](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/2-7-save-resources.png)

    The API resource is displayed.

7. Choose **Deploy** to create and activate the API proxy for your integration flow.

    ![Deploy](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/009.png)

8. Choose the **POST** operation to display more details on the API. A default API definition in Open API specification format is also generated.

9. To update the generated API definition in Open API format, choose **Edit** > **Edit in API Designer**.

    ![Edit API designer](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/010.png)

    The API designer opens.

10. In the editable section on the right part of the screen, make the following changes.

    Change the key **Payload** in line 37 to **`productIdentifier`**. Then, add a new row after **type** with the following key-value pair: `example: HT-2000`

    >**TIP**: Instead of copying the example, type it manually.

    ![change product identifier before](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/011-before.png)

    ![change product identifier after](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/011-after.png)

    Choose **Save**.

11. Choose **`RequestProductDetails`** and then the **Resources** tab. Then, choose **Edit** > **Edit in API Designer**.

    Now choose the **POST** request. You notice the API changed, in particular, the request body now contains one element with a product identifier.

    ![Resources Tab API Changes](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/014.png)

12. When you choose **Try Out** and then **Execute**, since no authentication details have been configured, you get an error message with error code 401 (not authorized). We will fix this error in the next steps of this tutorial.

    ![Error message](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/015.png)

    With this step, you have successfully created an API proxy for your integration flow and generated an API documentation for your REST API in **`OpenAPI`** format.


### Copy credentials from service key

 In this step, you'll copy the client ID, client secret, and token URL from the service key that you automatically generated in your SAP BTP account. See [Set Up SAP Integration Suite Trial](cp-starter-isuite-onboard-subscribe).

1. In your SAP BTP subaccount, navigate to your service instance page. Choose **Services** > **Instances and Subscriptions**.

2. Under the **Instances** section, look out for the service instance that was created. Choose the key under the **Credentials** column to open the service key.

      ![view key](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/3-2-key-view.png)

    >**TIP**: In trial accounts, the default name that the booster provides for the service instance is **default-it-rt-integration-flow**. In free tier accounts, the instance name is user defined.

3. Copy the values of the **`clientid`**, **`clientsecret`** and **`tokenurl`** parameters. These are the credentials that you later use to make a request to your integration flow.

      ![Copy clientid and clientsecret](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/3-3-copy-clientid-secret-tokenurl.png)


### Assign policy template

In this step, you assign a policy template to your API to specify authentication details for the API call. In particular, you use a policy template that defines that the caller of the API authenticates itself using OAuth 2.0 client credentials grant.

This grant type works in the following way: In a first call, the API client provides the values of **`clientid`** and **`clientsecret`** (from the service key generated in step 1) to a token service (the URL of the token service is also contained in the service key definition). The token service provides an access token to the API client. In a subsequent call, the API client calls the integration flow endpoint providing the access token. If the access token is valid, the API client is authorized to call the integration flow.

1. Choose **Discover** > **APIs**.

2. Search for the package **Connect to SAP Business Technology Platform Services** and select it.

    ![choose API](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/017.png)

3. Navigate to **Artifacts** tab, where you find one artifact.

4. Under **Actions**, choose **Copy**.

    ![Actions](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/019.png)

5. Once the artifact was copied successfully, go to **Configure** > **APIs**.

6. Choose the API that you created in the previous step.

    ![API Proxy](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/021.png)

7. Choose **Edit**.

    ![Edit](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/022.png)

8. Select **Policies**.

    ![Policies ](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/023.png)

    The policy editor opens.

9. Choose **Policy Template** > **Apply**.

    ![Policy Template](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/024.png)

10. Select the template **`Cloud_Platform_Connectivity`** and choose **Apply**.

    ![add Template](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/025.png)

11. Open the node **Target Endpoint**.

    ![TargetEndPoint](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/026.png)

12. Choose **`PreFlow`**.

    ![PreFlow](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/027.png)

13. In the editor, the OAuth workflow defined by the policy is visualized as a graphical model.

    Now, you need the values copied from the service key: **`clientid`**, **`clientsecret`** and **`tokenurl`**.

14. In the graphical model of the **Policy Editor**, choose the **`getcredential`** shape.

    ![Graphic Model](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/028.png)

15. Paste the value of **`clientid`** and **`clientsecret`** as shown in the following image.

    ![Values](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/029.png)

16. In the policy editor, choose the **`getoauthtoken`** shape.

    ![token](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/030.png)

17. Paste the value of **`tokenurl`** as shown in the following screenshot.

    >**Note**: Make sure that you append **`?grant_type=client_credentials`** to the token URL that you pasted.

    ![tokenURL](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/031.png)

18. Select **Update**.

    ![tokenURL](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/032.png)

19. Select **Save**.

    ![Save](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/033.png)

20. To deploy your changes, choose **Click to Deploy** in the message strip at the top of the screen.

    ![Save](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/033_New.png)

21. Confirm the deployment.

    You've now assigned a policy template to your API.



### Execute the API


In this step, you try out the API to get product details as a response from the web shop.

1. Go to the **Resources** tab.

    ![ResourceTab](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/034.png)

2. Choose **Try Out**.

    ![try out](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/035.png)

3. Choose **Execute**.

    ![Execute](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/036.png)

4. As result, you see the response from the **`WebShop`** with the product details for the given product identifier.

    ![WebShop](https://raw.githubusercontent.com/sap-tutorials/btp-adai/main/tutorials/cp-starter-isuite-api-management/037.png)


### Congratulations!

You have successfully set up your SAP Integration Suite tenant, designed a simple integration flow that reads data from a remote component, and defined the integration flow endpoint as an API. Finally, you have successfully called the API to get product details as a response from the remote component.

This scenario showed you how to use SAP Integration Suite, and in particular, its Cloud Integration and API Management capabilities seamlessly integrated, end-to-end.


---



---
