---
openapi: 3.0.0
info:
  version: 1.11.8
  title: Account API
  description: |
    The Vonage Business Cloud Account API enables you to retrieve information about accounts.
    
    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}":
    get:
      operationId: AccountCtrl.getAccountServicesByAccountID
      parameters:
        - $ref: "#/components/parameters/AccountID"
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountHalResponse"
        "404":
          description: Account not found
      security:
        - bearerAuth: []
      summary: Get account data by ID

  "/api/accounts/{account_id}/locations":
    get:
      operationId: AccountCtrl.getLocationsByAccountID
      parameters:
        - $ref: "#/components/parameters/AccountID"
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LocationsHalResponse"
      security:
        - bearerAuth: []
      summary: Get account locations data by account ID

  "/api/accounts/{account_id}/locations/{location_id}":
    get:
      operationId: AccountCtrl.getLocationByID
      parameters:
        - $ref: "#/components/parameters/AccountID"
        - in: path
          name: location_id
          required: true
          schema:
            type: number
          description: The Vonage Business Cloud location ID
          example: 327910
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LocationHalResponse"
        "404":
          description: Location not found
      security:
        - bearerAuth: []
      summary: Get location data by account ID and location ID

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

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

  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"
        last:
          $ref: "#/components/schemas/LastHref"

    Address:
      type: object
      properties:
        address_1:
          type: string
          example: "123 Example Street"
          description: Street portion of the address
        address_2:
          type: string
          example: "Apt. 456"
          description: Additional address information
        country:
          type: string
          example: "US"
          description: Country code
        state:
          type: string
          example: "NJ"
          description: State/Province code
        city:
          type: string
          example: "Holmdel"
          description: City name
        postal_code:
          type: string
          example: "07733"
          description: Postal code

    Account:
      properties:
        id:
          type: number
          example: 571700
          description: Unique identifier of the account
        name:
          type: string
          example: "Vonage"
          description: Name of the account
        status:
          type: string
          example: "ACTIVE"
          description: Status of the account
        address:
          $ref: "#/components/schemas/Address"
      type: object

    AccountEmbeddedObject:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Account"
      description: Account object

    AddressWithTimeZone:
      type: object
      properties:
        address_1:
          type: string
          example: "123 Example Street"
          description: Street portion of the address
        address_2:
          type: string
          example: "Apt. 456"
          description: Additional address information
        country:
          type: string
          example: "US"
          description: Country code
        state:
          type: string
          example: "NJ"
          description: State/Province code
        city:
          type: string
          example: "Holmdel"
          description: City name
        postal_code:
          type: string
          example: "07733"
          description: Postal code
        time_zone:
          type: string
          example: "America/New York"
          description: Time zone

    Location:
      type: object
      properties:
        id:
          type: number
          example: 327910
          description: Unique identifier of the location
        name:
          type: string
          example: "Headquarters"
          description: Name of the location
        address:
          $ref: "#/components/schemas/AddressWithTimeZone"

    LocationsEmbeddedObject:
      type: object
      properties:
        data:
          items:
            $ref: "#/components/schemas/Location"
          type: array
      description: Collection of location objects

    LocationEmbeddedObject:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Location"
      description: Location object

    AccountHalResponse:
      type: object
      properties:
        page_size:
          type: number
          example: 100
          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/AccountEmbeddedObject"

    LocationHalResponse:
      type: object
      properties:
        page_size:
          type: number
          example: 100
          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/LocationEmbeddedObject"

    LocationsHalResponse:
      type: object
      properties:
        page_size:
          type: number
          example: 100
        page:
          type: number
          example: 1
        total_pages:
          type: number
          example: 10
        total_items:
          type: number
          example: 100
        _links:
          $ref: "#/components/schemas/Links"
        _embedded:
          $ref: "#/components/schemas/LocationsEmbeddedObject"
