USSD
Build a USSD service with Galatext: request a shared or dedicated code, publish a menu, and review caller sessions. Every customer endpoint below requires a bearer JWT. Your API key is not accepted for these requests.
Code requests start in REQUESTED. Galatext arranges code allocation and activation; submitting a request does not allocate a code or collect a service fee automatically.
Endpoints
| Method | Path | Purpose |
|---|---|---|
POST | /api/ussd/applications | Request a code |
GET | /api/ussd/applications | List your services |
GET | /api/ussd/stats | Get service and phone-session totals |
GET | /api/ussd/applications/:id | Read a service and saved menu |
PUT | /api/ussd/applications/:id/menu | Save a draft menu |
POST | /api/ussd/applications/:id/publish | Publish the saved menu |
POST | /api/ussd/applications/:id/preview | Evaluate a menu without a phone session |
GET | /api/ussd/applications/:id/sessions | Read live phone-session history |
Service IDs are UUIDs. Customers can access only their own services. Code assignment, activation, and network connection setup are managed by Galatext.
Request a code
const service = await client.ussd.create({
name: 'Customer support',
description: 'Customers can view our opening hours and contact details.',
codeType: 'SHARED',
});name must be 3–80 characters, description 10–1,000 characters, and codeType either SHARED or DEDICATED. An account can have at most ten requests awaiting review.
Services include provider: "GALATEXT", status, serviceCode, operatorNote, menuVersion, publishedVersion, publishedAt, sessionsCount, and timestamps. Detail responses also include the saved menu. serviceCode is empty until assigned. An operatorNote may contain a setup update from Galatext.
Save and publish a menu
const menu = {
screens: [
{
id: 'main',
type: 'MENU',
text: 'Welcome to Acme. How can we help?',
options: [{ key: '1', label: 'Opening hours', next: 'hours' }],
},
{
id: 'hours',
type: 'END',
text: 'We are open Monday to Friday, 8am to 5pm.',
options: [],
},
],
};
const saved = await client.ussd.saveMenu(service.id, service.menuVersion, menu);
const published = await client.ussd.publish(service.id, saved.menuVersion);There must be 1–30 screens with unique IDs and a root screen named main. Every screen must be reachable from the root. A MENU screen has 1–9 options with unique numeric keys 1–9, labels, and valid next targets. An END screen has no options. Each rendered screen, including options and navigation, must fit within 160 characters.
Callers can enter 0 to return to the main menu or 00 to exit. The current menu engine handles numeric navigation and end messages. It does not collect free-text answers or call your business API.
Saving a draft increments menuVersion without changing the published menu. Publish the current saved version to make it available to new phone sessions. If another editor saved first, the API returns 409; reload the service before saving again. An existing phone session keeps the menu version it started with.
Preview
const main = await client.ussd.preview(service.id);
const hours = await client.ussd.preview(service.id, '1', menu);
console.log(hours.message, hours.ended);text is the cumulative numeric response path, such as 1*2. Omit menu to preview the saved draft, or pass a menu to test unsaved changes. Results include message, response (prefixed with CON or END), ended, screen, and failed.
Preview does not create a live session, change statistics, or deduct credits. A successful preview does not mean the service code is active on a handset.
Services and sessions
const services = await client.ussd.list({ page: 1, limit: 10, status: 'ACTIVE', search: 'support' });
const sessions = await client.ussd.sessions(service.id, { page: 1, limit: 20 });
const totals = await client.ussd.stats();Both lists return { data, total, page, limit, totalPages }; page size is 1–50. Service states are REQUESTED, ACTIVE, SUSPENDED, and REJECTED. Service search matches name or assigned code.
Session states are ACTIVE, COMPLETED, EXPIRED, and FAILED. Session records contain a Galatext session id, phoneNumber, status, lastScreen, steps, and timestamps. Filter sessions using status. Phone sessions expire after three minutes. Preview runs are excluded.
Statistics include totalServices, activeServices, requestedServices, totalSessions, activeSessions, completedSessions, expiredSessions, and failedSessions.
Once Galatext activates the code, dial it on a handset and check the resulting live session. Contact info@galatext.com for allocation, activation, or service charges.