> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidocs.sare.africa/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.sare.africa/_mcp/server.

# USSD Gateway Callback

POST http://localhost:8080/api/v3/wallet/ussd
Content-Type: application/x-www-form-urlencoded

Public (wallet/ussd/** whitelisted) - the callback a USSD gateway (e.g. Africa's Talking) posts to. Form-urlencoded body, not JSON.

Reference: https://apidocs.sare.africa/sare-core-api/ussd/gateway-callback/ussd-gateway-callback

## Request

### Body (application/x-www-form-urlencoded)

This endpoint expects an object.

- `text` (string, required)
- `sessionId` (string, required)
- `networkCode` (string, required)
- `phoneNumber` (string, required)
- `serviceCode` (string, required)

## Response

### 200

OK

## Examples

**Request**

```json
{
  "text": "string",
  "sessionId": "string",
  "networkCode": "string",
  "phoneNumber": "string",
  "serviceCode": "string"
}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "http://localhost:8080/api/v3/wallet/ussd"

payload = ""
headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, data=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'http://localhost:8080/api/v3/wallet/ussd';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  body: new URLSearchParams('')
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:8080/api/v3/wallet/ussd"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("http://localhost:8080/api/v3/wallet/ussd")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v3/wallet/ussd")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v3/wallet/ussd', [
  'form_params' => null,
  'headers' => [
    'Content-Type' => 'application/x-www-form-urlencoded',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v3/wallet/ussd");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/x-www-form-urlencoded"]

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v3/wallet/ussd")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```