openapi: 3.0.0
info:
  title: Email Sender API
  version: 1.0.0
  description: API for sending emails via Amazon SES using API Gateway and Lambda

servers:
  - url: Enter ApiEndpoint

paths:
  /email-sender:
    post:
      summary: Send an email
      security:
        - OAuth2:
            - email-api/send-email
      description: Sends an email using the provided recipient, subject, and message body
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailRequest'
      responses:
        '200':
          description: Email sent successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: Bad request due to missing fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - Invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

components:
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: Enter CognitoAuthorizationUrl
          tokenUrl: Enter CognitoTokenUrl
          scopes:
            email-api/send-email: Permission to send emails

  schemas:
    EmailRequest:
      type: object
      required:
        - to
        - subject
        - body
      properties:
        to:
          type: string
          format: email
          description: Recipient email address
        subject:
          type: string
          description: Email subject line
        body:
          type: string
          description: Email message content

    SuccessResponse:
      type: object
      properties:
        message:
          type: string
          example: Email sent successfully
        requestId:
          type: string
          description: Unique identifier for the request

    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
        requestId:
          type: string
          description: Unique identifier for the request that caused the error