> ## 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.

# Schedule a query/card

> Schedules a query/card to run on a specified cron schedule.



## OpenAPI

````yaml post /api/query/schedule
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/schedule:
    post:
      tags:
        - Queries (formerly cards)
      summary: Schedule a query/card
      description: Schedules a query/card to run on a specified cron schedule.
      operationId: schedule_api_query_schedule_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScheduleQueryRequest'
        required: true
      responses:
        '200':
          description: Query scheduled successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduleResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    ScheduleQueryRequest:
      properties:
        card_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Card Url
          description: URL of the card or visualization you want to schedule.
        query_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Query Id
          description: Unique ID of the query you want to schedule.
        name:
          type: string
          title: Name
          description: A user-defined name for the scheduled query job.
        cron:
          type: string
          title: Cron
          description: A cron expression defining when or how often the query should run.
      type: object
      required:
        - name
        - cron
      title: ScheduleQueryRequest
    ScheduleResponse:
      properties:
        id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Id
          description: A unique ID for the scheduled query flow.
        flow_url:
          type: string
          title: Flow Url
          description: Airflow URL to access the scheduled query flow.
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message if scheduling fails due to any issue.
      type: object
      required:
        - flow_url
      title: ScheduleResponse
    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
    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

````