Overview

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

Receive SMS

Example

Here is an example of the SMS that would be delivered to your URL. This example is written in Python.

import requests

# Define the URL
url = f"{{ client URL }}"

# Define the payload data in a Python dictionary
data = {
    "from": "2348020000000",
    "to": "<sms code>",
    "body": "<content>",
    "reference_id": "<ref>",
    "service": "ftue",
    "trx_time": "2023-01-20 14:09"
    
}

# 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.

Your response to our POST request should be a valid JSON.

Phone numbers (MSISDN)

MSISDNs (phone numbers) would always be delivered to you in international format.

Phone numbers will be sent with or without a leading + (for example, +2348020000000 or 2348020000000).

Last updated