Skip to main content
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Start hook run API in Test Reporting & Analytics

Use this API to start a hook execution within a build. Hooks represent setup or teardown operations such as database setup, environment configuration, or cleanup. Returns a uuid required for the finish hook run call and for associating logs with this hook.

Start a hook run

POST https://api-automation.browserstack.com/ext/v1/builds/{{BUILD_HASHED_ID}}/hooks/start

Request parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-automation.browserstack.com/ext/v1/builds/BUILD_HASHED_ID/hooks/start" \
-H "Content-Type: application/json" \
-d '{
  "hook_type": "beforeAll",
  "name": "Database setup",
  "file_name": "hooks/db_setup.py",
  "scopes": ["Setup"],
  "started_at": "2025-11-11T10:30:02Z"
}'
  • hook_type* String

    Type of hook (for example, beforeEach, afterEach, beforeAll, afterAll, beforeTest, afterTest, setup, teardown). Maximum 50 characters.

  • name* String

    Name of the hook. Maximum 500 characters.

  • file_name* String

    Name of the hook file. Maximum 1000 characters.

  • scopes* Array

    Hook scopes. Between 1 and 20 scopes, each up to 100 characters.

  • started_at* String (ISO 8601)

    Hook start timestamp in ISO 8601 format (for example, 2025-11-11T10:31:10Z).

  • test_run_id String

    UUID of the associated test run, if this hook is specific to a single test.

  • tags Array

    Hook tags for categorization. Maximum 50 tags.

  • location String

    Hook location or file path, including line number. Maximum 1000 characters.

  • custom_metadata Object

    Custom key-value metadata. Maximum 25 keys, 10 values per key, 500 characters per key or value.

  • environment Object

    Details about the environment in which the hook runs.

    â–¶ SHOW VALUES
    • device String

      Device name used to run the test. Maximum 100 characters.

    • os String

      Operating system used to run the test. Maximum 100 characters.

    • os_version String

      Operating system version. Maximum 50 characters.

    • browser String

      Browser used to run the test. Maximum 100 characters.

    • browser_version String

      Browser version. Maximum 50 characters.

Response attributes 200 OK JSON

Response

{
  "success": true,
  "uuid": "5e0c5f1a-3b4d-4f2e-9e8a-1c2d3e4f5a6b"
}
  • success Boolean

    Indicates if the hook was started successfully.

  • uuid String

    UUID for the hook run. Use this value as the hookRunUuid path parameter in the finish hook run API call, and as the hook_run_uuid field when adding logs for this hook.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Download Copy Check Circle