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

Finish hook run API in Test Reporting & Analytics

Use this API to complete a hook execution with its final result, timing information, and optional failure or step-level details. The hook_type must match the value provided in the corresponding start hook run request.

Finish a hook run

PUT https://api-automation.browserstack.com/ext/v1/builds/{{BUILD_HASHED_ID}}/hooks/{{HOOK_RUN_UUID}}/finish

Request parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X PUT "https://api-automation.browserstack.com/ext/v1/builds/BUILD_HASHED_ID/hooks/HOOK_RUN_UUID/finish" \
-H "Content-Type: application/json" \
-d '{
  "hook_type": "beforeAll",
  "result": "passed",
  "finished_at": "2025-11-11T10:30:04Z",
  "file_name": "hooks/db_setup.py",
  "scopes": ["Setup"]
}'
  • hook_type* String

    Type of hook. Must exactly match the value provided in the corresponding start hook run request. Maximum 50 characters.

  • result* String

    Final result of the hook. Allowed values are passed, failed, skipped, or timeout.

  • finished_at* String (ISO 8601)

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

  • 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.

  • duration_in_ms Integer

    Total duration of the hook in milliseconds. Must be a positive integer.

  • failure Array

    Failure details when the hook result is failed. Maximum 100 failure entries.

    â–¶ SHOW VALUES
    • backtrace Array

      Stack trace of the failure as an array of strings. Maximum 1000 lines, each up to 2000 characters.

  • custom_metadata Object

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

  • environment Object

    Environment details. When provided, these values override any values set in the start hook run call.

    â–¶ 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.

  • meta Object

    Hook execution metadata including step-level details. Uses the same step structure as test runs.

    â–¶ SHOW VALUES
    • steps Array

      An array of step objects representing individual steps within the test or hook execution.

      â–¶ SHOW VALUES
      • id* String

        Unique identifier for the step within the test run.

      • keyword String

        Step keyword, typically used in BDD frameworks (for example, Given, When, Then).

      • text String

        Step description or display text.

      • started_at String (ISO 8601)

        Step start timestamp in ISO 8601 format.

      • finished_at String (ISO 8601)

        Step completion timestamp in ISO 8601 format.

      • result String

        Step result. Allowed values are passed, failed, skipped, or timeout.

      • duration Integer

        Step duration in milliseconds.

      • failure String

        Failure message or error description for a failed step. Maximum 5000 characters.

Response attributes 200 OK JSON

Response

{
  "success": true,
  "message": "Hook run finished successfully."
}
  • success Boolean

    Indicates if the hook was finished successfully.

  • message String

    A success or error message describing the result of the operation.

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