Using a service account to run tasks

Use a service account to run tasks in the following endpoint: https://api.<env>

Before you begin

About this task

In this section, the following API call is issued:

method: POST
endpoint:  https://api.<env>
headers: {
 "Content-Type": "application/json",
 "Authorization": "Bearer <service_account_token>"
payload: {
  "executable": "id_of_the_task_to_be_run",
  "logLevel": "WARN"

It is implemented in Talend API Tester for demonstration purposes.

In Talend API Tester, you can use an expression builder to dynamically retrieve the service account token from its related API request.


  1. Select POST from the Method list and in the field aside, enter the user management endpoint to be used: https://api.<env> service account run task

  2. Click Add header. In the name field that is displayed, enter Content-Type and in the value field, enter application/json.

  1. Click Add header and in the name field that is displayed, enter Authorization and in the value field, enter Bearer and the service account access token in plain text or click the expression builder icon to build a dynamic expression. Enter a whitespace to separate Bearer and the token.

    Since you need to renew the token once the current one expires, it is recommended to use an expression to enable this API request to dynamically use the latest token once it is renewed by the token API request. expression builder renew token

    In Talend API Tester, you can use the expression builder to write the expression. Note that the token API request must have been saved in your repository. In the previous section, this API request was saved and named as Renew the SAT.

    This makes the value of Authorization look like this:

    Bearer ${"service-account 2021"."Service Account Token scenario"."Renew the SAT"."response"."body"."access_token"}
4. In the BODY area, enter the information that specifies the task to be run by the service account. { "executable": "id_of_the_task_to_be_run", "logLevel": "WARN" }
In this example, no parameters are specified in the body so that this task run uses the default parameters created during the creation of the task. If you need to use custom values for your task parameters, such as connection parameters, add these parameters to the body, for example:
{ "parameters": [ { "name": "authentication_type", "value": "Basic", "encrypted": false }, { "name": "basic_username", "value": "my_user_name", "encrypted": false }, { "name": "basic_password", "value": "my_password", "encrypted": true }, { "name": "basic_security_token", "value": "my_salesforce_security_token", "encrypted": true } ] }
5. Send and save the request.


The ID of this run is returned with the status code 201.

  "executionId": "16fefb53-035a-4249-af9d-f80a3b47b132"

What to do next

Use this ID at the endpoint /executions/{runId}/logs to monitor this task run. For further information, see Monitoring task runs in Talend Cloud Management Console