openapi: 3.0.0
info:
  title: OmaxTelecom SMS API
  description: |-
    OmaxTelecom SMS API helps you manage contacts, send SMS messages, and integrate SMS capabilities into your applications.
    
    The API uses HTTP verbs and a RESTful endpoint structure with an access key that is used as the API Authorization. 
    Request and response payloads are formatted as JSON using UTF-8 encoding and URL encoded values.
    
    **AUTHENTICATION:**
    
    All API requests require an `api_token` parameter in the request body. The API token can be obtained from the 
    Developers section in OmaxTelecom Console.
    
    **HEADERS:**
    - `Accept: application/json` (Required)
    - `Content-Type: application/json` (Required)
  version: 1.0.0
servers:
  - url: https://api.omax.dev/sms/api/v1
    description: Sandbox environment for testing
  - url: https://api.omaxtelecom.com/sms/api/v1
    description: Production environment
tags:
  - name: Contacts
    description: |-
      OmaxTelecom SMS Contacts API helps you manage contacts that are identified by a unique random ID. 
      Using this ID, you can create, view, update, or delete contacts. This API works as a collection of 
      customer-specific contacts that allows you to group them and assign custom values that you can later 
      use when sending SMS template messages.
  - name: Contact Groups
    description: Manage contact groups for organizing contacts
  - name: SMS
    description: Send and manage SMS messages
  - name: OTP
    description: One-time password generation and verification
  - name: Voice
    description: Voice call management and operations
  - name: MMS
    description: Multimedia messaging service
  - name: WhatsApp
    description: WhatsApp messaging integration
  - name: Viber
    description: Viber messaging integration
  - name: Profile
    description: User profile management

paths:
  /contacts/{group_id}/store:
    post:
      tags:
        - Contacts
      summary: Create a contact
      description: Creates a new contact object. Returns the created contact object with each request.
      operationId: createContact
      parameters:
        - name: group_id
          in: path
          required: true
          description: Contact Groups uid
          schema:
            type: string
          example: "6065ecdc9184a"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - api_token
                - PHONE
              properties:
                api_token:
                  type: string
                  description: API Token from Developers option
                  example: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
                PHONE:
                  type: string
                  description: The phone number of the contact
                  example: "8801721970168"
                FIRST_NAME:
                  type: string
                  description: First name of the contact (optional, depends on contact group fields configuration)
                  example: "Jhon"
                LAST_NAME:
                  type: string
                  description: Last name of the contact (optional, depends on contact group fields configuration)
                  example: "Doe"
            examples:
              example-1:
                summary: Create contact with basic fields
                value:
                  api_token: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
                  PHONE: "8801721970168"
                  FIRST_NAME: "Jhon"
                  LAST_NAME: "Doe"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "success"
                  data:
                    type: object
                    description: Contact data with all details
                    example:
                      uid: "606732aec8705"
                      group_id: "6065ecdc9184a"
                      PHONE: "8801721970168"
                      FIRST_NAME: "Jhon"
                      LAST_NAME: "Doe"
                      created_at: "2024-01-01T00:00:00Z"
                      updated_at: "2024-01-01T00:00:00Z"
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    description: A human-readable description of the error
                    example: "Invalid phone number format"
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Invalid API token"

  /contacts/{group_id}/search/{uid}:
    post:
      tags:
        - Contacts
      summary: View a contact
      description: Retrieves the information of an existing contact. You only need to supply the unique contact uid and group uid that was returned upon creation or receiving.
      operationId: getContact
      parameters:
        - name: group_id
          in: path
          required: true
          description: Contact Groups uid
          schema:
            type: string
          example: "6065ecdc9184a"
        - name: uid
          in: path
          required: true
          description: Contact uid
          schema:
            type: string
          example: "606732aec8705"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - api_token
              properties:
                api_token:
                  type: string
                  description: API Token from Developers option
                  example: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
            example:
              api_token: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "success"
                  data:
                    type: object
                    description: Contact data with all details
                    example:
                      uid: "606732aec8705"
                      group_id: "6065ecdc9184a"
                      PHONE: "8801721970168"
                      FIRST_NAME: "Jhon"
                      LAST_NAME: "Doe"
                      created_at: "2024-01-01T00:00:00Z"
                      updated_at: "2024-01-01T00:00:00Z"
        '404':
          description: Contact not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Contact not found"
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Invalid API token"

  /contacts/{group_id}/update/{uid}:
    patch:
      tags:
        - Contacts
      summary: Update a contact
      description: Updates an existing contact. You only need to supply the unique uid of contact and contact group uid that was returned upon creation.
      operationId: updateContact
      parameters:
        - name: group_id
          in: path
          required: true
          description: Contact Groups uid
          schema:
            type: string
          example: "6065ecdc9184a"
        - name: uid
          in: path
          required: true
          description: Contact uid
          schema:
            type: string
          example: "606732aec8705"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - api_token
                - PHONE
              properties:
                api_token:
                  type: string
                  description: API Token from Developers option
                  example: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
                PHONE:
                  type: string
                  description: The phone number of the contact
                  example: "8801721970168"
                FIRST_NAME:
                  type: string
                  description: First name of the contact (optional, depends on contact group fields configuration)
                  example: "Jhon"
                LAST_NAME:
                  type: string
                  description: Last name of the contact (optional, depends on contact group fields configuration)
                  example: "Doe"
            example:
              api_token: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
              PHONE: "8801721970168"
              FIRST_NAME: "Jhon"
              LAST_NAME: "Doe"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "success"
                  data:
                    type: object
                    description: Updated contact data with all details
                    example:
                      uid: "606732aec8705"
                      group_id: "6065ecdc9184a"
                      PHONE: "8801721970168"
                      FIRST_NAME: "Jhon"
                      LAST_NAME: "Doe"
                      created_at: "2024-01-01T00:00:00Z"
                      updated_at: "2024-01-01T12:00:00Z"
        '404':
          description: Contact not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Contact not found"
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Invalid API token"

  /contacts/{group_id}/delete/{uid}:
    delete:
      tags:
        - Contacts
      summary: Delete a contact
      description: Deletes an existing contact. You only need to supply the unique contact uid and group uid that was returned upon creation.
      operationId: deleteContact
      parameters:
        - name: group_id
          in: path
          required: true
          description: Contact Groups uid
          schema:
            type: string
          example: "6065ecdc9184a"
        - name: uid
          in: path
          required: true
          description: Contact uid
          schema:
            type: string
          example: "606732aec8705"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - api_token
              properties:
                api_token:
                  type: string
                  description: API Token from Developers option
                  example: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
            example:
              api_token: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "success"
                  data:
                    type: object
                    description: Deleted contact data
                    example:
                      uid: "606732aec8705"
                      deleted: true
        '404':
          description: Contact not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Contact not found"
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Invalid API token"

  /contacts/{group_id}/all:
    post:
      tags:
        - Contacts
      summary: View all contacts in group
      description: Retrieves all contacts in a specific contact group with pagination support.
      operationId: getAllContacts
      parameters:
        - name: group_id
          in: path
          required: true
          description: Contact Groups uid
          schema:
            type: string
          example: "6065ecdc9184a"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - api_token
              properties:
                api_token:
                  type: string
                  description: API Token from Developers option
                  example: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
            example:
              api_token: "534|pBusBf2Uay3LYM2NDKYfB9jzVNCojnG4E46ujYaN7bbdac68"
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "success"
                  data:
                    type: object
                    description: Contacts data with pagination
                    properties:
                      contacts:
                        type: array
                        items:
                          type: object
                          properties:
                            uid:
                              type: string
                            group_id:
                              type: string
                            PHONE:
                              type: string
                            FIRST_NAME:
                              type: string
                            LAST_NAME:
                              type: string
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      pagination:
                        type: object
                        properties:
                          current_page:
                            type: integer
                          total_pages:
                            type: integer
                          total_items:
                            type: integer
                    example:
                      contacts:
                        - uid: "606732aec8705"
                          group_id: "6065ecdc9184a"
                          PHONE: "8801721970168"
                          FIRST_NAME: "Jhon"
                          LAST_NAME: "Doe"
                          created_at: "2024-01-01T00:00:00Z"
                          updated_at: "2024-01-01T00:00:00Z"
                      pagination:
                        current_page: 1
                        total_pages: 1
                        total_items: 1
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: "error"
                  message:
                    type: string
                    example: "Invalid API token"

components:
  schemas:
    Error:
      type: object
      properties:
        status:
          type: string
          example: "error"
        message:
          type: string
          description: A human-readable description of the error
    Success:
      type: object
      properties:
        status:
          type: string
          example: "success"
        data:
          type: object
          description: Response data
    Contact:
      type: object
      properties:
        uid:
          type: string
          description: Unique contact identifier
        group_id:
          type: string
          description: Contact group identifier
        PHONE:
          type: string
          description: Phone number of the contact
        FIRST_NAME:
          type: string
          description: First name of the contact
        LAST_NAME:
          type: string
          description: Last name of the contact
        created_at:
          type: string
          format: date-time
          description: Contact creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Contact last update timestamp
