openapi: 3.0.4
info:
  title: Evolution Foundation - CRM Service - Labels
  description: Management of contacts, conversations, inboxes, labels and macros
  version: 1.1.0
servers:
- url: https://api.evoai.app
  description: Production server
- url: http://localhost:3000
  description: Development server
  variables:
    port:
      default: '3000'
- url: '{customUrl}'
  description: Custom server
  variables:
    customUrl:
      default: https://your-instance.com
      description: Enter your server URL
paths:
  /api/v1/contacts/{id}/labels:
    parameters:
    - name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: ID of the contact
    get:
      operationId: list-all-labels-of-a-contact
      summary: List Labels
      description: Lists all the labels of a contact
      security:
      - userApiKey: []
      responses:
        '200':
          description: Contact labels retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of label strings
                    items:
                      type: string
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Contact labels retrieved successfully
              example:
                success: true
                data:
                - vip
                - priority
                - newsletter
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Contact labels retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                validation_error:
                  summary: Invalid request parameters
                  value:
                    status: 400
                    error: Bad Request
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid or missing token
                  value:
                    status: 401
                    error: Unauthorized
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                forbidden:
                  summary: Access forbidden
                  value:
                    status: 403
                    error: Forbidden
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                contact_not_found:
                  summary: Contact not found
                  value:
                    status: 404
                    error: Not Found
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    status: 500
                    error: Internal Server Error
    post:
      operationId: contact-add-labels
      summary: Add Labels
      description: Add labels to a contact. Note that this API would overwrite the existing list of labels associated to the
        contact.
      security:
      - userApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - labels
              properties:
                labels:
                  type: array
                  description: Array of labels (comma-separated strings)
                  items:
                    type: string
                  example:
                  - support
                  - billing
      responses:
        '200':
          description: Contact labels updated successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of label strings
                    items:
                      type: string
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Contact labels updated successfully
              example:
                success: true
                data:
                - support
                - billing
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Contact labels updated successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                validation_error:
                  summary: Invalid request parameters
                  value:
                    status: 400
                    error: Bad Request
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                invalid_token:
                  summary: Invalid or missing token
                  value:
                    status: 401
                    error: Unauthorized
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                forbidden:
                  summary: Access forbidden
                  value:
                    status: 403
                    error: Forbidden
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                contact_not_found:
                  summary: Contact not found
                  value:
                    status: 404
                    error: Not Found
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                validation_error:
                  summary: Validation failed
                  value:
                    status: 422
                    error: Unprocessable Entity
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    status: 500
                    error: Internal Server Error
components:
  schemas:
    PublicApiErrorResponse:
      type: object
      required:
      - status
      - error
      properties:
        status:
          type: integer
          description: HTTP status code
          example: 404
        error:
          type: string
          description: Error message
          example: Not Found
  securitySchemes:
    userApiKey:
      type: apiKey
      in: header
      name: api_access_token
    ApiAccessToken:
      type: apiKey
      in: header
      name: api_access_token
      description: API access token for user authentication
