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

# Apply an atomic SQL migration (manage grant)

> Requires host authentication and current database grants. Names and stable UUIDs are accepted as resource references. SQL availability and dialect depend on the provider; the PostgreSQL adapter supports a bounded subset, not arbitrary server SQL.



## OpenAPI

````yaml /agent-openapi.json post /api/v1/data/{resource}/migrations
openapi: 3.1.0
info:
  title: Polpo API
  version: 1.0.0
  description: >-
    REST API for Polpo — an AI agent that manages teams of AI coding agents.
    Manage tasks, missions, agents, playbooks, skills, and approvals. For
    conversational interaction, use the OpenAI-compatible POST
    /v1/chat/completions endpoint.
servers:
  - url: http://localhost:3890
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Databases
    description: >-
      Named application databases, records, scoped SQL, and versioned
      migrations.
paths:
  /api/v1/data/{resource}/migrations:
    post:
      tags:
        - Databases
      summary: Apply an atomic SQL migration (manage grant)
      description: >-
        Requires host authentication and current database grants. Names and
        stable UUIDs are accepted as resource references. SQL availability and
        dialect depend on the provider; the PostgreSQL adapter supports a
        bounded subset, not arbitrary server SQL.
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 128
          required: true
          name: resource
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                  pattern: ^[a-z][a-z0-9_]{0,47}$
                expectedVersion:
                  type: integer
                  exclusiveMinimum: 0
                statements:
                  type: array
                  items:
                    type: object
                    properties:
                      sql:
                        type: string
                        minLength: 1
                        maxLength: 65536
                      params:
                        type: array
                        items:
                          anyOf:
                            - type: string
                              maxLength: 65536
                            - type: number
                            - type: boolean
                            - type: 'null'
                        maxItems: 1000
                    required:
                      - sql
                    additionalProperties: false
                  minItems: 1
                  maxItems: 100
                allowDestructive:
                  type: boolean
              required:
                - id
                - expectedVersion
                - statements
              additionalProperties: false
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      name:
                        type: string
                      schema:
                        type: object
                        properties:
                          tables:
                            type: object
                            additionalProperties:
                              type: object
                              properties:
                                columns:
                                  type: object
                                  additionalProperties:
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - text
                                          - integer
                                          - number
                                          - boolean
                                          - timestamp
                                          - uuid
                                          - json
                                      nullable:
                                        type: boolean
                                      unique:
                                        type: boolean
                                      references:
                                        type: object
                                        properties:
                                          table:
                                            type: string
                                            pattern: ^[a-z][a-z0-9_]{0,47}$
                                          column:
                                            type: string
                                        required:
                                          - table
                                          - column
                                        additionalProperties: false
                                    required:
                                      - type
                                    additionalProperties: false
                                indexes:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      name:
                                        type: string
                                        pattern: ^[a-z][a-z0-9_]{0,62}$
                                      columns:
                                        type: array
                                        items:
                                          type: string
                                          pattern: ^[a-z][a-z0-9_]{0,47}$
                                        minItems: 1
                                        maxItems: 4
                                      unique:
                                        type: boolean
                                    required:
                                      - columns
                                    additionalProperties: false
                                  maxItems: 16
                              required:
                                - columns
                              additionalProperties: false
                        required:
                          - tables
                        additionalProperties: false
                      schemaVersion:
                        type: integer
                      createdAt:
                        type: string
                    required:
                      - id
                      - name
                      - schema
                      - schemaVersion
                      - createdAt
                required:
                  - ok
                  - data
        '400':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '401':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '403':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '404':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '409':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '413':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '422':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
        '503':
          description: Invalid, denied, conflicting, bounded or unavailable request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  error:
                    type: string
                required:
                  - ok
                  - code
                  - error
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key passed as a Bearer token. Configure via the apiKeys field in
        project.json or the POLPO_API_KEY environment variable.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.