Overview

Send SMS through a single connection for timely and cost-efficient communication using the 9bits SMS API.

Authentication

Find your API token for each account in Settings => Security on the 9bits Customer Dashboard.

The token is sent in the Authorization header of each endpoint preceded by Bearer. It's required for all requests made to the SMS API.

Example

Here is an example of authentication within the header. This example is written in Python.

import requests

# Define your API token, service plan ID, and the URL
api_token = "{YOUR_API_Token}"
url = f"https://app.9bits.net/api/v1/sendsms"

# Define the payload data in a Python dictionary
data = {
    "from": "myCode",
    "to": ["2348020000000"],
    "body": "Hi buddy! How are you today?"
}

# Define headers with authorization and content type
headers = {
    "Authorization": f"Bearer {api_token}",
    "Content-Type": "application/json"
}

# Send the POST request
response = requests.post(url, json=data, headers=headers)

# Check the response
if response.status_code == 200:
    print("Request was successful.")
    print(response.json())
else:
    print(f"Request failed with status code: {response.status_code}")
    print(response.text)

SMS REST formats and conventions

JSON

JSON (appplication/json) is the content type of both requests and responses unless otherwise specified.

Requests with invalid JSON will be rejected.

Phone numbers (MSISDN)

Only MSISDNs (phone numbers) in international format are accepted by the API.

Phone numbers can be sent with or without a leading + (for example, +2348020000000 or 2348020000000 are both valid) or with a leading 00.

All phone numbers returned by the REST API will be without a + prefix, even if they were sent with one.

Last updated