Capy setup API

The setup API from Capy — 1 operation(s) for setup.

OpenAPI Specification

capy-setup-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Capy automations setup API
  version: 1.0.0
servers:
- url: https://capy.ai/api
security:
- bearerAuth: []
tags:
- name: setup
paths:
  /v1/projects/{projectId}/setup:
    get:
      operationId: getSetup
      summary: Get setup
      description: Get Setup used for future project runs. Setup contains VM size, three automatic repository scripts, opt-in Commands, terminals, previews, and pre/post tool hooks. Environment variables are configured separately.
      tags:
      - setup
      security:
      - bearerAuth: []
      parameters:
      - name: projectId
        in: path
        required: true
        description: Project ID.
        schema:
          type: string
        example: proj_123
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Setup'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalError'
    patch:
      operationId: updateSetup
      summary: Update setup
      description: Save Setup for future project runs. The update becomes active immediately; secret and environment variable fields are not accepted.
      tags:
      - setup
      security:
      - bearerAuth: []
      parameters:
      - name: projectId
        in: path
        required: true
        description: Project ID.
        schema:
          type: string
        example: proj_123
      - name: replaceLegacyHooks
        in: query
        required: false
        schema:
          type: boolean
          description: Set to true to confirm that saving Setup replaces active deprecated .capy/settings.json hooks for future runs.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSetupBody'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateSetupResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  responses:
    InternalError:
      description: Internal error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    Setup:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        source:
          type: string
          enum:
          - legacy
          - setup
          - none
        legacyHooks:
          type: object
          properties:
            status:
              type: string
              enum:
              - active
              - ignored
              - none
            repositories:
              type: array
              items:
                type: string
            checkComplete:
              type: boolean
          required:
          - status
          - repositories
          - checkComplete
          additionalProperties: false
        setup:
          type: object
          properties:
            vmSize:
              type: string
              enum:
              - small
              - medium
              - large
              - ultra
              - hyper
            repositories:
              type: array
              items:
                type: object
                properties:
                  repository:
                    type: string
                  branch:
                    type: string
                  scripts:
                    type: object
                    properties:
                      initialize:
                        anyOf:
                        - type: string
                        - type: 'null'
                      updateAfterCheckout:
                        anyOf:
                        - type: string
                        - type: 'null'
                      startup:
                        anyOf:
                        - type: string
                        - type: 'null'
                    required:
                    - initialize
                    - updateAfterCheckout
                    - startup
                    additionalProperties: false
                  timeouts:
                    type: object
                    properties:
                      initialize:
                        type: integer
                        minimum: 60
                        maximum: 3600
                      updateAfterCheckout:
                        type: integer
                        minimum: 60
                        maximum: 3600
                      startup:
                        type: integer
                        minimum: 60
                        maximum: 3600
                    additionalProperties: false
                  commands:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        command:
                          type: string
                      required:
                      - name
                      - command
                      additionalProperties: false
                required:
                - repository
                - branch
                - scripts
                - commands
                additionalProperties: false
            hooks:
              type: object
              properties:
                pre:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    anyOf:
                    - type: array
                      items:
                        type: string
                    - type: object
                      properties:
                        commands:
                          type: array
                          items:
                            type: string
                          description: Shell commands to run
                        agents:
                          type: array
                          items:
                            type: string
                            enum:
                            - captain
                            - build
                            - review
                          description: 'Which agent types this applies to. Omit to apply to all agents (default: all)'
                      required:
                      - commands
                      additionalProperties: false
                  description: Commands to run BEFORE a tool executes. Keys are tool names (bash_run, edit, write, etc.), values are arrays of shell commands or objects with commands and agents filter
                post:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    anyOf:
                    - type: array
                      items:
                        type: string
                    - type: object
                      properties:
                        commands:
                          type: array
                          items:
                            type: string
                          description: Shell commands to run
                        agents:
                          type: array
                          items:
                            type: string
                            enum:
                            - captain
                            - build
                            - review
                          description: 'Which agent types this applies to. Omit to apply to all agents (default: all)'
                      required:
                      - commands
                      additionalProperties: false
                  description: Commands to run AFTER a tool executes. Keys are tool names, values are arrays of shell commands or objects with commands and agents filter. Can use ${variable} interpolation from tool args/results
                context:
                  type: object
                  properties:
                    maxOutputLength:
                      type: integer
                      exclusiveMinimum: 0
                      maximum: 9007199254740991
                      description: 'Maximum characters of hook output to include in context (default: 2000)'
                    truncateStrategy:
                      type: string
                      enum:
                      - head
                      - tail
                      - middle
                      description: 'How to truncate output exceeding maxOutputLength: ''head'' keeps start, ''tail'' keeps end, ''middle'' keeps both ends'
                  additionalProperties: false
              additionalProperties: false
          required:
          - repositories
          additionalProperties: false
      required:
      - source
      - legacyHooks
      - setup
      additionalProperties: false
    UpdateSetupResponse:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        source:
          type: string
          enum:
          - legacy
          - setup
          - none
        legacyHooks:
          type: object
          properties:
            status:
              type: string
              enum:
              - active
              - ignored
              - none
            repositories:
              type: array
              items:
                type: string
            checkComplete:
              type: boolean
          required:
          - status
          - repositories
          - checkComplete
          additionalProperties: false
        setup:
          type: object
          properties:
            vmSize:
              type: string
              enum:
              - small
              - medium
              - large
              - ultra
              - hyper
            repositories:
              type: array
              items:
                type: object
                properties:
                  repository:
                    type: string
                  branch:
                    type: string
                  scripts:
                    type: object
                    properties:
                      initialize:
                        anyOf:
                        - type: string
                        - type: 'null'
                      updateAfterCheckout:
                        anyOf:
                        - type: string
                        - type: 'null'
                      startup:
                        anyOf:
                        - type: string
                        - type: 'null'
                    required:
                    - initialize
                    - updateAfterCheckout
                    - startup
                    additionalProperties: false
                  timeouts:
                    type: object
                    properties:
                      initialize:
                        type: integer
                        minimum: 60
                        maximum: 3600
                      updateAfterCheckout:
                        type: integer
                        minimum: 60
                        maximum: 3600
                      startup:
                        type: integer
                        minimum: 60
                        maximum: 3600
                    additionalProperties: false
                  commands:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        command:
                          type: string
                      required:
                      - name
                      - command
                      additionalProperties: false
                required:
                - repository
                - branch
                - scripts
                - commands
                additionalProperties: false
            hooks:
              type: object
              properties:
                pre:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    anyOf:
                    - type: array
                      items:
                        type: string
                    - type: object
                      properties:
                        commands:
                          type: array
                          items:
                            type: string
                          description: Shell commands to run
                        agents:
                          type: array
                          items:
                            type: string
                            enum:
                            - captain
                            - build
                            - review
                          description: 'Which agent types this applies to. Omit to apply to all agents (default: all)'
                      required:
                      - commands
                      additionalProperties: false
                  description: Commands to run BEFORE a tool executes. Keys are tool names (bash_run, edit, write, etc.), values are arrays of shell commands or objects with commands and agents filter
                post:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    anyOf:
                    - type: array
                      items:
                        type: string
                    - type: object
                      properties:
                        commands:
                          type: array
                          items:
                            type: string
                          description: Shell commands to run
                        agents:
                          type: array
                          items:
                            type: string
                            enum:
                            - captain
                            - build
                            - review
                          description: 'Which agent types this applies to. Omit to apply to all agents (default: all)'
                      required:
                      - commands
                      additionalProperties: false
                  description: Commands to run AFTER a tool executes. Keys are tool names, values are arrays of shell commands or objects with commands and agents filter. Can use ${variable} interpolation from tool args/results
                context:
                  type: object
                  properties:
                    maxOutputLength:
                      type: integer
                      exclusiveMinimum: 0
                      maximum: 9007199254740991
                      description: 'Maximum characters of hook output to include in context (default: 2000)'
                    truncateStrategy:
                      type: string
                      enum:
                      - head
                      - tail
                      - middle
                      description: 'How to truncate output exceeding maxOutputLength: ''head'' keeps start, ''tail'' keeps end, ''middle'' keeps both ends'
                  additionalProperties: false
              additionalProperties: false
          required:
          - repositories
          additionalProperties: false
      required:
      - source
      - legacyHooks
      - setup
      additionalProperties: false
    UpdateSetupBody:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        vmSize:
          type: string
          enum:
          - small
          - medium
          - large
          - ultra
          - hyper
        repositories:
          type: array
          items:
            type: object
            properties:
              repository:
                type: string
              branch:
                type: string
              scripts:
                type: object
                properties:
                  initialize:
                    anyOf:
                    - type: string
                    - type: 'null'
                  updateAfterCheckout:
                    anyOf:
                    - type: string
                    - type: 'null'
                  startup:
                    anyOf:
                    - type: string
                    - type: 'null'
                required:
                - initialize
                - updateAfterCheckout
                - startup
                additionalProperties: false
              timeouts:
                type: object
                properties:
                  initialize:
                    type: integer
                    minimum: 60
                    maximum: 3600
                  updateAfterCheckout:
                    type: integer
                    minimum: 60
                    maximum: 3600
                  startup:
                    type: integer
                    minimum: 60
                    maximum: 3600
                additionalProperties: false
              commands:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                    command:
                      type: string
                  required:
                  - name
                  - command
                  additionalProperties: false
            required:
            - repository
            - branch
            - scripts
            - commands
            additionalProperties: false
        hooks:
          type: object
          properties:
            pre:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                anyOf:
                - type: array
                  items:
                    type: string
                - type: object
                  properties:
                    commands:
                      type: array
                      items:
                        type: string
                      description: Shell commands to run
                    agents:
                      type: array
                      items:
                        type: string
                        enum:
                        - captain
                        - build
                        - review
                      description: 'Which agent types this applies to. Omit to apply to all agents (default: all)'
                  required:
                  - commands
                  additionalProperties: false
              description: Commands to run BEFORE a tool executes. Keys are tool names (bash_run, edit, write, etc.), values are arrays of shell commands or objects with commands and agents filter
            post:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                anyOf:
                - type: array
                  items:
                    type: string
                - type: object
                  properties:
                    commands:
                      type: array
                      items:
                        type: string
                      description: Shell commands to run
                    agents:
                      type: array
                      items:
                        type: string
                        enum:
                        - captain
                        - build
                        - review
                      description: 'Which agent types this applies to. Omit to apply to all agents (default: all)'
                  required:
                  - commands
                  additionalProperties: false
              description: Commands to run AFTER a tool executes. Keys are tool names, values are arrays of shell commands or objects with commands and agents filter. Can use ${variable} interpolation from tool args/results
            context:
              type: object
              properties:
                maxOutputLength:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 9007199254740991
                  description: 'Maximum characters of hook output to include in context (default: 2000)'
                truncateStrategy:
                  type: string
                  enum:
                  - head
                  - tail
                  - middle
                  description: 'How to truncate output exceeding maxOutputLength: ''head'' keeps start, ''tail'' keeps end, ''middle'' keeps both ends'
              additionalProperties: false
          additionalProperties: false
      required:
      - repositories
      additionalProperties: false
    ErrorResponse:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details: {}
          required:
          - code
          - message
          additionalProperties: false
      required:
      - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API token (capy_xxxx). Generate at capy.ai/settings/tokens