> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.send-2.com/send-2-sms-api/send-sms/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.send-2.com/_mcp/server. # Send SMS POST https://sms.send-2.com/v1/message Content-Type: application/json Reference: https://docs.send-2.com/send-2-sms-api/send-sms ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Body (application/json) This endpoint expects an object. - `phone` (string, required) — MPESA hashed phone (e.g. 8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d) or standard international format (e.g. +254722000000) - `text` (string, required) — The SMS message content - `sender` (integer, required) — The numeric sender ID assigned to your account ## Response ### 200 OK - `success` (boolean, required) - `message` (string, required) - `data` (V1MessagePostResponsesContentApplicationJsonSchemaData, required) ## Errors ### 406 Not Acceptable Error Not Acceptable - `success` (boolean, required) - `message` (string, required) ## Types ### V1MessagePostResponsesContentApplicationJsonSchemaData - `id` (string, required) - `status` (string, required) - `units` (integer, required) ## Examples ### Success: using MPESA hashed phone **Response** ```json { "success": true, "message": "Processed", "data": { "id": "01ksm2b4y5ttaca57a66f5aw81", "status": "Sent", "units": 1 } } ``` **SDK Code** ```python Success: using MPESA hashed phone import requests url = "https://sms.send-2.com/v1/message" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Success: using MPESA hashed phone const url = 'https://sms.send-2.com/v1/message'; const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Success: using MPESA hashed phone package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sms.send-2.com/v1/message" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Success: using MPESA hashed phone require 'uri' require 'net/http' url = URI("https://sms.send-2.com/v1/message") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java Success: using MPESA hashed phone import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://sms.send-2.com/v1/message") .header("Authorization", "Bearer ") .asString(); ``` ```php Success: using MPESA hashed phone request('POST', 'https://sms.send-2.com/v1/message', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp Success: using MPESA hashed phone using RestSharp; var client = new RestClient("https://sms.send-2.com/v1/message"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift Success: using MPESA hashed phone import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://sms.send-2.com/v1/message")! 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() ``` ### Success: using numeric phone number **Response** ```json { "success": true, "message": "Processed", "data": { "id": "01ksm2b4y5ttaca57a66f5aw81", "status": "Sent", "units": 1 } } ``` **SDK Code** ```python Success: using numeric phone number import requests url = "https://sms.send-2.com/v1/message" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Success: using numeric phone number const url = 'https://sms.send-2.com/v1/message'; const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Success: using numeric phone number package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sms.send-2.com/v1/message" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Success: using numeric phone number require 'uri' require 'net/http' url = URI("https://sms.send-2.com/v1/message") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java Success: using numeric phone number import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://sms.send-2.com/v1/message") .header("Authorization", "Bearer ") .asString(); ``` ```php Success: using numeric phone number request('POST', 'https://sms.send-2.com/v1/message', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp Success: using numeric phone number using RestSharp; var client = new RestClient("https://sms.send-2.com/v1/message"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift Success: using numeric phone number import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://sms.send-2.com/v1/message")! 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() ``` ### Using MPESA hashed phone **Request** ```json { "phone": "8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d", "text": "Hello, your OTP is 123456", "sender": 12345 } ``` **Response** ```json { "success": true, "message": "Processed", "data": { "id": "01ksm2b4y5ttaca57a66f5aw81", "status": "Sent", "units": 1 } } ``` **SDK Code** ```python Using MPESA hashed phone import requests url = "https://sms.send-2.com/v1/message" payload = { "phone": "8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d", "text": "Hello, your OTP is 123456", "sender": 12345 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Using MPESA hashed phone const url = 'https://sms.send-2.com/v1/message'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"phone":"8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d","text":"Hello, your OTP is 123456","sender":12345}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Using MPESA hashed phone package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sms.send-2.com/v1/message" payload := strings.NewReader("{\n \"phone\": \"8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Using MPESA hashed phone require 'uri' require 'net/http' url = URI("https://sms.send-2.com/v1/message") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"phone\": \"8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}" response = http.request(request) puts response.read_body ``` ```java Using MPESA hashed phone import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://sms.send-2.com/v1/message") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"phone\": \"8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}") .asString(); ``` ```php Using MPESA hashed phone request('POST', 'https://sms.send-2.com/v1/message', [ 'body' => '{ "phone": "8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d", "text": "Hello, your OTP is 123456", "sender": 12345 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Using MPESA hashed phone using RestSharp; var client = new RestClient("https://sms.send-2.com/v1/message"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"phone\": \"8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Using MPESA hashed phone import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "phone": "8556a495c390f3ba95d2bdf6d06436f2fd09f516531f0a7cd9591c60812fa46d", "text": "Hello, your OTP is 123456", "sender": 12345 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://sms.send-2.com/v1/message")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` ### Using numeric phone number **Request** ```json { "phone": "+254722000000", "text": "Hello, your OTP is 123456", "sender": 12345 } ``` **Response** ```json { "success": true, "message": "Processed", "data": { "id": "01ksm2b4y5ttaca57a66f5aw81", "status": "Sent", "units": 1 } } ``` **SDK Code** ```python Using numeric phone number import requests url = "https://sms.send-2.com/v1/message" payload = { "phone": "+254722000000", "text": "Hello, your OTP is 123456", "sender": 12345 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Using numeric phone number const url = 'https://sms.send-2.com/v1/message'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"phone":"+254722000000","text":"Hello, your OTP is 123456","sender":12345}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Using numeric phone number package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sms.send-2.com/v1/message" payload := strings.NewReader("{\n \"phone\": \"+254722000000\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Using numeric phone number require 'uri' require 'net/http' url = URI("https://sms.send-2.com/v1/message") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"phone\": \"+254722000000\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}" response = http.request(request) puts response.read_body ``` ```java Using numeric phone number import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://sms.send-2.com/v1/message") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"phone\": \"+254722000000\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}") .asString(); ``` ```php Using numeric phone number request('POST', 'https://sms.send-2.com/v1/message', [ 'body' => '{ "phone": "+254722000000", "text": "Hello, your OTP is 123456", "sender": 12345 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Using numeric phone number using RestSharp; var client = new RestClient("https://sms.send-2.com/v1/message"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"phone\": \"+254722000000\",\n \"text\": \"Hello, your OTP is 123456\",\n \"sender\": 12345\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Using numeric phone number import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "phone": "+254722000000", "text": "Hello, your OTP is 123456", "sender": 12345 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://sms.send-2.com/v1/message")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ```