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

# Run Query Async

> Execute a query asynchronously and return query object.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url "https://api.roe-ai.com/v1/database/query/async/?organization_id=YOUR_ORG_ID" \
    --header "Authorization: Bearer YOUR_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
      "query": "SELECT * FROM my_table LIMIT 10"
    }'
  ```
</RequestExample>


## OpenAPI

````yaml POST /v1/database/query/async/
openapi: 3.1.0
info:
  title: Roe AI API
  version: 1.0.0
  description: Complete API documentation for Roe AI platform
servers:
  - url: https://api.roe-ai.com
    description: Production API
security: []
paths:
  /v1/database/query/async/:
    post:
      tags:
        - v1
      description: Execute a query asynchronously and return query object.
      operationId: v1_database_query_async_create
      parameters:
        - in: query
          name: worksheet_id
          schema:
            type: string
          description: Worksheet ID. Required if organization_id is not provided.
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
            format: uuid
          description: >-
            Organization ID. This is required for access control. It can be
            provided via query or request body depending on the endpoint.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorksheetQueryCreateRequest'
            examples:
              AsyncDatabaseQueryExample:
                value:
                  query: SELECT * FROM users LIMIT 10
                  worksheet_id: 123e4567-e89b-12d3-a456-426614174000
                  use_admin: false
                summary: Async Database Query Example
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorksheetQuery'
              examples:
                AsyncDatabaseQueryExample:
                  value:
                    query: SELECT * FROM users LIMIT 10
                    worksheet_id: 123e4567-e89b-12d3-a456-426614174000
                    use_admin: false
                  summary: Async Database Query Example
          description: Query object
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad request
components:
  schemas:
    WorksheetQueryCreateRequest:
      type: object
      description: Serializer for creating worksheet queries.
      properties:
        query:
          type: string
          minLength: 1
        worksheet_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Worksheet ID to associate with the query
        use_admin:
          type: boolean
          default: false
          description: Whether to use admin privileges
      required:
        - query
    WorksheetQuery:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        worksheet:
          $ref: '#/components/schemas/Worksheet'
        organization:
          $ref: '#/components/schemas/OrganizationSlim'
        creator:
          oneOf:
            - $ref: '#/components/schemas/UserInfo'
            - type: 'null'
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        query:
          type: string
        query_task_id:
          type:
            - string
            - 'null'
          readOnly: true
        query_task_status:
          type:
            - string
            - 'null'
          readOnly: true
        error:
          type:
            - string
            - 'null'
          readOnly: true
        ai_summary:
          type:
            - string
            - 'null'
          readOnly: true
      required:
        - ai_summary
        - created_at
        - error
        - finished_at
        - id
        - query
        - query_task_id
        - query_task_status
        - updated_at
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Error message
      required:
        - message
    Worksheet:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
          maxLength: 1024
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        creator:
          oneOf:
            - $ref: '#/components/schemas/UserInfo'
            - type: 'null'
        organization:
          $ref: '#/components/schemas/OrganizationSlim'
      required:
        - created_at
        - id
        - name
        - updated_at
    OrganizationSlim:
      type: object
      description: Simple organization serializer for nested use.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
          maxLength: 150
        created_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - created_at
        - id
        - name
    UserInfo:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        email:
          type: string
          format: email
          title: Email address
          maxLength: 254
        first_name:
          type: string
          maxLength: 150
        last_name:
          type: string
          maxLength: 150
        display_name:
          type: string
          readOnly: true
      required:
        - display_name
        - email
        - id

````