SMS API code examples

Every call to the BudgetSMS HTTP API is one HTTPS GET request with your credentials in the query string. The response is a single line: OK followed by the result, or ERR followed by an error code. That makes it work from any language or tool; below are complete, working examples.

Languages

  • cURL: Send an SMS, test a call, check your credit and look up a number with cURL on the command line or in a shell script. Copy, fill in your credentials and run.
  • PHP: A small PHP helper for the BudgetSMS HTTP API: send SMS, test, credit, number lookups and a receiver for delivery reports. Plain PHP, no dependencies.
  • Python: Send SMS from Python with the requests library: one helper function for every BudgetSMS API call, with error handling and delivery report lookup.
  • Node.js: Send SMS from Node.js (18 or newer) with the built-in fetch: a helper for the BudgetSMS API plus an Express route that receives delivery reports.
  • Java: Send SMS from Java 11 or newer with java.net.http.HttpClient: a small client class for the BudgetSMS HTTP API with error handling.
  • C# / .NET: Send SMS from C# with HttpClient: async client class for the BudgetSMS HTTP API (.NET 6+), error handling by API code and a test call that sends nothing.

Integrations

  • Laravel: Send SMS from a Laravel application with the Http facade, credentials in config/services.php, and a notification channel for one-time passwords and reminders.
  • WordPress: Send SMS from WordPress or WooCommerce with wp_remote_get, credentials in wp-config.php, and a hook that texts you on every new order.
  • n8n, Zapier and Make: Send SMS without code: the HTTP request settings for n8n, Zapier (Webhooks) and Make to call the BudgetSMS API from any automation.

Official packages

  • PHP: composer require budgetsms/budgetsms-php, one class for every call, PHP 7.4 or newer, no dependencies.
  • Node.js: npm install budgetsms-sdk, ES module with TypeScript types, Node.js 18 or newer, no dependencies.
  • MCP server: npx budgetsms-mcp gives Claude, ChatGPT and other AI assistants tools to send and test SMS, check credit, look up numbers and read prices.

Before you start

You need three values from the control panel (API details): your username, your numeric userid and your API handle. Every example uses the placeholders USERNAME, USERID and HANDLE for them. Test your integration with /testsms/: it accepts the same parameters as /sendsms/, and answers in the same format, but it is a simulator: no SMS is sent and nothing is charged, the message id and price are random, and about one in five calls returns a random ERR 2xxx so your error handling gets exercised. It does not check the destination number.

Phone numbers are written in international format without a leading + or 00, for example 31612345678 for a Dutch mobile number. Delivery reports arrive by Push DLR (we call your URL) or with Pull DLR (you ask per message). The complete machine-readable description of the API is the OpenAPI specification.