openapi: 3.0.0
info:
  title: Evolution Foundation - Evolution Go - Newsletter
  description: Go implementation of Evolution
  version: '1.0'
servers:
- url: http://localhost:8080/
  description: Development server (HTTP)
- url: https://localhost:8080/
  description: Development server (HTTPS)
- url: '{customUrl}'
  description: Custom server
  variables:
    customUrl:
      default: https://your-instance.com
      description: Enter your server URL
paths:
  /newsletter/create:
    post:
      description: Create newsletter
      summary: Create newsletter
      responses:
        '200':
          description: Newsletter created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                  newsletter:
                    type: object
              example:
                data:
                  id: "120360000000000001@newsletter"
                  state:
                    type: "active"
                  thread_metadata:
                    creation_time: "1700000000"
                    invite: "0029VaAbBbCcDdEeFfGgHh01"
                    name:
                      text: "Newsletter Name"
                      id: "1700000000000008"
                      update_time: "1700000000000008"
                    description:
                      text: "Newsletter description"
                      id: "1700000000000008"
                      update_time: "1700000000000008"
                    subscribers_count: "0"
                    verification: "unverified"
                    picture: null
                    preview:
                      url: ""
                      id: "1700000000829122"
                      type: "PREVIEW"
                      direct_path: ""
                      hash: null
                    settings:
                      reaction_codes:
                        value: ""
                  viewer_metadata:
                    mute: "on"
                    role: "owner"
                message: "success"
        '400':
          description: Bad Request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: BAD_REQUEST
                  message: Invalid request data. Newsletter information is required.
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/create
                  method: POST
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid or missing API key
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/create
                  method: POST
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to create newsletter
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/create
                  method: POST
        '404':
          description: Not Found - Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: Resource not found
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/create
                  method: POST
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: An unexpected error occurred
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/create
                  method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateNewsletter'
        description: Newsletter data
  /newsletter/info:
    post:
      description: Get newsletter
      summary: Get newsletter
      responses:
        '200':
          description: Newsletter retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  newsletter:
                    type: object
              example:
                data:
                  id: ""
                  state:
                    type: "non_existing"
                  thread_metadata:
                    creation_time: "0"
                    invite: ""
                    name:
                      text: ""
                      id: ""
                      update_time: "0"
                    description:
                      text: ""
                      id: ""
                      update_time: "0"
                    subscribers_count: "0"
                    verification: ""
                    picture: null
                    preview:
                      url: ""
                      id: ""
                      type: ""
                      direct_path: ""
                      hash: null
                    settings:
                      reaction_codes:
                        value: ""
                  viewer_metadata: null
                message: "success"
        '400':
          description: Bad Request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: BAD_REQUEST
                  message: Invalid request data. Newsletter information is required.
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/info
                  method: POST
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid or missing API key
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/info
                  method: POST
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to get newsletter
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/info
                  method: POST
        '404':
          description: Not Found - Newsletter not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: Newsletter not found
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/info
                  method: POST
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: An unexpected error occurred
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/info
                  method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetNewsletter'
        description: Newsletter data
  /newsletter/link:
    post:
      description: Get newsletter invite
      summary: Get newsletter invite
      responses:
        '200':
          description: Newsletter invite retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  inviteLink:
                    type: string
              example:
                data:
                  id: ""
                  state:
                    type: "non_existing"
                  thread_metadata:
                    creation_time: "0"
                    invite: ""
                    name:
                      text: ""
                      id: ""
                      update_time: "0"
                    description:
                      text: ""
                      id: ""
                      update_time: "0"
                    subscribers_count: "0"
                    verification: ""
                    picture: null
                    preview:
                      url: ""
                      id: ""
                      type: ""
                      direct_path: ""
                      hash: null
                    settings:
                      reaction_codes:
                        value: ""
                  viewer_metadata: null
                message: "success"
        '400':
          description: Bad Request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: BAD_REQUEST
                  message: Invalid request data. Newsletter information is required.
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/link
                  method: POST
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid or missing API key
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/link
                  method: POST
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to get newsletter invite
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/link
                  method: POST
        '404':
          description: Not Found - Newsletter not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: Newsletter not found
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/link
                  method: POST
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: An unexpected error occurred
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/link
                  method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetNewsletterInvite'
        description: Newsletter data
  /newsletter/list:
    get:
      description: List newsletters
      summary: List newsletters
      responses:
        '200':
          description: Newsletters listed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  newsletters:
                    type: array
                    items:
                      type: object
              example:
                data:
                - id: "120360000000000001@newsletter"
                  state:
                    type: "active"
                  thread_metadata:
                    creation_time: "1700000000"
                    invite: "0029VaAbBbCcDdEeFfGgHh01"
                    name:
                      text: "Newsletter Name"
                      id: "1700000000000008"
                      update_time: "1700000000000008"
                    description:
                      text: "Newsletter description"
                      id: "1700000000000008"
                      update_time: "1700000000000008"
                    subscribers_count: "0"
                    verification: "unverified"
                    picture: null
                    preview:
                      url: ""
                      id: "1700000000000009"
                      type: "PREVIEW"
                      direct_path: ""
                      hash: null
                    settings:
                      reaction_codes:
                        value: "ALL"
                  viewer_metadata:
                    mute: "on"
                    role: "owner"
                message: "success"
        '400':
          description: Bad Request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: BAD_REQUEST
                  message: Invalid request data
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/list
                  method: GET
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid or missing API key
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/list
                  method: GET
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to list newsletters
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/list
                  method: GET
        '404':
          description: Not Found - Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: Resource not found
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/list
                  method: GET
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: An unexpected error occurred
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/list
                  method: GET
  /newsletter/messages:
    post:
      description: Get newsletter messages
      summary: Get newsletter messages
      responses:
        '200':
          description: Newsletter messages retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  messages:
                    type: array
                    items:
                      type: object
              example:
                data: []
                message: "success"
        '400':
          description: Bad Request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: BAD_REQUEST
                  message: Invalid request data. Newsletter information is required.
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/messages
                  method: POST
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid or missing API key
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/messages
                  method: POST
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to get newsletter messages
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/messages
                  method: POST
        '404':
          description: Not Found - Newsletter not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: Newsletter not found
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/messages
                  method: POST
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: An unexpected error occurred
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/messages
                  method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetNewsletterMessages'
        description: Newsletter data
  /newsletter/subscribe:
    post:
      description: Subscribe newsletter
      summary: Subscribe newsletter
      responses:
        '200':
          description: Subscribed to newsletter successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
              example:
                message: "success"
        '400':
          description: Bad Request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: BAD_REQUEST
                  message: Invalid request data. Newsletter information is required.
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/subscribe
                  method: POST
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid or missing API key
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/subscribe
                  method: POST
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to subscribe to newsletter
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/subscribe
                  method: POST
        '404':
          description: Not Found - Newsletter not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: Newsletter not found
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/subscribe
                  method: POST
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: An unexpected error occurred
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                  path: /newsletter/subscribe
                  method: POST
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetNewsletter'
        description: Newsletter data
components:
  schemas:
    CreateNewsletter:
      type: object
      properties:
        description:
          type: string
        name:
          type: string
    ErrorResponse:
      type: object
      required:
      - success
      - error
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          required:
          - code
          - message
          properties:
            code:
              type: string
            message:
              type: string
        meta:
          type: object
          properties:
            timestamp:
              type: string
              format: date-time
            path:
              type: string
            method:
              type: string
    GetNewsletter:
      type: object
      properties:
        jid:
          $ref: '#/components/schemas/JID'
    GetNewsletterInvite:
      type: object
      properties:
        key:
          type: string
    GetNewsletterMessages:
      type: object
      properties:
        before_id:
          type: integer
        count:
          type: integer
        jid:
          $ref: '#/components/schemas/JID'
    JID:
      type: object
      properties:
        device:
          type: integer
        integrator:
          type: integer
        rawAgent:
          type: integer
        server:
          type: string
        user:
          type: string
