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

# Get Query Status

> Returns the execution status of a registered query. Poll this endpoint until the query reaches a terminal status, then fetch the results.




## OpenAPI

````yaml /api/analytics-query/analytics-query.yaml get /v5/analytics/query/{request_id}/status
openapi: 3.0.3
info:
  title: MoEngage Analytics Query API
  version: '5.0'
  description: >
    Asynchronous REST APIs to run MoEngage Analytics queries — Behavior,
    Funnels, Retention,

    Session/Source (BFRS) and User Property Analysis (UPA) — and retrieve their
    results.


    These queries are asynchronous. A `POST` registers the query and immediately
    returns a

    `request_id`; a worker executes the query; you then poll the status and
    fetch the results:


    1. **Submit** — `POST` one of the analysis endpoints. The response echoes
    the analysis `type` and returns a `request_id`.

    2. **Poll** — `GET /v5/analytics/query/{request_id}/status` until `status`
    is `SUCCESSFUL` (or `FAILED`).

    3. **Fetch** — `GET /v5/analytics/query/{request_id}/results` to retrieve
    the resolved series.
servers:
  - url: https://api-{dc}.moengage.com
    description: MoEngage API Server
    variables:
      dc:
        default: '01'
        description: >-
          The 'dc' in the API Endpoint URL refers to the MoEngage Data Center
          (DC). MoEngage hosts each customer in a different DC. You can find
          your DC number and replace the value of 'dc' in the URL by referring
          to the DC and API endpoint mapping
          [here](/api/introduction#data-centers). Your MoEngage Data Center (DC)
          can be 01, 02, 03, 04, 05, 06, or 101.
security:
  - basicAuth: []
tags:
  - name: Analytics Queries
    description: >-
      Register asynchronous BFRS and UPA analytics queries, then poll status and
      fetch results.
paths:
  /v5/analytics/query/{request_id}/status:
    get:
      tags:
        - Analytics Queries
      summary: Get Query Status
      description: >
        Returns the execution status of a registered query. Poll this endpoint
        until the query reaches a terminal status, then fetch the results.
      operationId: getQueryStatus
      parameters:
        - name: request_id
          in: path
          required: true
          description: The `request_id` returned when the query was registered.
          schema:
            type: string
            example: REQUEST_ID
      responses:
        '200':
          description: >-
            This response is returned when the request is processed
            successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  response_id:
                    $ref: '#/components/schemas/ResponseId'
                  type:
                    type: string
                    description: The type of resource returned in the `data` field.
                    example: query_status
                  data:
                    type: object
                    properties:
                      status:
                        type: string
                        description: >
                          Execution status of the query.


                          - `PENDING`: The query is registered and queued. Keep
                          polling.

                          - `PROCESSING`: The query is running. Keep polling.

                          - `SUCCESSFUL`: The query finished. Fetch the results
                          with [Get Query
                          Results](/api/analytics-queries/get-query-results).

                          - `FAILED`: The query could not be completed. Check
                          `failure_reason`, correct the request, and register
                          the query again. A `request_id` cannot be re-run.
                        enum:
                          - PENDING
                          - PROCESSING
                          - SUCCESSFUL
                          - FAILED
                      failure_reason:
                        type: string
                        description: >
                          Why the query failed. Returned only when `status` is
                          `FAILED`.
                        example: >-
                          One or more selected attributes are no longer
                          available. Please verify your selection and try again.
              examples:
                Successful:
                  summary: Query finished
                  value:
                    response_id: 199fb3c9-373f-4fe6-a40f-76185ef02b88
                    type: query_status
                    data:
                      status: SUCCESSFUL
                Processing:
                  summary: Query still running
                  value:
                    response_id: d3a15e78-9b26-4c40-8e17-5f0b2a9d6c31
                    type: query_status
                    data:
                      status: PROCESSING
                Failed:
                  summary: Query failed
                  value:
                    response_id: e8c40a92-3f71-4b6d-82a5-9d1f0e7c3b48
                    type: query_status
                    data:
                      status: FAILED
                      failure_reason: >-
                        One or more selected attributes are no longer available.
                        Please verify your selection and try again.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    ResponseId:
      type: string
      description: >-
        A unique identifier for the response, useful for correlating logs and
        support requests.
      example: fc803857-632e-4bf0-8df1-fbc2bdeedb66
    GatewayAuthError:
      type: object
      description: >
        Authentication or authorization failure returned by the API gateway. The
        body is JSON, but the gateway sends it with `Content-Type: text/plain`.
      properties:
        code:
          type: string
          description: >
            A machine-readable code identifying the failure, such as `ER001`
            when credentials are missing or invalid, or `ER007` when the
            credentials do not have access to the route.
          example: ER001
        target:
          type: string
          description: The stage of the request that failed.
          example: Authentication Invalid
        message:
          type: string
          description: A human-readable description of the failure.
          example: Auth validation failed.
    ErrorResponse:
      type: object
      required:
        - error
        - response_id
      description: >
        Standard MoEngage error envelope, returned by the service.
        Authentication and authorization failures (401 and 403) are returned by
        the API gateway in a different format — see those responses for details.
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: A machine-readable error code.
              enum:
                - VALIDATION_FAILED
                - BAD_REQUEST
                - NOT_FOUND
                - QUOTA_EXCEEDED
                - INTERNAL_ERROR
            message:
              type: string
              description: A human-readable description of the error.
            doc_url:
              type: string
              description: A link to documentation about this error, when available.
        response_id:
          $ref: '#/components/schemas/ResponseId'
  responses:
    Unauthorized:
      description: >
        This response is returned when the credentials are missing or invalid.


        The API gateway generates this response before the request reaches the
        service, so it does not use the standard error envelope. The body is
        JSON, but the gateway sends it with `Content-Type: text/plain`. Parse it
        accordingly.
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/GatewayAuthError'
          example:
            code: ER001
            target: Authentication Invalid
            message: Auth validation failed.
    NotFound:
      description: The query `request_id` does not exist, or is not in this workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: The query request you are looking for does not exist.
              doc_url: https://www.moengage.com/docs/api/analytics-queries/
            response_id: 0998efae-b324-4559-afb0-756961d2e11a
    InternalError:
      description: An unexpected server error occurred.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INTERNAL_ERROR
              message: An unexpected error occurred while processing the request.
              doc_url: https://www.moengage.com/docs/api/analytics-queries/
            response_id: dcc4fd00-2980-41a5-94b3-ad4844ae3d72
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >
        Authentication is done via Basic Auth. This requires a Base64-encoded
        string of your credentials in the format `username:password`.


        - **Username**: Use your MoEngage Workspace ID (also known as the App
        ID). Find it in the MoEngage dashboard at **Settings** > **Account** >
        **API keys**.

        - **Password**: Use an API key from **Settings** > **Account** > **API
        keys**.


        Refer to [API Key
        Dashboard](/user-guide/settings/account/api-and-api-keys/api-key-dashboard)
        for details on creating and managing API keys.

````