openapi: 3.0.0
info:
  title: Make Edge API
  contact:
    name: Apifonica Support
    email: support@apifonica.com
  x-logo:
    url: 'https://apifonica.com/public/img/logo.svg'
    altText: Apifonica logo
  description: |-
    Using this service, you can run single communication via Call or SMS.

    ## Usage
    ##### PRECONDITIONS
    You have to be registered Apifonica user for using this service

    1. Register an Apifonica account (https://apifonica.com/)
    2. Get account_sid and account_token in your personal account profile (https://account.apifonica.com/profile).
    3. Buy a phone number (for Call communications) in Apifonica personal account (https://account.apifonica.com/numbers/buy/) and register an alpha name (if you need to send SMS)

    ##### USER FLOW
    1. Create scenario
    2. Create campaign
    3. Save somewhere Campaign ID (you can do it after campaign created clicking on it)

    See the documentation of API interface description below
  version: '1.0'
servers:
  - url: 'https://make.edge.apifonica.com/'
    variables: {}
tags:
  - name: Call
    description: Below you can see Call communications API
  - name: SMS
    description: Below you can see SMS communications API
  - name: Webhook
    description: Below you can see Webhook API
  - name: Helpers
    description: Below you can see Helpers API
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: |
        * `Username` - equal to your `account_sid` (e.g., acc89ddf772-5df2-41d7-b257-000000000000)
        * `Password` - equal to your `token` (e.g., auta42e0580-8138-308a-a354-000000000000)
security:
  - httpBasic: []
paths:
  /api/v1/call/simple:
    post:
      description: Use this endpoint to create a Call communication
      operationId: CallService_SimpleCall
      requestBody:
        content:
          application/json:
            schema:
              properties:
                campaign_sid:
                  description: The ID of created campaign in Apifonica
                  type: string
                  example: faebf8ba-9696-4c4e-b32b-097a335caaa2
                country_code:
                  description: PL, LV, RO or empty for default phone normalization
                  type: string
                  example: PL
                phone:
                  description: Recipient number
                  type: string
                  example: 48221234567
                placeholders:
                  type: array
                  description: Array of placeholder objects to use in the campaign scenario
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        description: Placeholder key to replace in the campaign scenario
                        example: name
                      value:
                        type: string
                        description: Value to replace the placeholder with
                        example: Test
              type: object
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  contact_sid:
                    type: string
                  communication_time:
                    type: string
                    format: date-time
                    description: Optional field containing the time of communication
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      security:
        - basicAuth: [ ]
      summary: Start Call
      tags:
        - Call
  /api/v1/call/custom:
    post:
      description: Use this endpoint to create a Call communication with re-tries and scheduling
      operationId: CallService_CustomCall
      requestBody:
        content:
          application/json:
            schema:
              properties:
                campaign_sid:
                  description: The ID of created campaign in Apifonica
                  type: string
                  example: faebf8ba-9696-4c4e-b32b-097a335caaa2
                country_code:
                  description: PL, LV, RO or empty for default phone normalization
                  type: string
                  example: PL
                phone:
                  description: Recipient number
                  type: string
                  example: 48221234567
                placeholders:
                  type: array
                  description: Array of placeholder objects to use in the campaign scenario
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        description: Placeholder key to replace in the campaign scenario
                        example: name
                      value:
                        type: string
                        description: Value to replace the placeholder with
                        example: Test
                retries:
                  type: array
                  description: An array of integers representing the number of minutes to wait before retrying the call.
                  items:
                    type: integer
                    example: 5
                schedule:
                  type: object
                  description: An object representing the schedule for the call campaign.
                  properties:
                    days:
                      type: string
                      description: workdays or everyday.
                      example: workdays
                    start_hour:
                      type: integer
                      description: The starting hour of the call window.
                      example: 9
                    end_hour:
                      type: integer
                      description: The ending hour of the call window.
                      example: 18
              type: object
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  contact_sid:
                    type: string
                  communication_time:
                    type: string
                    format: date-time
                    description: Optional field containing the time of communication
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      security:
        - basicAuth: [ ]
      summary: Start Custom Call
      tags:
        - Call
  /api/v1/sms/simple:
    post:
      description: Use this endpoint to send an SMS
      operationId: SMSService_SimpleSMS
      requestBody:
        content:
          application/json:
            schema:
              properties:
                alpha_name:
                  type: string
                  description: The alphanumeric sender ID (up to 11 characters) or phone number in E.164 format (up to 15 digits).
                  example: "APIF2020"
                country_code:
                  type: string
                  description: PL, LV, RO or empty for default phone normalization.
                  example: "PL"
                phone:
                  type: string
                  description: The recipient's phone number in E.164 format (up to 15 digits).
                  example: "48221234567"
                message:
                  type: string
                  description: The message to be sent.
                  example: "Text to send"
              type: object
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  contact_sid:
                    type: string
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      security:
        - basicAuth: [ ]
      summary: Send SMS
      tags:
        - SMS
  /api/v1/webhook/attach:
    post:
      description: Use this endpoint to attach a webhook to a campaign where communication results will be send
      operationId: Webhook_Attach
      requestBody:
        content:
          application/json:
            schema:
              properties:
                url:
                  type: string
                  description: The URL of the webhook endpoint.
                  example: "https://requestcatcher.com"
                campaign_sid:
                  type: string
                  format: uuid
                  description: The unique identifier of the campaign.
                  example: "faebf8ba-9696-4c4e-b32b-097a335caaa2"
              type: object
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  external_hook_id:
                    type: string
                    description: The unique identifier of the webhook.
                    example: "whebf8ba-9696-4c4e-b32b-097a335caaa2"
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      security:
        - basicAuth: [ ]
      summary: Attach Webhook
      tags:
        - Webhook
  /api/v1/webhook/detach/{external_hook_id}:
    delete:
      description: Use this endpoint to detach a webhook from a campaign
      operationId: Webhook_Detach
      parameters:
        - in: path
          name: external_hook_id
          required: true
          description: The unique identifier of the webhook attachment.
          schema:
            type: string
            format: uuid
            example: "whXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      responses:
        '200':
          description: OK
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      security:
        - basicAuth: [ ]
      summary: Detach Webhook
      tags:
        - Webhook
  /api/v1/sms/alpha-name:
    get:
      description: Use this endpoint to get Alpha names for the account
      operationId: Helpers_GetAlphaNames
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  alpha_names:
                    type: array
                    items:
                      type: string
                      example: "APIF2020"
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      parameters:
        - name: limit
          description: An amount of items to return
          in: query
          required: false
          schema:
            type: string
        - name: offset
          description: An amount of items to skip
          in: query
          required: false
          schema:
            type: string
      security:
        - basicAuth: [ ]
      summary: Get available Alpha Names
      tags:
        - Helpers
  /api/v1/campaign:
    get:
      description: Use this endpoint to get a list of available campaigns
      operationId: Helpers_GetCampaigns
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    sid:
                      type: string
                      description: The unique identifier of the campaign
                    scenario_sid:
                      type: string
                      description: The unique identifier of the scenario associated with the campaign
                    name:
                      type: string
                      description: The name of the campaign
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      parameters:
        - name: limit
          description: An amount of items to return
          in: query
          required: false
          schema:
            type: string
        - name: offset
          description: An amount of items to skip
          in: query
          required: false
          schema:
            type: string
      security:
        - basicAuth: [ ]
      summary: Get available campaigns
      tags:
        - Helpers
  /api/v1/user/check:
    get:
      description: Use this endpoint to check if user has access
      operationId: Helpers_CheckUser
      responses:
        '200':
          description: OK
        default:
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
          description: An unexpected error response.
      security:
        - basicAuth: [ ]
      summary: Check user access
      tags:
        - Helpers
