messagebird Purchased Numbers API

Operations for managing purchased phone numbers.

OpenAPI Specification

messagebird-purchased-numbers-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: MessageBird Balance Available Numbers Purchased Numbers API
  description: The MessageBird Balance API provides developers with access to their account balance information. It returns the current payment type, available amount, and currency for the account associated with the API key. This API is useful for monitoring credit usage, building billing dashboards, and setting up automated alerts when account balances fall below a threshold.
  version: '1.0'
  contact:
    name: MessageBird Support
    url: https://support.messagebird.com
  termsOfService: https://www.messagebird.com/en/terms
servers:
- url: https://rest.messagebird.com
  description: Production Server
security:
- accessKey: []
tags:
- name: Purchased Numbers
  description: Operations for managing purchased phone numbers.
paths:
  /phone-numbers:
    get:
      operationId: listPurchasedNumbers
      summary: List purchased phone numbers
      description: Retrieves a paginated list of all phone numbers purchased on the account.
      tags:
      - Purchased Numbers
      parameters:
      - name: limit
        in: query
        required: false
        description: The maximum number of items to return.
        schema:
          type: integer
          default: 20
      - name: offset
        in: query
        required: false
        description: The number of items to skip.
        schema:
          type: integer
          default: 0
      responses:
        '200':
          description: A list of purchased numbers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PurchasedNumberList'
        '401':
          description: Unauthorized
    post:
      operationId: purchaseNumber
      summary: Purchase a phone number
      description: Purchases an available phone number and adds it to the account.
      tags:
      - Purchased Numbers
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NumberPurchase'
      responses:
        '201':
          description: Number purchased
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PurchasedNumber'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '422':
          description: Unprocessable entity
  /phone-numbers/{number}:
    get:
      operationId: viewPurchasedNumber
      summary: View a purchased phone number
      description: Retrieves the details of a specific purchased phone number.
      tags:
      - Purchased Numbers
      parameters:
      - $ref: '#/components/parameters/numberParam'
      responses:
        '200':
          description: Number details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PurchasedNumber'
        '401':
          description: Unauthorized
        '404':
          description: Number not found
    patch:
      operationId: updatePurchasedNumber
      summary: Update a purchased phone number
      description: Updates the configuration of a purchased phone number, such as assigning tags or enabling features.
      tags:
      - Purchased Numbers
      parameters:
      - $ref: '#/components/parameters/numberParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NumberUpdate'
      responses:
        '200':
          description: Number updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PurchasedNumber'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Number not found
    delete:
      operationId: cancelPurchasedNumber
      summary: Cancel a purchased phone number
      description: Cancels a purchased phone number, releasing it from the account.
      tags:
      - Purchased Numbers
      parameters:
      - $ref: '#/components/parameters/numberParam'
      responses:
        '204':
          description: Number cancelled
        '401':
          description: Unauthorized
        '404':
          description: Number not found
components:
  schemas:
    PurchasedNumberList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/PurchasedNumber'
        count:
          type: integer
          description: The number of items returned.
        totalCount:
          type: integer
          description: The total number of purchased numbers.
        offset:
          type: integer
          description: The offset applied.
        limit:
          type: integer
          description: The limit applied.
    NumberUpdate:
      type: object
      properties:
        tags:
          type: array
          description: Tags to assign to the number.
          items:
            type: string
    NumberPurchase:
      type: object
      required:
      - number
      - countryCode
      properties:
        number:
          type: string
          description: The phone number to purchase in E.164 format.
        countryCode:
          type: string
          description: The two-letter ISO 3166-1 country code.
          minLength: 2
          maxLength: 2
        billingIntervalMonths:
          type: integer
          description: The billing interval in months.
          enum:
          - 1
          - 12
          default: 1
    PurchasedNumber:
      type: object
      properties:
        number:
          type: string
          description: The phone number in E.164 format.
        country:
          type: string
          description: The two-letter country code.
        region:
          type: string
          description: The region for the number.
        locality:
          type: string
          description: The locality for the number.
        features:
          type: array
          description: The features enabled for the number.
          items:
            type: string
        tags:
          type: array
          description: Tags assigned to the number.
          items:
            type: string
        type:
          type: string
          description: The type of phone number.
        status:
          type: string
          description: The status of the number.
          enum:
          - active
          - cancelled
        createdAt:
          type: string
          format: date-time
          description: The date and time when the number was purchased.
        renewalAt:
          type: string
          format: date-time
          description: The date and time of the next renewal.
  parameters:
    numberParam:
      name: number
      in: path
      required: true
      description: The phone number in E.164 format.
      schema:
        type: string
  securitySchemes:
    accessKey:
      type: apiKey
      in: header
      name: Authorization
      description: Access key authentication in the form of 'AccessKey {accessKey}'.
externalDocs:
  description: Balance API Documentation
  url: https://developers.messagebird.com/api/balance/