必要なもの
- 独自ソフトウェアを動かせる、またはHTTPリクエストを送れるハードウェア(モデムプール、SIMバンク、GoIP)
- お住まいの国で、あなたまたはあなたの会社の名義で適法に登録されたSIMカード
- 承認済みのゲートウェイ申請
モデムプール、SIMバンク、GoIPゲートウェイを署名付き REST API で接続します。ポートを登録し、heartbeat を送り、受信SMSを転送し、各割り当てを webhook、long-poll、heartbeat のいずれかで確認します。
この方法でのあなたの取り分:各売上の100%。
ハードウェア、通信事業者、回線数をお知らせください。すべての申請を担当者が確認します。
承認後、ダッシュボードでゲートウェイを作成します。キーとシークレットが1回だけ表示されます。
各ポートを番号と通信事業者とともに送信し、当社が発行するSMSコードで各回線を確認します。
heartbeat を送り、すべての受信SMSを転送し、割り当てを確認します。あなたの回線はプール内の他の回線と同様に販売されます。
HTTPS上のJSON APIです。すべてのリクエストはゲートウェイのシークレットで署名されるため、キーだけを見ても誰も使えません。
https://smsgrab.com/api/supply/v1
すべてのリクエストにこの4つのヘッダーを付けてください。タイムスタンプは当社の時計との差が5分以内である必要があり、各 nonce は1回だけ使えます。
SmsGrab-KeySmsGrab-TimestampSmsGrab-NonceSmsGrab-Signature次の7つの要素を改行でつなぎます:固定の接頭辞 SGSUPPLY1、HTTPメソッド、送信したとおりのパス、生のクエリ文字列(なければ空)、タイムスタンプ、nonce、ボディのSHA-256(小文字の16進数、ボディがなければ空文字列のもの)。これをシークレットで署名します。
SGSUPPLY1
POST
/api/supply/v1/messages
1790503200
3q9ZkQe7Tn2vYp8LwXc1Ab
a507e2e670909f12a167f25eb94140a4b5f799b75cc1d9a6c736eead88501bbe
secret sgss_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8
body {"messages":[{"id":"gw-7781","port":"1","from":"WhatsApp","text":"Your WhatsApp code: 123-456","received_at":"2026-11-28T10:00:00Z"}]}
signature v1=db3e086faba31b85c508811b82a90d73c19719d650e03602fdd2d5a02b381618
Python
import hashlib, hmac, json, os, secrets, time, urllib.parse
import requests
KEY_ID = os.environ["SMSGRAB_SUPPLY_KEY"]
SECRET = os.environ["SMSGRAB_SUPPLY_SECRET"].encode()
def signed(method, url, payload=None):
body = b"" if payload is None else json.dumps(payload, separators=(",", ":")).encode()
parts = urllib.parse.urlsplit(url)
timestamp = str(int(time.time()))
nonce = secrets.token_urlsafe(24)
canonical = "\n".join(["SGSUPPLY1", method, parts.path, parts.query,
timestamp, nonce, hashlib.sha256(body).hexdigest()])
headers = {
"SmsGrab-Key": KEY_ID,
"SmsGrab-Timestamp": timestamp,
"SmsGrab-Nonce": nonce,
"SmsGrab-Signature": "v1=" + hmac.new(SECRET, canonical.encode(), hashlib.sha256).hexdigest(),
}
if body:
headers["Content-Type"] = "application/json"
return requests.request(method, url, data=body or None, headers=headers, timeout=30)
signed("POST", "https://smsgrab.com/api/supply/v1/messages", {"messages": [{
"id": "gw-7781", "port": "1", "from": "WhatsApp",
"text": "Your WhatsApp code: 482-913", "received_at": "2026-11-28T10:00:00Z",
}]})
Node.js
import { createHash, createHmac, randomBytes } from 'node:crypto';
const keyId = process.env.SMSGRAB_SUPPLY_KEY;
const secret = process.env.SMSGRAB_SUPPLY_SECRET;
export async function signed(method, url, payload) {
const body = payload === undefined ? '' : JSON.stringify(payload);
const { pathname, search } = new URL(url);
const timestamp = String(Math.floor(Date.now() / 1000));
const nonce = randomBytes(18).toString('base64url');
const canonical = ['SGSUPPLY1', method, pathname, search.replace(/^\?/, ''), timestamp, nonce,
createHash('sha256').update(body).digest('hex')].join('\n');
return fetch(url, {
method,
body: body === '' ? undefined : body,
headers: {
'SmsGrab-Key': keyId,
'SmsGrab-Timestamp': timestamp,
'SmsGrab-Nonce': nonce,
'SmsGrab-Signature': `v1=${createHmac('sha256', secret).update(canonical).digest('hex')}`,
...(body === '' ? {} : { 'Content-Type': 'application/json' }),
},
});
}
await signed('POST', 'https://smsgrab.com/api/supply/v1/heartbeat', {
agent: 'my-gateway/1.0',
interval_seconds: 30,
ports: [{ port: '1', state: 'ready', signal_dbm: -71, operator: 'Turkcell' }],
});
PHP
function smsgrab_signed(string $method, string $url, ?array $payload = null): array
{
$body = $payload === null ? '' : json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
$parts = parse_url($url);
$timestamp = (string) time();
$nonce = rtrim(strtr(base64_encode(random_bytes(18)), '+/', '-_'), '=');
$canonical = implode("\n", ['SGSUPPLY1', $method, $parts['path'], $parts['query'] ?? '',
$timestamp, $nonce, hash('sha256', $body)]);
$headers = [
'SmsGrab-Key: '.getenv('SMSGRAB_SUPPLY_KEY'),
'SmsGrab-Timestamp: '.$timestamp,
'SmsGrab-Nonce: '.$nonce,
'SmsGrab-Signature: v1='.hash_hmac('sha256', $canonical, getenv('SMSGRAB_SUPPLY_SECRET')),
];
$curl = curl_init($url);
curl_setopt_array($curl, [CURLOPT_CUSTOMREQUEST => $method, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30]);
if ($body !== '') {
$headers[] = 'Content-Type: application/json';
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = (string) curl_exec($curl);
return ['status' => curl_getinfo($curl, CURLINFO_RESPONSE_CODE), 'body' => json_decode($response, true)];
}
smsgrab_signed('PUT', 'https://smsgrab.com/api/supply/v1/lines', ['lines' => [
['port' => '1', 'phone_e164' => '+905321112233', 'country_iso' => 'TR', 'operator' => 'Turkcell'],
]]);
curl
URL="https://smsgrab.com/api/supply/v1/messages"
BODY='{"messages":[{"id":"gw-7781","port":"1","from":"WhatsApp","text":"Your WhatsApp code: 123-456","received_at":"2026-11-28T10:00:00Z"}]}'
TS=$(date +%s)
NONCE=$(openssl rand -base64 18 | tr '+/' '-_' | tr -d '=')
REQUEST_PATH=$(printf '%s' "$URL" | sed -E 's#^https?://[^/]+##; s#\?.*$##')
BODY_HASH=$(printf '%s' "$BODY" | openssl dgst -sha256 -hex | sed 's/^.* //')
SIGNATURE=$(printf 'SGSUPPLY1\nPOST\n%s\n\n%s\n%s\n%s' "$REQUEST_PATH" "$TS" "$NONCE" "$BODY_HASH" \
| openssl dgst -sha256 -hmac "$SMSGRAB_SUPPLY_SECRET" -hex | sed 's/^.* //')
curl -s -X POST "$URL" \
-H "SmsGrab-Key: $SMSGRAB_SUPPLY_KEY" \
-H "SmsGrab-Timestamp: $TS" \
-H "SmsGrab-Nonce: $NONCE" \
-H "SmsGrab-Signature: v1=$SIGNATURE" \
-H "Content-Type: application/json" \
-d "$BODY"
認証の問題はすべて 401 と理由 SUPPLY_SIGNATURE_INVALID を返し、nonce の再利用は SUPPLY_NONCE_REUSED を返します。ボディは最大256 KiBのJSONです。各キーは1分あたり600リクエストまで送信できます。
| エンドポイント | 内容 |
|---|---|
GET/me |
ゲートウェイ、確認モード、1日の上限に対する本日の販売数 |
POST/heartbeat |
各ポートの状態を報告してゲートウェイをオンラインに保ち、次の間隔を返します |
PUT/lines |
最大512ポートを番号と通信事業者とともに登録または更新します |
DELETE/lines/{port} |
SIMがなくなったポートを削除します |
POST/lines/{port}/pause |
ポートを一時停止します。登録は残りますが、新しい販売は受けません |
POST/lines/{port}/resume |
一時停止中のポートで再び販売を受けられるようにします |
POST/messages |
最大100件の受信SMSを送信します。各メッセージIDは1回だけ受け付けます |
GET/assignments?wait=25&after={cursor} |
新規および終了した割り当てを long-poll で取得し、最大25秒保持します |
POST/assignments/{id}/ack |
ポートが割り当て可能な状態であることを確認します |
POST/webhook/test |
webhook にテストイベントを送信し、結果を報告します |
お客様があなたのポートで番号を購入すると、割り当てが作成されます。ゲートウェイ設定で確認方法を選んでください。
Webhook
assignment.opened をあなたのURLへPOSTします。3秒以内に {"ack":true} 付きの 2xx で応答してください。
Long-poll
ゲートウェイが GET /assignments を開いたままにし、受け取った割り当てをそれぞれ確認します。
Heartbeat
準備完了のポートを含む最新の heartbeat があれば十分です。シンプルな構成に最適です。
各 webhook には SmsGrab-Signature: t=<unix time>,v1=<hex> が付きます。webhook シークレットで "<t>.<raw body>" のHMAC-SHA256を計算し、定数時間で比較し、古いタイムスタンプは拒否してください。終了イベントは1分、5分、15分後と1時間後に再送されます。
{
"id": "evt_6f1c2a5e-9b0d-4a77-8a51-2d3e4f5a6b7c",
"type": "assignment.opened",
"created_at": "2026-11-28T10:00:00.000Z",
"data": {
"assignment": {
"id": "0b8e7c1a-4d2f-4e6a-9c3b-5a1d2e3f4a5b",
"port": "1",
"phone_e164": "+905321112233",
"service": { "id": "whatsapp", "name": "WhatsApp" },
"since": "2026-11-28T10:00:00.000Z",
"until": "2026-11-28T10:20:00.000Z"
}
}
}
PHP
$body = (string) file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_SMSGRAB_SIGNATURE'] ?? ''), $signature);
$timestamp = (string) ($signature['t'] ?? '');
$expected = hash_hmac('sha256', $timestamp.'.'.$body, getenv('SMSGRAB_SUPPLY_WEBHOOK_SECRET'));
if (! ctype_digit($timestamp) || abs(time() - (int) $timestamp) > 300
|| ! hash_equals($expected, (string) ($signature['v1'] ?? ''))) {
http_response_code(401);
exit;
}
$event = json_decode($body, true, 32, JSON_THROW_ON_ERROR);
if ($event['type'] === 'assignment.opened') {
remember_assignment($event['data']['assignment']);
}
header('Content-Type: application/json');
echo json_encode(['ack' => true]);
Python
import hashlib, hmac, os, time
from flask import Flask, abort, jsonify, request
app = Flask(__name__)
SECRET = os.environ["SMSGRAB_SUPPLY_WEBHOOK_SECRET"].encode()
@app.post("/smsgrab")
def smsgrab():
header = request.headers.get("SmsGrab-Signature", "")
signature = dict(item.split("=", 1) for item in header.split(",") if "=" in item)
timestamp = signature.get("t", "")
expected = hmac.new(SECRET, timestamp.encode() + b"." + request.get_data(), hashlib.sha256).hexdigest()
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300 \
or not hmac.compare_digest(expected, signature.get("v1", "")):
abort(401)
event = request.get_json()
if event["type"] == "assignment.opened":
remember_assignment(event["data"]["assignment"])
return jsonify(ack=True)
Node.js
import express from 'express';
import { createHmac, timingSafeEqual } from 'node:crypto';
const app = express();
const secret = process.env.SMSGRAB_SUPPLY_WEBHOOK_SECRET;
app.post('/smsgrab', express.raw({ type: 'application/json' }), (req, res) => {
const signature = Object.fromEntries((req.get('SmsGrab-Signature') ?? '').split(',').map((item) => item.split('=', 2)));
const timestamp = Number(signature.t);
const expected = Buffer.from(createHmac('sha256', secret).update(`${signature.t}.${req.body}`).digest('hex'));
const received = Buffer.from(signature.v1 ?? '');
if (!Number.isInteger(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > 300
|| received.length !== expected.length || !timingSafeEqual(received, expected)) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body);
if (event.type === 'assignment.opened') {
rememberAssignment(event.data.assignment);
}
return res.json({ ack: true });
});
登録した回線は、SMSを受信できることが確認されてから販売されます。ダッシュボードで確認コードを発行し、15分以内にそのコードを含む任意のSMSを回線へ送ってください。メッセージは確認にのみ使われ、保存されることはありません。
GoIP ゲートウェイは追加のソフトウェアなしでSMSをURLへ転送できます。
inbound URL の例
https://smsgrab.com/api/supply/v1/inbound/goip/YOUR-PRIVATE-TOKEN
あなたのSIMが入った任意の Android スマートフォン
任意のSMS転送アプリ、Tasker、MacroDroid、iOS ショートカット
SIMやeSIMコードを送れば、当社が運用します