Triggering Scheduled Runs with APIs

Updated by Kashif Hussain

Trigger your schedules from the comfort of your systems using curl commands. We hear your feedback and wish to make your automation process as swift and effective as possible.

For all commands, you will need your Sofy authentication key handy. Here's how to find it:

  • x-sofy-auth-key: To retrieve your subscription key, navigate to Account > Account Settings > API Key.

Guide: Running Scheduled Runs Using cURL Commands

Follow these steps to fetch your data and trigger scheduled runs on Sofy devices using cURL commands. Ensure you replace placeholder values with actual data from your subscription.

1. Fetch the List of All Applications and Builds for Your Subscription

Use this command to retrieve details about all applications and their respective builds in your subscription:

curl --location 'https://public.sofy.ai/application-microservice/public/applications' \
--header 'x-sofy-auth-key: <your-auth-key>'

Example Response:

{
"data": [
{
"application_guid": "6448AE05-AE5E-48C0-A1B1-B1E7266CDA6C",
"platform_name": "ANDROID",
"application_friendly_name": null,
"application_builds": [
{
"app_hash": "4dde068421cce336876808763aa19239",
"build_id": "2.3.6(203060)",
"build_friendly_name": null,
"build_package_name": "io.bramerz.kfc"
},
{
"app_hash": "0c979ce52c65d5f0b26a01df1cdbd1d7",
"build_id": "2.3.2(203020)",
"build_friendly_name": null,
"build_package_name": "io.bramerz.kfc"
}
]
}
],
"message": "Fetched 2 record(s)"
}

2. Fetch the List of Available Devices by OS

Retrieve details of all devices in your subscription (including offline devices), such as OS version, manufacturer, name, and device ID. Replace ANDROID with the appropriate OS if needed:

curl --location 'https://public.sofy.ai/device-microservice/public/devices/ANDROID' \
--header 'x-sofy-auth-key: <your-auth-key>'

Example Response:

{
"data": [
{
"os_version": "T13",
"manufacturer": "Google",
"device_name": "Google Pixel 6",
"device_serial": "xxxxxxxxxxxxx",
"STATE": "ONLINE"
},
{
"os_version": "15",
"manufacturer": "Google",
"device_name": "Google Pixel 8",
"device_serial": "xxxxxxxxxxxxx",
"STATE": "ONLINE"
},
{
"os_version": "S12",
"manufacturer": "Google",
"device_name": "Google Pixel 3a XL",
"device_serial": "xxxxxxxxxxxxx",
"STATE": "ONLINE"
}
],
"message": "Devices fetched successfully"
}

3. Retrieve All ScheduledRunGUIDs for Each App

To retrieve the ScheduledRunGUIDs for a specific build, replace appHash with the actual App Hash from Step 1:

curl --location 'https://ca-pub-gateway-stag-eastus2-001.happyriver-eac353b2.eastus2.azurecontainerapps.io/scheduler-microservice/public/via-app/8CBF99C0-BCF5-48E1-AF2B-7453FBC1A70F' \
--header 'x-sofy-auth-key: <your-auth-key>'
  • Example Response:

    {
    "data": [
    {
    "scheduled_guid": "5822858B-D15E-42F9-A555-032C8508765F",
    "name": "scenario-63"
    }
    ],
    "message": "Fetched 1 record(s)."
    }

4. Trigger a Scheduled Run

To execute a scheduled run with selected devices and build parameters, replace the following placeholders in the command:

  • :scheduledGUID with the ScheduledRunGUID from Step 3 or Step 4
  • :appHash with the Application Hash from Step 1
  • :deviceSerials with a comma-separated list of device IDs from Step 2
curl --location --request POST 'https://public.sofy.ai/scheduler-microservice/scheduled-runs/:scheduledGUID/execute?appHash=:appHash&deviceSerials=:deviceSerials' \
--header 'x-sofy-auth-key: <your-auth-key>'
  • Example Response:

{
"data": [
{
"testRunsGroupId": "xxxxxx"
}
],
"message": "Test runs are scheduled and in queue. Login to https://portal.sofy.ai for more info."
}

Notes

  1. Ensure all placeholder values are replaced with actual data before executing commands.
  2. If you encounter any issues, check the API documentation or contact support for assistance.
  3. The list of devices retrieved includes both online and offline devices. Make sure the selected devices are online for successful execution.

By following these steps, you can efficiently manage and execute scheduled runs using cURL commands on Sofy.


How did we do?