言語を選択

開発者API

SMS認証を あなたのコードから直接

1回のHTTPS呼び出しで、ボットやプラットフォームがWhatsApp、Telegramなど多数のサービス用の実在する番号を取得できます。コードはWebhookまたはロングポーリングで受け取り、コードを受信した番号だけにお支払いいただきます。

  • 2,281サービス
  • 200か国
  • 自動コードが届かなければ返金

curl

curl -s -X POST https://smsgrab.com/api/dev/v1/activations \
  -H "Authorization: Bearer $SMSGRAB_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"service":"whatsapp","country":"indonesia"}'

Python

activation = requests.post(
    "https://smsgrab.com/api/dev/v1/activations",
    headers={"Authorization": f"Bearer {key}", "Idempotency-Key": str(uuid.uuid4())},
    json={"service": "whatsapp", "country": "indonesia"},
    timeout=30,
).json()

Node.js

const activation = await fetch('https://smsgrab.com/api/dev/v1/activations', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${key}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({ service: 'whatsapp', country: 'indonesia' }),
}).then((response) => response.json());

PHP

$activation = json_decode((string) $client->post('activations', [
    'json' => ['service' => 'whatsapp', 'country' => 'indonesia'],
    'headers' => ['Idempotency-Key' => bin2hex(random_bytes(16))],
])->getBody(), true);

Go

order := map[string]any{"service": "whatsapp", "country": "indonesia"}
err := call("POST", "/activations", order, idempotencyKey(), &activation)
201 Created
{
  "id": "5c1d0c2e-9f3a-4b7e-8a61-2f0c9d4e7b10",
  "compat_id": 100000123,
  "status": "WAITING_SMS",
  "service_id": "whatsapp",
  "country_id": "indonesia",
  "phone_number": "+6281234567890",
  "price_minor": 17,
  "currency": "USD",
  "expires_at": "2026-09-27T10:25:00.000Z",
  "sms": []
}

自動化のために設計

アプリと同じ番号在庫、会計、返金で、連携に必要なものがすべて揃っています。

  • シンプルなREST API

    予測しやすいJSON、冪等な購入、対処しやすい明確なエラー理由。

  • 署名付きWebhook

    コードの受信やステータス変化ごとにHMAC署名付きイベントを送信し、24時間まで再試行します。

  • ロングポーリング

    リクエストを最大25秒保持し、コードが届いた瞬間に受け取れます。

  • sms-activate互換

    既存ツールの接続先を当社のエンドポイントに変えるだけ。アクションとレスポンスはそのままです。

  • 細かく制御できるキー

    読み取り専用か購入可能か、IP許可リスト、1日の上限、有効期限、無停止のローテーション。

  • 自動返金

    番号の期限までにコードが届かなければ、すぐに残高へ返金されます。

  • 利用状況とリクエストログ

    キーごとの日別リクエスト、利用額、エラーに加え、過去7日間の絞り込み可能なログ。

  • ボリューム価格

    アプリと同じ価格に、月間の利用量に応じて自動で広がる割引。

4ステップで開始

最初の番号まで、数回の呼び出しだけです。

  1. アカウントを作成

    メールアドレスで登録して確認します。アプリとウェブサイトは同じアカウントを使います。

  2. APIキーを作成

    権限を選び、キーをサーバーに制限し、シークレットを一度だけコピーします。

  3. 番号を購入

    サービスと国をPOSTすると、番号と価格がすぐに返ります。

  4. コードを受信

    ロングポーリングかWebhookで待ち、アクティベーションを完了します。

成長するほど下がる価格

APIの価格はアプリと同じです。大口割引は、すべてのチャネルでの過去30日間の利用額に応じて広がります。

  • アプリの同じ番号より高くなることはありません
  • コードが届かない番号は自動で返金
  • 段階は到達から数分で更新
  • アプリと同じ残高からUSDで請求

30日間の利用額別の割引

ボリューム段階は現在停止中です。価格はアプリと同じで、承認された再販業者には固定の割引が適用されます。

移行

sms-activateから1行の変更で移行

互換エンドポイントは同じプロトコルに対応しているため、sms-activate向けのボットや管理画面はベースURLとキーを変えるだけで動作します。

SMS-Activateは2025年12月に終了しました。ツールの接続先をSmsGrabに変えれば、そのまま使い続けられます。

https://smsgrab.com/api/stubs/handler_api.php
  • getNumber、getStatus、setStatus、getPricesなどの標準アクション
  • すでに使っている数値のアクティベーションID、サービスコード、国ID
  • REST APIと同じキー、制限、価格、返金、Webhook
互換性リファレンス

curl

BASE="https://smsgrab.com/api/stubs/handler_api.php?api_key=$SMSGRAB_API_KEY"

curl -s -w '\n' "$BASE&action=getBalance"
curl -s -w '\n' "$BASE&action=getNumber&service=tg&country=6&maxPrice=0.30"
curl -s -w '\n' "$BASE&action=getStatus&id=100000123"
curl -s -w '\n' "$BASE&action=setStatus&id=100000123&status=6"

Python

import os
import time

import requests

BASE = "https://smsgrab.com/api/stubs/handler_api.php"
KEY = os.environ["SMSGRAB_API_KEY"]


def action(name: str, **params) -> str:
    response = requests.get(BASE, params={"api_key": KEY, "action": name, **params}, timeout=30)
    response.raise_for_status()
    return response.text


print(action("getBalance"))
answer = action("getNumber", service="tg", country=6, maxPrice="0.30")
if not answer.startswith("ACCESS_NUMBER:"):
    raise SystemExit(answer)
_, activation_id, number = answer.split(":")
print("Number:", number)

while True:
    status = action("getStatus", id=activation_id)
    if status.startswith("STATUS_OK:"):
        print("Code:", status.split(":", 1)[1])
        action("setStatus", id=activation_id, status=6)
        break
    if status == "STATUS_CANCEL":
        print("Cancelled or expired, the charge was refunded")
        break
    time.sleep(5)

Node.js

const BASE = 'https://smsgrab.com/api/stubs/handler_api.php';

async function action(name, params = {}) {
  const url = new URL(BASE);
  url.search = new URLSearchParams({ api_key: process.env.SMSGRAB_API_KEY, action: name, ...params }).toString();
  const response = await fetch(url, { signal: AbortSignal.timeout(30_000) });
  if (!response.ok) {
    throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  }
  return response.text();
}

console.log(await action('getBalance'));
const answer = await action('getNumber', { service: 'tg', country: '6', maxPrice: '0.30' });
if (!answer.startsWith('ACCESS_NUMBER:')) {
  throw new Error(answer);
}
const [, id, number] = answer.split(':');
console.log('Number:', number);

for (;;) {
  const status = await action('getStatus', { id });
  if (status.startsWith('STATUS_OK:')) {
    console.log('Code:', status.slice('STATUS_OK:'.length));
    await action('setStatus', { id, status: '6' });
    break;
  }
  if (status === 'STATUS_CANCEL') {
    console.log('Cancelled or expired, the charge was refunded');
    break;
  }
  await new Promise((resolve) => setTimeout(resolve, 5000));
}

PHP

<?php

function smsgrab(string $action, array $params = []): string
{
    $query = http_build_query(['api_key' => getenv('SMSGRAB_API_KEY'), 'action' => $action] + $params);
    $answer = file_get_contents('https://smsgrab.com/api/stubs/handler_api.php?'.$query, false, stream_context_create(['http' => ['timeout' => 30]]));
    if ($answer === false) {
        throw new RuntimeException('The request failed');
    }

    return $answer;
}

echo smsgrab('getBalance').PHP_EOL;
$answer = smsgrab('getNumber', ['service' => 'tg', 'country' => 6, 'maxPrice' => '0.30']);
if (! str_starts_with($answer, 'ACCESS_NUMBER:')) {
    exit($answer.PHP_EOL);
}
[, $id, $number] = explode(':', $answer);
echo 'Number: '.$number.PHP_EOL;

while (true) {
    $status = smsgrab('getStatus', ['id' => $id]);
    if (str_starts_with($status, 'STATUS_OK:')) {
        echo 'Code: '.substr($status, strlen('STATUS_OK:')).PHP_EOL;
        smsgrab('setStatus', ['id' => $id, 'status' => 6]);
        break;
    }
    if ($status === 'STATUS_CANCEL') {
        echo 'Cancelled or expired, the charge was refunded'.PHP_EOL;
        break;
    }
    sleep(5);
}

Go

package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"strings"
	"time"
)

const base = "https://smsgrab.com/api/stubs/handler_api.php"

var client = &http.Client{Timeout: 30 * time.Second}

func action(name string, params url.Values) (string, error) {
	query := url.Values{"api_key": {os.Getenv("SMSGRAB_API_KEY")}, "action": {name}}
	for key, values := range params {
		query[key] = values
	}
	response, err := client.Get(base + "?" + query.Encode())
	if err != nil {
		return "", err
	}
	defer response.Body.Close()
	body, err := io.ReadAll(io.LimitReader(response.Body, 1<<20))
	if err != nil {
		return "", err
	}
	if response.StatusCode != http.StatusOK {
		return "", fmt.Errorf("http %d: %s", response.StatusCode, body)
	}
	return string(body), nil
}

func main() {
	answer, err := action("getNumber", url.Values{"service": {"tg"}, "country": {"6"}, "maxPrice": {"0.30"}})
	if err != nil {
		panic(err)
	}
	if !strings.HasPrefix(answer, "ACCESS_NUMBER:") {
		fmt.Println(answer)
		return
	}
	parts := strings.Split(answer, ":")
	id := parts[1]
	fmt.Println("Number:", parts[2])
	for {
		status, err := action("getStatus", url.Values{"id": {id}})
		if err != nil {
			panic(err)
		}
		if code, ok := strings.CutPrefix(status, "STATUS_OK:"); ok {
			fmt.Println("Code:", code)
			if _, err := action("setStatus", url.Values{"id": {id}, "status": {"6"}}); err != nil {
				panic(err)
			}
			return
		}
		if status == "STATUS_CANCEL" {
			fmt.Println("Cancelled or expired, the charge was refunded")
			return
		}
		time.Sleep(5 * time.Second)
	}
}

リアルタイム

コードをサーバーへ直接

必要なイベントを購読すると、検証可能な署名付きでHTTPSエンドポイントへ配信します。

  • 番号を購入
  • コードを受信
  • アクティベーション完了
  • アクティベーションをキャンセル
  • アクティベーション期限切れ
  • 返金済み
  • 残高不足
  • チャージ作成
  • チャージ確認中
  • チャージ反映
  • チャージ期限切れ
  • チャージ審査中
Webhookガイド
600キーあたり毎分のリクエスト
60キーあたり毎分の購入
100同時に待機できる番号
25秒のロングポーリング
  • すべての配信にタイムスタンプ付きのHMAC-SHA256署名
  • 公開HTTPSエンドポイントのみ、配信ごとに事前チェック
  • テスト配信、30日間の履歴、ワンクリック再配信

開発者からの質問

開発者APIの料金は?

サブスクリプションはありません。各番号の価格はアプリと同じで、同じ残高から支払われます。30日間の利用額が増えるとボリューム段階で価格が下がり、承認された再販業者には固定の割引が適用されます。コードが届かなかった番号は自動で返金されます。

コードが届かなかったら?

番号は一緒に表示される有効期限まで有効で、通常は10〜20分です。その間にコードが届かなかった場合や、待機中に番号をキャンセルした場合は、自動的に残高へ返金されます。

sms-activate向けの連携をそのまま使えますか?

はい。ベースURLを当社の互換エンドポイントに変更し、SmsGrabのキーを使ってください。標準アクション、レスポンス、数値IDはそのままです。

レート制限は?

標準では、キーごとに毎分600リクエストと60件の購入、アカウントの全キー合計で毎分3000リクエスト、同時にコードを待機できる番号は最大100件です。

キーを安全に保つには?

キーはサーバーにのみ保管し、アプリごとに専用のキーを使い、サーバーのアドレスに制限して1日の利用上限を設定してください。漏洩の可能性があれば、アカウントからローテーションまたは無効化してください。

アプリとAPIの残高は共通ですか?

はい。APIはSmsGrabアカウントの残高を使用し、すべての購入と返金はほかの取引と同じくウォレットに表示されます。

ほかの回答は ヘルプセンター

認証を自動化しませんか?

アカウントでキーを作成すれば、数分で最初の呼び出しができます。