> For the complete documentation index, see [llms.txt](https://developer.9bits.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.9bits.net/messaging/two-way-sms/rest-api/overview.md).

# Overview

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

## Send SMS

### Example

Here is an example of the SMS that should be sent to 9bits endpoint. This example is written in Python.

{% code overflow="wrap" %}

```python
import requests

api_token = "{YOUR_API_Token}"
url = f"https://app.9bits.net:2081/ng/v1/sendsms"

# Define the payload data in a Python dictionary
data = {
    "from": "48974",
    "to": "2348020000000",
    "message": "When was the last time you went to the cinema?",
    "session_id": "67543uhn3",
    "sent_date": "2024-01-02T23:50:37.000000Z"
}

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

```

{% endcode %}

## Receive SMS

### Example

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

```python
import requests

url = f"{{ client_url }}"

# Define the payload data in a Python dictionary
data = {
    "type": "two-way sms"
    "telco": "mtn",
    "from": "2348020000000",
    "to": "48974",
    "message": "When was the last time you went to the cinema?",
    "session_id": "67543uhn3",
    "sent_date": "2024-01-02T23:50:37.000000Z"
}

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.9bits.net/messaging/two-way-sms/rest-api/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
