---
openapi: 3.0.0
info:
  version: 1.11.8
  title: Extension API
  description: |
    The Vonage Business Cloud Extension API enables you to retrieve information about extensions.

    Your application must subscribe to the Provisioning API suite to use this API.
  contact:
    name: "Vonage Business Cloud Support"
    url: "https://businesssupport.vonage.com/contactus"
  termsOfService: "https://www.vonage.com/business/legal-policy-center/business-cloud/tos"

servers:
  - url: "https://api.vonage.com/t/vbc.prod/provisioning"
paths:
  "/api/accounts/{account_id}/extensions":
    get:
      operationId: ExtensionCtrl.getAccountExtensions
      parameters:
        - $ref: "#/components/parameters/AccountID"
        - in: query
          name: page_size
          required: false
          schema:
            type: number
          description: Number of records per page
          example: 10
        - in: query
          name: page
          required: false
          schema:
            type: number
          description: Current page number
          example: 10
        - in: query
          name: location_id
          required: false
          schema:
            type: number
          description: Filter by location id
          example: 145214
        - in: query
          name: phone_number
          required: false
          schema:
            type: string
          description: Filter by phone number
          example: "14155550100"
        - in: query
          name: login_name
          required: false
          schema:
            type: string
          description: Filter by login name
          example: "jsmith"
        - in: query
          name: email
          required: false
          schema:
            type: string
          description: Filter by email address
          example: "john.smith@example.com"
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EndUserRouteHalResponse"
        "400":
          description: Invalid parameters given
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorsResponse"
      security:
        - bearerAuth: []
      summary: Get account extensions data by account ID

  "/api/accounts/{account_id}/extensions/{extension_number}":
    get:
      operationId: ExtensionCtrl.getAccountExtensionByID
      parameters:
        - $ref: "#/components/parameters/AccountID"
        - in: path
          name: extension_number
          required: true
          schema:
            type: number
          description: The extension number
          example: 789
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EndUserRouteHalResponse"
        "404":
          description: Extension not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
      security:
        - bearerAuth: []
      summary: Get extension data by account ID and extension number

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: OAuth

  parameters:
    AccountID:
      in: path
      name: account_id
      required: true
      schema:
        type: string
      description: The Vonage Business Cloud account ID

  schemas:
    FirstHref:
      type: object
      properties:
        href:
          type: string
      description: URL to the first page of records
    PrevHref:
      type: object
      properties:
        href:
          type: string
      description: URL to the previous page of records
    SelfHref:
      type: object
      properties:
        href:
          type: string
      description: URL to the current page of records
    NextHref:
      type: object
      properties:
        href:
          type: string
      description: URL to the next page of records
    LastHref:
      type: object
      properties:
        href:
          type: string
      description: URL to the last page of records

    Links:
      type: object
      properties:
        first:
          $ref: "#/components/schemas/FirstHref"
        prev:
          $ref: "#/components/schemas/PrevHref"
        self:
          $ref: "#/components/schemas/SelfHref"
        next:
          $ref: "#/components/schemas/NextHref"

    BasicUser:
      type: object
      properties:
        email:
          type: string
          description: Email address of the user
          example: "john.smith@example.com"
        login_name:
          type: string
          description: Login name of the user
          example: "jsmith"
        first_name:
          type: string
          description: First name of the user
          example: "John"
        last_name:
          type: string
          description: Last name of the user
          example: "Smith"

    DID:
      type: object
      properties:
        phone_number:
          type: string
          description: Phone number
          example: "14155550100"
        custom_tag:
          type: string
          description: Custom tag associated with the phone number
          example: "My Tag"

    Line:
      type: object
      properties:
        handset_name:
          type: string
          description: Name of the handset
          example: "line1-VH6370927"
        sip_id:
          type: string
          description: SIP identifier of the handset
          example: "VH16370927"

    EndUserRoute:
      type: object
      properties:
        extension_number:
          type: string
          description: Extension number
          example: "789"
        user:
          $ref: "#/components/schemas/BasicUser"
        location_id:
          type: number
          description: Unique identifier of the assigned location
          example: 145214
        vtt_enabled:
          type: boolean
          description: Voicemail transcription status of the location
          example: true
        dnd_enabled:
          type: boolean
          description: Do Not Disturb status of the extension
          example: false
        caller_id:
          type: string
          description: Caller ID of the extension
          example: "John Smith"
        block_caller_id:
          type: boolean
          description: Block Caller ID status of the extension
          example: false
        dids:
          items:
            $ref: "#/components/schemas/DID"
          type: array
          description: Collection of phone numbers assigned to the extension
        extension_handsets:
          items:
            $ref: "#/components/schemas/Line"
          type: array
          description: Collection of handsets assigned to the extension

    EndUserRouteEmbeddedObject:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/EndUserRoute"

    EndUserRouteHalResponse:
      type: object
      properties:
        page_size:
          type: number
          example: 10
          description: Number of records per page
        page:
          type: number
          example: 1
          description: Current page number
        total_pages:
          type: number
          example: 10
          description: Total number of pages
        total_items:
          type: number
          example: 100
          description: Total number of records
        _links:
          $ref: "#/components/schemas/Links"
        _embedded:
          $ref: "#/components/schemas/EndUserRouteEmbeddedObject"

    ErrorResponse:
      type: object
      properties:
        msg:
          description: Error message
          type: string
        status:
          description: Http Response Code
          type: number

    ValidationErrorsResponse:
      type: object
      properties:
        status:
          description: Error status code
          type: number
        title:
          description: Error title
          type: string
        instance:
          description: Error Track ID
          type: string
        invalid_parameters:
          items:
            $ref: "#/components/schemas/DetailedInvalidParam"
          description: Invalid parameters and their reason for failing
          type: array

    DetailedInvalidParam:
      type: object
      properties:
        name:
          type: string
          description: Invalid property name
        reason:
          type: string
          description: Invalid property reason
