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

# Test Macro

> Test a SQL macro execution.

Executes the macro in a transaction that is rolled back after execution.
Requires superadmin privileges.



## OpenAPI

````yaml post /api/v1/macros/{macro_id}/test
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/macros/{macro_id}/test:
    post:
      tags:
        - macros
      summary: Test Macro
      description: |-
        Test a SQL macro execution.

        Executes the macro in a transaction that is rolled back after execution.
        Requires superadmin privileges.
      operationId: test_macro_api_v1_macros__macro_id__test_post
      parameters:
        - name: macro_id
          in: path
          required: true
          schema:
            type: integer
            title: Macro Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MacroTestRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MacroTestResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    MacroTestRequest:
      properties:
        parameters:
          items:
            type: string
          type: array
          title: Parameters
          description: Array of test values to pass to the macro
      type: object
      title: MacroTestRequest
      description: Schema for testing a macro.
    MacroTestResponse:
      properties:
        result:
          anyOf:
            - type: string
            - type: 'null'
          title: Result
          description: The result of the macro execution
        execution_time:
          type: number
          title: Execution Time
          description: Execution time in milliseconds
        rows_affected:
          type: integer
          title: Rows Affected
          description: Number of rows affected (always 0 for SELECT)
          default: 0
      type: object
      required:
        - execution_time
      title: MacroTestResponse
      description: Schema for macro test response.
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````