Use API Keys

API keys allow a technical user to be authorized when connecting to an SAP Build Process Automation service instance.

Prerequisites

  • You have a service key for the target SAP Build Process Automation service instance. For more information, see Create a Service Key for the SAP Build Process Automation Instance.

  • You have the value of an API key created for the target environment and with the required scope.

  • You have released, deployed, and started a running instance of the process in SAP Build Process Automation to which you would like to connect.

Context

You can use API keys to allow a technical user to connect to a target SAP Build Process Automation service instance. The examples below demonstrate how you can configure the API key to be sent with each HTTP request.

Collect Connection Information

  • Get the following entries from the service key for the target SAP Build Process Automation service instance that are needed to configure the authentication:

    • clientid

    • clientsecret

    • url

    ServiceKey details

  • Optional: In case you are executing an API trigger, get the URL and the definitionID of the target trigger. Go to Start of the navigation pathSAP Build Lobby Next navigation step Control Tower Next navigation step EnvironmentsEnd of the navigation path and select the desired environment. Switch to Triggers tab and choose More Options of the API trigger you want to execute, and then select View.

    API key details with the URL and Payload example

Use an API Key from an Application Running on SAP BTP

To use an API Key in requests from an application running on SAP BTP, you have to first set an additional header property in the destination that is used for these requests:

Applications created with SAP Cloud Application Programming Model (CAP)

  1. For a CAP application, create an additional property with any name, for example apiKey and your API key as a value.

  2. To read the apiKey, first call the destination service, assigning its value to the headers.api-key property.

  3. Then, send the API key in the request header.

Applications created with SAP Cloud SDK

For an SAP Cloud SDK application, you only need to create an additional property with name URL.headers.api-key and your API key as a value. For more information, see Use the HttpClient Accessor To Configure Requests To Remote Services.

Test an API Key - Execute an API Trigger Using an API client

Use an API client of your choice to send an HTTP POST request that executes the API trigger. The configuration options for different API clients might differ, but these are the most common settings that you have to provide.

Configure Authentication

Open your API client and start creating a new HTTP POST request:
  1. Enter the trigger URL.

  2. As authentication type choose OAuth 2.0. In this case you would have to connect to a URL and get the access token that will allow you to send the POST request.

  3. Choose client credentials as a way to authenticate when connecting to the access token URL.

  4. Enter the access token URL. Use the value from the url property, and append /oauth/token to it.

  5. Enter the client ID and the client secret, providing the previously copied clientid and clientsecret.

  6. Request the access token and confirm that it's issued.

Configure the API Call

Once the authentication is completed, let's configure the details of the HTTP request:
  1. Include your API key in the request headers by adding an api-key entry and assigning your API key as its value.

  2. Define the payload in the request body using the Payload example from the API trigger definition and assign some test values for the variables.

  3. Execute the request. If the request is successful, you will get "201 Created" as a response.

Result: You have successfully created a process instance via the API trigger.