Overview
These starter clients and Postman files call https://api.smstake.com. They are copy-paste boilerplates, not a published package. RCS, Voice and WhatsApp use SMSTAKE_API_KEY as a Bearer token under https://api.smstake.com/v1/. SMS uses a username and password on its own paths. Request fields are on each channel reference.
Environment variables
Set these in the shell before you run a snippet. SMSTAKE_BASE_URL is the host only, with no path and no trailing slash. SMSTAKE_API_KEY is the Bearer token issued at onboarding. Channel samples that say SMSTAKE_API_TOKEN mean this same value. Voice may send it as X-API-Key instead of Bearer. Do not send both.
| Variable | Example | Used by |
|---|---|---|
SMSTAKE_BASE_URL | https://api.smstake.com | Every snippet and Postman request |
SMSTAKE_API_KEY | YOUR_API_TOKEN | RCS, Voice and WhatsApp |
SMSTAKE_USERNAME | YOUR_USERNAME | SMS |
SMSTAKE_PASSWORD | YOUR_PASSWORD | SMS |
export SMSTAKE_BASE_URL="https://api.smstake.com"
export SMSTAKE_API_KEY="YOUR_API_TOKEN"
export SMSTAKE_USERNAME="YOUR_USERNAME"
export SMSTAKE_PASSWORD="YOUR_PASSWORD"
$env:SMSTAKE_BASE_URL = "https://api.smstake.com"
$env:SMSTAKE_API_KEY = "YOUR_API_TOKEN"
$env:SMSTAKE_USERNAME = "YOUR_USERNAME"
$env:SMSTAKE_PASSWORD = "YOUR_PASSWORD"
Postman collections
Download the environment and the collection for the channel you are calling. In Postman, choose Import and select both files, then pick the SMSTAKE environment in the environment menu before you send. Replace the placeholder token, username and password. A hosted Run in Postman button needs a public Postman workspace, so these files are the collection you import.
| Collection | Requests | Download |
|---|---|---|
| SMS | HTTP GET send, JSON send, pull delivery report | SMS collection |
| RCS | POST /v1/rcs/send and /v1/rcs/send-batch | RCS collection |
| Voice | POST /v1/voice/call and /v1/voice/otp | Voice collection |
POST /v1/whatsapp/send utility template | WhatsApp collection |
Client boilerplates
Each snippet reads SMSTAKE_BASE_URL and SMSTAKE_API_KEY, then posts a WhatsApp utility template to https://api.smstake.com/v1/whatsapp/send. Change the path for RCS or Voice. SMS does not use this header. Send it with SMSTAKE_USERNAME and SMSTAKE_PASSWORD, as in the SMS API samples.
Node.js and TypeScript
Node.js 18 or later includes fetch. Save the file as smstake.ts and run it with your TypeScript runner, or remove the type annotations for plain Node.js.
const baseUrl = process.env.SMSTAKE_BASE_URL ?? "https://api.smstake.com";
const apiKey = process.env.SMSTAKE_API_KEY;
export async function smstakePost(path: string, body: unknown) {
const res = await fetch(`${baseUrl}${path}`, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
return res.json();
}
console.log(await smstakePost("/v1/whatsapp/send", {
to: "+919876543210",
type: "template",
template: {
name: "order_shipped",
language: "en",
category: "utility",
components: [{ type: "body", parameters: [{ type: "text", text: "ORD-2847" }] }]
}
}));
Python
import os, requests
base_url = os.environ.get("SMSTAKE_BASE_URL", "https://api.smstake.com")
api_key = os.environ["SMSTAKE_API_KEY"]
def smstake_post(path, body):
resp = requests.post(
f"{base_url}{path}",
headers={"Authorization": f"Bearer {api_key}"},
json=body,
timeout=30,
)
resp.raise_for_status()
return resp.json()
print(smstake_post("/v1/whatsapp/send", {
"to": "+919876543210",
"type": "template",
"template": {
"name": "order_shipped",
"language": "en",
"category": "utility",
"components": [{"type": "body", "parameters": [{"type": "text", "text": "ORD-2847"}]}],
},
}))
PHP
<?php
$baseUrl = getenv("SMSTAKE_BASE_URL") ?: "https://api.smstake.com";
$apiKey = getenv("SMSTAKE_API_KEY");
$ch = curl_init($baseUrl . "/v1/whatsapp/send");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"to" => "+919876543210",
"type" => "template",
"template" => [
"name" => "order_shipped",
"language" => "en",
"category" => "utility",
"components" => [["type" => "body", "parameters" => [["type" => "text", "text" => "ORD-2847"]]]],
],
]),
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);
Java
var baseUrl = System.getenv().getOrDefault("SMSTAKE_BASE_URL", "https://api.smstake.com");
var apiKey = System.getenv("SMSTAKE_API_KEY");
var body = """
{"to":"+919876543210","type":"template","template":{"name":"order_shipped","language":"en","category":"utility","components":[{"type":"body","parameters":[{"type":"text","text":"ORD-2847"}]}]}}
""";
var client = java.net.http.HttpClient.newHttpClient();
var request = java.net.http.HttpRequest.newBuilder()
.uri(java.net.URI.create(baseUrl + "/v1/whatsapp/send"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(java.net.http.HttpRequest.BodyPublishers.ofString(body))
.build();
var response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
C#
var baseUrl = Environment.GetEnvironmentVariable("SMSTAKE_BASE_URL") ?? "https://api.smstake.com";
var apiKey = Environment.GetEnvironmentVariable("SMSTAKE_API_KEY");
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var json = """{"to":"+919876543210","type":"template","template":{"name":"order_shipped","language":"en","category":"utility","components":[{"type":"body","parameters":[{"type":"text","text":"ORD-2847"}]}]}}""";
var response = await client.PostAsync(baseUrl + "/v1/whatsapp/send", new StringContent(json, Encoding.UTF8, "application/json"));
Console.WriteLine(await response.Content.ReadAsStringAsync());