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

# Get a job

> Returns the current status of a query job. The job_id from either the `200` or `202` execute response resolves here. When the job is completed, the response includes download references for the result; while it is still running, only the status is returned.




## OpenAPI

````yaml /developer-docs/api-reference/trustfusion-openapi-schema-1.0.0.yaml get /v1/query/jobs/{job_id}
openapi: 3.0.3
info:
  title: TrustFusion Facets API
  description: >
    API for all facets exposed by TrustFusion, including:


    - **Query**: Validate queries against validation rules, execute governed
    semantic queries

    - **Schema**: Discover semantic models, datasets, fields, relationships, and
    metrics

    - **Threats**: Discover threats and fetch a threat's investigation template
    or advisory by ID


    All endpoints require a valid Cognito JWT token.
  version: 1.0.0
servers:
  - url: https://devx.{environment}.oleria.io
    description: Oleria DevX Server
    variables:
      environment:
        default: prod
        description: Environment name (prod, staging, dev)
        enum:
          - prod
          - staging
          - dev
security:
  - clientCredentials: []
paths:
  /v1/query/jobs/{job_id}:
    get:
      tags:
        - Query
      summary: Get a job
      description: >
        Returns the current status of a query job. The job_id from either the
        `200` or `202` execute response resolves here. When the job is
        completed, the response includes download references for the result;
        while it is still running, only the status is returned.
      operationId: GetQueryJob
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
          description: The job identifier returned by the execute endpoint.
          example: athn_a1b2c3d4-e5f6-7890-abcd-ef1234567890
      responses:
        '200':
          description: >
            Job status and results. Check `status` to determine job state. When
            `running` or `pending`, poll again after `retry_after` seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryJobResponse'
              examples:
                pending:
                  summary: Job pending/running
                  value:
                    job_id: athn_a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    status: running
                    retry_after: 5
                completed:
                  summary: Job completed with download URL (truncated preview)
                  value:
                    job_id: athn_a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    status: completed
                    rows:
                      - account_id: acc-001
                        mfa_status: disabled
                    downloads:
                      - url: >-
                          https://downloads.prod.oleria.io/acme/qr/athena/results/exec.csv?Policy=eyJTdGF0ZW1lbnQ&Signature=Gr8tSignatureExample&Key-Pair-Id=K2EXAMPLE
                        format: csv
                    download:
                      url: >-
                        https://downloads.prod.oleria.io/acme/qr/athena/results/exec.csv?Policy=eyJTdGF0ZW1lbnQ&Signature=Gr8tSignatureExample&Key-Pair-Id=K2EXAMPLE
                      format: csv
                    statistics:
                      execution_time_ms: 45000
                      data_scanned_bytes: 524288000
                failed:
                  summary: Job failed
                  value:
                    job_id: athn_a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    status: failed
                    error:
                      code: QUERY_TIMEOUT
                      message: Query execution timeout after 300s
        '401':
          description: Missing or invalid authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Valid token but insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Job not found or expired (jobs are retained for 7 days)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - clientCredentials:
            - ClientCredentialsResourceServer/client_credentials_base_scope
components:
  schemas:
    QueryJobResponse:
      type: object
      required:
        - job_id
        - status
      description: >
        Status and results for a query job. A `completed` job carries
        `statistics` and, when the engine exposes a downloadable artifact,
        `downloads`. When status is `failed`, the error field describes the
        failure.
      properties:
        job_id:
          type: string
          description: >
            Unique identifier for the query job. Use this value to poll for
            status via the jobs endpoint.
        status:
          type: string
          enum:
            - pending
            - running
            - completed
            - failed
          description: >
            Current job state. `pending` = queued, `running` = executing,
            `completed` = results available, `failed` = execution error.
        retry_after:
          type: integer
          description: >
            Recommended polling interval in seconds. Present when status is
            `pending` or `running`. Clients should wait at least this long
            before polling again.
          example: 5
        downloads:
          type: array
          description: >
            Download references for the query result, present once `status` is
            `completed` and the engine exposes a downloadable artifact (omitted
            otherwise). A csv result is a single reference; a json result may be
            several references that together hold the complete result set.
          items:
            $ref: '#/components/schemas/Download'
        download:
          description: >
            Convenience reference to the single result file. Present only when
            the result is exactly one file — always so for `csv` — and identical
            to the sole `downloads` entry when present. A result delivered as
            multiple files populates only `downloads`, so a client that must
            handle any result should read `downloads`.
          allOf:
            - $ref: '#/components/schemas/Download'
        rows:
          type: array
          description: >
            An initial page of results, inline, so a client can render a preview
            without fetching the file. Present when `status` is `completed`. The
            complete result set is delivered via `downloads` when present.
          items:
            type: object
            additionalProperties: true
        statistics:
          description: >
            Execution statistics. Reported when status is `completed` and the
            engine returns statistics for the execution; absent when none are
            available.
          allOf:
            - $ref: '#/components/schemas/QueryStatistics'
        error:
          description: Error details when status is `failed`.
          allOf:
            - $ref: '#/components/schemas/ErrorResponse'
    ErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code for programmatic handling.
          example: QUERY_PARSE_ERROR
        message:
          type: string
          description: Human-readable error description.
          example: Failed to parse SQL query
        details:
          type: object
          additionalProperties: true
          description: Additional context for debugging (optional, free-form).
          example:
            line: 3
            column: 15
            hint: Unexpected token near 'SELCT'
        reasons:
          type: array
          description: >
            Policy violation details. Present when `code` is `POLICY_VIOLATION`.
            Each entry identifies a governance policy that the query violated.
          items:
            $ref: '#/components/schemas/Reason'
    Download:
      type: object
      required:
        - url
        - format
      description: >
        A download reference for a query result file. A csv result is a single
        file; a json result may be delivered as more than one JSON Lines file,
        which together hold the complete result set.
      properties:
        url:
          type: string
          format: uri
          description: >
            Short-lived pre-signed URL to fetch the result file directly, valid
            for a few minutes. After it expires, re-poll the job to obtain a
            fresh link.
          example: >-
            https://downloads.prod.oleria.io/acme/qr/athena/results/exec.csv?Policy=eyJTdGF0ZW1lbnQ&Signature=Gr8tSignatureExample&Key-Pair-Id=K2EXAMPLE
        format:
          type: string
          enum:
            - json
            - csv
          description: >
            File format. `csv` is a single comma-separated file with a header
            row. `json` is JSON Lines (NDJSON) — one JSON object per line.
          example: csv
    QueryStatistics:
      type: object
      description: >
        Execution statistics for the query. Reported together when the engine
        returns statistics for an execution; absent when no statistics are
        available.
      required:
        - execution_time_ms
        - data_scanned_bytes
      properties:
        row_count:
          type: integer
          format: int64
          description: >
            Total number of rows in the result set. Present only when the inline
            `rows` hold the complete result; omitted when `rows` is a truncated
            preview, where the full count is available only from the downloaded
            result file.
          example: 1500
        execution_time_ms:
          type: integer
          format: int64
          description: Query execution time in milliseconds.
          example: 2340
        data_scanned_bytes:
          type: integer
          format: int64
          description: >
            Total bytes scanned by the query engine. Useful for cost visibility
            and budget attribution.
          example: 104857600
    Reason:
      type: object
      required:
        - code
        - message
      description: A single policy violation identified during query validation.
      properties:
        code:
          type: string
          description: >
            Stable, machine-readable identifier for the denial reason.
            SCREAMING_SNAKE_CASE; declared on the violated policy.
          example: MUTATION_NOT_ALLOWED
        message:
          type: string
          description: Human-readable explanation of the denial.
          example: >-
            Only SELECT queries are permitted. Mutation statements are not
            allowed.
  securitySchemes:
    clientCredentials:
      type: oauth2
      description: >
        OAuth 2.0 Client Credentials flow. The tokenUrl shown is for the
        production environment. For other environments, replace `prod` with the
        target environment name (e.g., `auth.staging.oleria.io` for staging).
      flows:
        clientCredentials:
          tokenUrl: https://auth.prod.oleria.io/oauth/token
          scopes:
            ClientCredentialsResourceServer/client_credentials_base_scope: >-
              Default scope used for all client credentials (RBAC is controlled
              via permissions in the bearer token)

````