Convex Queries API

Execute read-only query functions deployed on the Convex backend. Queries run in a transactional, reactive context and return data from the Convex database.

OpenAPI Specification

convex-queries-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Convex Deployment Platform AccessTokens Queries API
  description: The Convex Deployment Platform API is a deployment-scoped administrative REST API for configuring individual Convex deployments. It exposes private endpoints accessible only to deployment administrators and supports operations such as managing environment variables and other deployment configuration settings. Each deployment has its own endpoint in the format https://{deployment-name}.convex.cloud/api/v1/. Authentication requires an Authorization header using deployment keys, Team Access Tokens, or OAuth Application Tokens formatted as "Convex {token}". This API is currently in Beta and is intended for platform integrations and infrastructure automation workflows.
  version: v1-beta
  contact:
    name: Convex Platform Support
    email: platforms@convex.dev
    url: https://www.convex.dev/community
  termsOfService: https://www.convex.dev/terms
servers:
- url: https://{deploymentName}.convex.cloud/api/v1
  description: Convex Deployment Server
  variables:
    deploymentName:
      default: happy-otter-123
      description: The deployment name found in the Convex dashboard or via the Management API. Each deployment has a unique subdomain under convex.cloud.
security:
- convexAuth: []
tags:
- name: Queries
  description: Execute read-only query functions deployed on the Convex backend. Queries run in a transactional, reactive context and return data from the Convex database.
paths:
  /api/query:
    post:
      operationId: executeQuery
      summary: Execute a query function
      description: Executes a read-only query function deployed on the Convex backend. The function is identified by its module path and export name (e.g. "myModule:myQuery"). Named arguments are passed as a JSON object. Returns the function's return value and any console log output produced during execution.
      tags:
      - Queries
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FunctionRequest'
      responses:
        '200':
          description: Function executed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionSuccessResponse'
        '400':
          description: Bad request — invalid function path or argument format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionErrorResponse'
        '401':
          description: Unauthorized — missing or invalid authorization token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionErrorResponse'
        '404':
          description: Function not found at the given path
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionErrorResponse'
components:
  schemas:
    FunctionErrorResponse:
      type: object
      required:
      - status
      - errorMessage
      - logLines
      properties:
        status:
          type: string
          description: Indicates the function encountered an error during execution.
          enum:
          - error
        errorMessage:
          type: string
          description: A human-readable description of the error that occurred during function execution.
        errorData:
          type: object
          description: Additional structured data about the error, present when the function throws a ConvexError with associated data. The shape depends on the application-specific error definition.
          additionalProperties: true
        logLines:
          type: array
          description: An array of strings representing console output produced by the function prior to the error.
          items:
            type: string
    FunctionRequest:
      type: object
      required:
      - path
      - args
      properties:
        path:
          type: string
          description: The fully-qualified function path in the format "module:functionName" (e.g. "messages:list"). The module name maps to the file path within the convex/ directory.
          pattern: ^[a-zA-Z0-9_/]+:[a-zA-Z0-9_]+$
          example: messages:list
        args:
          type: object
          description: Named arguments to pass to the function as a JSON object. The keys and value types must match the function's declared parameter types.
          additionalProperties: true
        format:
          type: string
          description: Output format for the response value. Currently only "json" is supported and is also the default when omitted.
          enum:
          - json
          default: json
    FunctionSuccessResponse:
      type: object
      required:
      - status
      - value
      - logLines
      properties:
        status:
          type: string
          description: Indicates the function executed without error.
          enum:
          - success
        value:
          description: The return value of the function. The type depends on the function's return type definition and may be any valid JSON value including objects, arrays, strings, numbers, booleans, or null.
        logLines:
          type: array
          description: An array of strings representing console output (e.g. console.log) produced by the function during execution.
          items:
            type: string
  securitySchemes:
    convexAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Authorization header using a deployment key, Team Access Token, or OAuth Application Token. The token must be prefixed with the string "Convex " (e.g. "Authorization: Convex prod:abc123..."). Deployment keys are created in the dashboard or via the Management API.'
externalDocs:
  description: Convex Deployment Platform API Documentation
  url: https://docs.convex.dev/deployment-platform-api