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

# Submit a query to save it and get visualizations

> Submit a query. Returns the details of the submitted query.



## OpenAPI

````yaml post /api/query/submit
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/query/submit:
    post:
      tags:
        - Queries (formerly cards)
      summary: Submit a query to save it and get visualizations
      description: Submit a query. Returns the details of the submitted query.
      operationId: submit_query_api_query_submit_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitQueryRequest'
        required: true
      responses:
        '200':
          description: Query for a card submitted successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AskResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    SubmitQueryRequest:
      properties:
        domain:
          type: string
          title: Domain
          description: The domain or data context where the query should be executed.
        query:
          type: string
          title: Query
          description: The SQL query string to be executed against the specified domain.
      type: object
      required:
        - domain
        - query
      title: SubmitQueryRequest
    AskResponse:
      properties:
        id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Id
          description: A unique identifier for the AI response or query.
        card_url:
          type: string
          title: Card Url
          description: URL of the visualized card or dashboard generated from the query.
        dashboard_id:
          anyOf:
            - type: integer
            - type: string
            - type: 'null'
          title: Dashboard Id
          description: The unique identifier of the dashboard created.
        domain:
          type: string
          title: Domain
          description: The domain context related to the query or response.
        domain_urn:
          type: string
          title: Domain Urn
          description: The unique URN representing the domain in the metadata system.
        query:
          type: string
          title: Query
          description: >-
            The SQL query generated or executed in response to the user's
            prompt.
        prompt:
          type: string
          title: Prompt
          description: The original prompt or question submitted by the user.
        embed_info:
          anyOf:
            - $ref: '#/components/schemas/AnalyticsEmbedInfo'
            - type: 'null'
          description: URL to embed the resulting visualization or card.
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message if any occurred during query generation or execution.
        analytics_provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Analytics Provider
          description: The analytics platform used for visualization.
          default: superset
      type: object
      required:
        - card_url
        - domain
        - domain_urn
        - query
        - prompt
      title: AskResponse
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AnalyticsEmbedInfo:
      properties:
        embed_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Embed Url
        entity_id:
          anyOf:
            - type: integer
            - type: string
            - type: 'null'
          title: Entity Id
        token:
          anyOf:
            - type: string
            - type: 'null'
          title: Token
      type: object
      title: AnalyticsEmbedInfo
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````