> ## Documentation Index
> Fetch the complete documentation index at: https://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
    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
        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
      required:
        - testSessionResultId
        - testSessionResultLink
        - checkType
        - errorGroupIds
        - status
        - hasErrors
        - hasFailures
        - isDegraded
        - aborted
  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]"` 

````