> ## Documentation Index
> Fetch the complete documentation index at: https://www.checklyhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Await the completion of a test session

> Call this endpoint to await the completion of a test session. A successful response code will be returned once the test session reaches its final state (i.e. when it passes or fails).

If the test session takes a long time to complete, the endpoint will return a timeout error code. You should keep calling the endpoint until you receive a successful response, or a non-timeout related error code. If using *curl*, its `--retry` option is suitable.

The successful response of this endpoint is equivalent to the `GET /v1/test-sessions/{testSessionId}` endpoint's response for a completed test session.



## OpenAPI

````yaml get /v1/test-sessions/{testSessionId}/completion
openapi: 3.0.0
info:
  title: Checkly Public API
  version: v1
  description: >-
    These are the docs for the newly released Checkly Public API. If you have
    any questions, please do not hesitate to get in touch with us.
servers:
  - url: https://api.checklyhq.com
security:
  - Bearer: []
tags: []
paths:
  /v1/test-sessions/{testSessionId}/completion:
    get:
      tags:
        - Test sessions
      summary: Await the completion of a test session
      description: >-
        Call this endpoint to await the completion of a test session. A
        successful response code will be returned once the test session reaches
        its final state (i.e. when it passes or fails).


        If the test session takes a long time to complete, the endpoint will
        return a timeout error code. You should keep calling the endpoint until
        you receive a successful response, or a non-timeout related error code.
        If using *curl*, its `--retry` option is suitable.


        The successful response of this endpoint is equivalent to the `GET
        /v1/test-sessions/{testSessionId}` endpoint's response for a completed
        test session.
      operationId: getV1TestsessionsTestsessionidCompletion
      parameters:
        - schema:
            type: string
            format: uuid
            description: Test session ID.
          required: true
          description: Test session ID.
          name: testSessionId
          in: path
        - schema:
            type: number
            minimum: 1
            maximum: 30
            description: >-
              Maximum time to wait for completion before returning a retryable
              timeout response.
          required: false
          description: >-
            Maximum time to wait for completion before returning a retryable
            timeout response.
          name: maxWaitSeconds
          in: query
        - schema:
            type: string
            format: uuid
            description: >-
              Your Checkly account ID, you can find it at
              https://app.checklyhq.com/settings/account/general
          required: false
          description: >-
            Your Checkly account ID, you can find it at
            https://app.checklyhq.com/settings/account/general
          name: x-checkly-account
          in: header
      responses:
        '200':
          description: Successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AwaitTestSessionCompletionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '408':
          description: Request Timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
components:
  schemas:
    AwaitTestSessionCompletionResponse:
      type: object
      properties:
        testSessionId:
          type: string
          format: uuid
        testSessionLink:
          type: string
          format: uri
        name:
          type: string
        status:
          type: string
          enum:
            - FAILED
            - PASSED
            - CANCELLED
        errorGroupIds:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of the test-session error groups observed in this test session.
        startedAt:
          type: string
          nullable: false
          format: date-time
        stoppedAt:
          type: string
          nullable: false
          format: date-time
        timeElapsed:
          type: number
        metadata:
          $ref: '#/components/schemas/TestSessionMetadata'
        results:
          type: array
          items:
            $ref: '#/components/schemas/TestSessionResult'
      required:
        - testSessionId
        - testSessionLink
        - name
        - status
        - errorGroupIds
        - startedAt
        - stoppedAt
        - timeElapsed
    ApiError:
      type: object
      properties:
        statusCode:
          type: number
        error:
          type: string
        message:
          type: string
      required:
        - statusCode
        - error
        - message
    TestSessionMetadata:
      type: object
      properties:
        environment:
          type: string
          minLength: 1
          description: A short description for the testing environment.
        repoUrl:
          type: string
          nullable: true
        commitId:
          type: string
          nullable: true
        commitOwner:
          type: string
          nullable: true
        commitMessage:
          type: string
          nullable: true
        branchName:
          type: string
          nullable: true
        github:
          $ref: '#/components/schemas/TestSessionGitHubMetadata'
    TestSessionResult:
      type: object
      properties:
        testSessionResultId:
          type: string
          format: uuid
        testSessionResultLink:
          type: string
          format: uri
        checkId:
          type: string
          nullable: true
          format: uuid
        checkType:
          type: string
          enum:
            - AGENTIC
            - API
            - BROWSER
            - HEARTBEAT
            - ICMP
            - MULTI_STEP
            - TCP
            - PLAYWRIGHT
            - URL
            - DNS
            - SSL
            - GRPC
            - TRACEROUTE
        name:
          type: string
        runLocation:
          type: string
        errorGroupIds:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of the test-session error groups associated with this result.
        resultType:
          type: string
          enum:
            - FINAL
            - ATTEMPT
            - PENDING
        status:
          type: string
          enum:
            - RUNNING
            - FAILED
            - PASSED
            - CANCELLED
        hasErrors:
          type: boolean
        hasFailures:
          type: boolean
        isDegraded:
          type: boolean
        aborted:
          type: boolean
        responseTime:
          type: number
          nullable: true
          description: >-
            Time the check spent producing its result, in milliseconds. For
            protocol checks this is the measured operation time (a subset of the
            run): request time for API and URL checks, connection time for TCP,
            resolution time for DNS, average latency for ICMP and TRACEROUTE,
            request timing for GRPC, and TLS handshake time for SSL. For
            browser, multi-step, Playwright and agentic checks it is the run
            wall-clock duration. Null until the check has finished. For the
            total wall-clock time a check run took, use `stoppedAt` -
            `startedAt`.
        startedAt:
          type: string
          nullable: true
          format: date-time
          description: When the check run started. Null until the check has started.
        stoppedAt:
          type: string
          nullable: true
          format: date-time
          description: >-
            When the check run finished. Subtract `startedAt` for the total
            wall-clock duration of the run. Null until the check has finished.
      required:
        - testSessionResultId
        - testSessionResultLink
        - checkType
        - errorGroupIds
        - status
        - hasErrors
        - hasFailures
        - isDegraded
        - aborted
    TestSessionGitHubMetadata:
      type: object
      properties:
        reporting:
          type: boolean
        repository:
          type: string
          nullable: true
        sha:
          type: string
          nullable: true
        runId:
          type: string
          nullable: true
        runAttempt:
          type: string
          nullable: true
        workflow:
          type: string
          nullable: true
        job:
          type: string
          nullable: true
        eventName:
          type: string
          nullable: true
        ref:
          type: string
          nullable: true
        headRef:
          type: string
          nullable: true
        baseRef:
          type: string
          nullable: true
        serverUrl:
          type: string
          nullable: true
      required:
        - reporting
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: Bearer
      description: >-
        The Checkly Public API uses API keys to authenticate requests. You can
        get the API Key
        [here](https://app.checklyhq.com/settings/user/api-keys). Your API key
        is like a password:  keep it secure!

        Authentication to the API is performed using the Bearer auth method in
        the Authorization header and using the account ID.

        For example, set **Authorization** header while using cURL: `curl -H
        "Authorization: Bearer [apiKey]" "X-Checkly-Account: [accountId]"` 

````