openapi: 3.0.3
info:
  title: SOAT Projects API
  version: 1.0.0
  description: API for managing projects (Projects resource)
  contact:
    name: SOAT Team
    url: https://github.com/ttoss/soat
servers:
  - url: '{baseUrl}'
    description: Base URL of your SOAT deployment (e.g. https://your-soat.com or http://localhost:5047)
    variables:
      baseUrl:
        description: The base URL of your SOAT deployment
        default: http://localhost:5047
tags:
  - name: Projects
    description: Manage projects
security:
  - bearerAuth: []
paths:
  /api/v1/projects:
    post:
      tags:
        - Projects
      summary: Create a project
      description: Creates a new project. Requires admin role.
      operationId: createProject
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  example: My Project
      responses:
        '201':
          description: Project created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: proj_V1StGXR8Z5jdHi6B
                  name:
                    type: string
                  created_at:
                    type: string
                    format: date-time
        '401':
          description: Unauthorized
        '403':
          description: Forbidden (non-admin user)
        '500':
          description: Internal server error
  /api/v1/projects/{project_id}:
    get:
      tags:
        - Projects
      summary: Get a project
      description: Returns details of a specific project.
      operationId: getProject
      parameters:
        - name: project_id
          in: path
          required: true
          description: Project public ID (proj_ prefix)
          schema:
            type: string
            example: proj_V1StGXR8Z5jdHi6B
      responses:
        '200':
          description: Project details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectRecord'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Project not found
    delete:
      tags:
        - Projects
      summary: Delete a project
      description: Deletes a project. Requires admin role.
      operationId: deleteProject
      parameters:
        - name: project_id
          in: path
          required: true
          description: Project public ID (proj_ prefix)
          schema:
            type: string
            example: proj_V1StGXR8Z5jdHi6B
      responses:
        '204':
          description: Project deleted successfully
        '401':
          description: Unauthorized
        '403':
          description: Forbidden (non-admin user)
        '404':
          description: Project not found
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT token or sk_ api key
  schemas:
    ProjectRecord:
      type: object
      properties:
        id:
          type: string
          description: Public project ID (proj_ prefix)
          example: proj_V1StGXR8Z5jdHi6B
        name:
          type: string
          example: My Project
        created_at:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00.000Z'
        updated_at:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00.000Z'
