Skip to main content

Webhooks Integration

The Sauce Labs Webhooks integration allows you to specify a URL to which Sauce Labs will push test result data as it becomes available, rather than forcing you to constantly poll for updates.

What You'll Need

Configure a Webhook

  1. From your Sauce Labs account, navigate to the Account Integrations page.
  2. Click the Webhooks Configure button.
  3. Click the + New Configuration button to create a new webhook, or find the webhook you wish to edit, and click the pencil icon associated with the webhook.
  4. Fill the form:
    1. enter the URL of the endpoint to which you would like Sauce Labs events pushed.
    2. select the event you wish to receive
      • Virtual Device Automation | Failed tests only: Receive information about failed jobs run on Sauce Labs desktop browsers and mobile emulators and simulators.
      • Virtual Device Automation | All tests: Receive all test result events for jobs run on Sauce Labs desktop browsers and mobile emulators and simulators.
      • Real Device Automation | Failed tests only: Receive information about failed test events for Appium jobs run on Sauce Labs real devices.
      • Real Device Automation | All tests: Receive all test result events for Appium jobs run on Sauce Labs real devices.
      • Visual Testing | Build completed: Receive information about Visual build once it is finished and its status is available.
    3. select whose events you wish to receive
      • specific user or service accounts: all users can create a webhook for themselves, team admins can create webhooks for each account within their team, and organinaztion admins can create a webhook for each account within the organization
      • specific team: team admins can create webhooks for their team, and organinaztion admins can create a webhook for each team within the organization
      • entire organization: only organization admins can create webhooks with organization scope
  5. Click Save to complete your configuration.

Delete a Webhook

  1. From your Sauce Labs account, navigate to the Account Integrations page.
  2. Click the Webhooks Configure button.
  3. Find the webhook you wish to delete, and click the trashcan icon associated with the webhook.

Security tokens

Retrieve a security token for a specific webhook

  1. From your Sauce Labs account, navigate to the Account Integrations page.
  2. Click the Webhooks Configure button.
  3. Find the webhook you wish to retrieve a security token for, and click the Show security token button associated with the webhook.
  4. Click on the copy icon next to the security token to copy the secret to clipboard.

Ensure a specific request is coming from Sauce Labs

A header saucelabs-sign is added to each webhook POST request which contains the request body signed with the webhook secret. To confirm the request indeed comes from Sauce Labs, a new signature needs to be generated and compared to the received signature. The code below show how to generate a signature in Python:

import hashlib
from hmac import new

expected_signature = new([WEBHOOK_SECURITY_TOKEN].encode("utf-8"), [PAYLOAD_JSON].encode("utf-8"), hashlib.sha256).hexdigest()

Event Payload

Virtual and Real Device Automation events

Each event sends a POST request containing the job object with the following data fields as its payload:

Data FieldFormatDescription
idSTRINGSauce Labs unique identifier of the test.
creation_timeDATE-TIMEThe date-time value, in YYYY-MM-DDTHH:mm:ssZ format, at which the test launched.
modification_timeDATE-TIMEThe date-time value, in YYYY-MM-DDTHH:mm:ssZ format, at which the test changed. This is typically due to a change in status, which triggers a new event and new webhook post.
ownerSTRINGThe Sauce Labs user who initiated the test.
owner_idSTRINGThe unique identifier of the test owner.
org_idSTRINGThe unique identifier of the Sauce Labs organization to which the test owner belongs.
team_idSTRINGThe unique identifier of the Sauce Labs team of which the test owner is a member.
team_nameSTRINGThe name of the team of which the test owner is a member.
group_idSTRINGThe unique identifier of the Sauce Labs group of which the test owner is a member.
statusENUMThe status of the test at the time the webhook event was triggered. Possible values are:
  • COMPLETE
  • PASSED
  • FAILED
  • ERRORED
passedBOOLEANIf the test includes pass/fail assertions, this field states whether the test passed. This field is optional, possible values are:
  • 1 true
  • 0 false
  • null
nameSTRINGThe name of the test.
browser_nameSTRINGThe browser in which the test ran.
browser_versionINTEGERThe version of the browser in which the test ran.
os_nameSTRINGThe operating system on which the test ran.
os_versionSTRINGThe version of the operating system on which the test ran.
duration_secINTEGERThe length of time that the test took to complete. This value is only populated in the final event push for the test.
visibilityENUMWho within the Sauce Labs organization can see the test. Possible values are:
  • PUBLIC
  • PUBLIC RESTRICTED
  • SHARE
  • TEAM
  • PRIVATE
See Sharing Test Results for visibility definitions.
tagsARRAYA set of string values representing custom labels for the test.
deviceSTRINGFor mobile app tests, the Sauce Labs unique identifier of the device on which the test was run.
appSTRINGThe App Storage identifier of uploaded test materials, such as the mobile app under test or a project test file.
errorSTRINGAn error that occurred during the test.
exceptionSTRINGAn exception that was thrown during the test.
commit_idSTRINGCommit information related to your development repo, if you have added the custom-data.commit capability to your test. Currently this field is not supported for RDC events and it will always appear as an empty string.
branch_nameSTRINGThe relevant branch of the referenced commit, if you have added the custom-data.branch capability to your test. Currently this field is not supported for RDC events and it will always appear as an empty string.
buildSTRINGA custom value that can group multiple related tests.
automation_backendSTRINGThe framework on which the test is run. Currently this field is not supported for RDC events and it will always appear as an empty string.
data_typeENUMThe type of event that triggered the webhook. Possible values are:
  • vdc
  • rdc

Visual Testing Build completed event

Data FieldFormatRequiredDescription
org_idSTRINGTRUEBuild owner's Sauce Labs organization id.
user_idSTRINGTRUEBuild owner's Sauce Labs user id.
team_idARRAYTRUEBuild owner's Sauce Labs active team id.
build_idSTRINGTRUESauce Labs unique identifier of the build.
build_nameSTRINGTRUEThe name that was given to the build.
build_urlSTRINGTRUEDirect link to the build in the Sauce Labs dashboard.
statusENUMTRUEStatus of the build. Possible values are:
  • APPROVED
  • EMPTY
  • EQUAL
  • ERRORED
  • QUEUED
  • REJECTED
  • UNAPPROVED
branchSTRINGFALSEThe name of the branch.
projectSTRINGFALSEThe name of the project.
summaryJSONTRUEContains the number of the snapshots of the following statuses: errored, approved, equal, rejected, unapproved, queued
data_centerSTRINGTRUEData center where the build was executed. Possible values are:
  • us-west-1
  • eu-central-1
  • us-east-1