Scegli una lingua

API per sviluppatori

Verifica via SMS direttamente dal tuo codice

Una sola chiamata HTTPS dà al tuo bot o alla tua piattaforma un numero reale per WhatsApp, Telegram e molti altri servizi. Leggi il codice via webhook o long polling e paga solo i numeri che lo ricevono.

  • 2.259servizi
  • 200paesi
  • Autorimborso se il codice non arriva

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": []
}

Pensata per l’automazione

Tutto ciò che serve alla tua integrazione, con lo stesso stock, la stessa contabilità e gli stessi rimborsi dell’app.

  • Un’API REST pulita

    JSON prevedibile, acquisti idempotenti e motivi di errore chiari su cui agire.

  • Webhook firmati

    Eventi firmati HMAC per ogni codice e cambio di stato, con nuovi tentativi per 24 ore.

  • Long polling

    Mantieni una richiesta fino a 25 secondi e ricevi il codice appena arriva.

  • Compatibile con sms-activate

    Punta i tuoi strumenti a un nuovo indirizzo. Azioni e risposte restano le stesse.

  • Chiavi sotto il tuo controllo

    Chiavi in sola lettura o di acquisto, liste di IP consentiti, limiti giornalieri, scadenza e rotazione senza interruzioni.

  • Rimborsi automatici

    Nessun codice prima della scadenza del numero? L’addebito torna direttamente sul tuo saldo.

  • Utilizzo e registro delle richieste

    Richieste, spese ed errori giornalieri per chiave, più un registro filtrabile degli ultimi 7 giorni.

  • Prezzi per volume

    Gli stessi prezzi dell’app, con sconti che crescono automaticamente con il tuo volume mensile.

Operativo in quattro passaggi

Il tuo primo numero è a poche chiamate di distanza.

  1. Crea un account

    Registrati con il tuo indirizzo email e verificalo. App e sito condividono lo stesso account.

  2. Crea una chiave API

    Scegli il suo accesso, limitala ai tuoi server e copia il segreto una volta.

  3. Acquista un numero

    Invia servizio e paese con POST. Ricevi subito il numero e il suo prezzo.

  4. Ricevi il codice

    Attendi con long polling o un webhook, poi completa l’attivazione.

Prezzi che scendono mentre cresci

L’API applica gli stessi prezzi dell’app. Il tuo sconto a volume cresce con la spesa degli ultimi 30 giorni su tutti i canali.

  • Mai più del prezzo dello stesso numero nell’app
  • I numeri senza codice vengono rimborsati automaticamente
  • La tua fascia si aggiorna pochi minuti dopo averla raggiunta
  • Addebitato in USD dallo stesso saldo dell’app

Sconto in base alla spesa in 30 giorni

Le fasce di volume non sono attive al momento. Paghi gli stessi prezzi dell’app, e i rivenditori approvati ricevono il loro sconto fisso.

Migrazione

Passa da sms-activate con una riga

Il nostro endpoint compatibile parla lo stesso protocollo: bot e pannelli creati per sms-activate funzionano appena cambi l’indirizzo base e la chiave.

SMS-Activate ha chiuso a dicembre 2025. Punta i tuoi strumenti su SmsGrab e continueranno a funzionare.

https://smsgrab.com/api/stubs/handler_api.php
  • getNumber, getStatus, setStatus, getPrices e tutte le altre azioni standard
  • Gli ID numerici delle attivazioni, i codici servizio e gli ID paese che già usi
  • Le stesse chiavi, limiti, prezzi, rimborsi e webhook dell’API REST
Riferimento di compatibilità

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)
	}
}

Tempo reale

Codici inviati al tuo server

Iscriviti agli eventi che ti interessano e li consegniamo al tuo endpoint HTTPS con una firma verificabile.

  • Numero acquistato
  • Codice ricevuto
  • Attivazione completata
  • Attivazione annullata
  • Attivazione scaduta
  • Addebito rimborsato
  • Saldo in esaurimento
  • Ricarica creata
  • Ricarica in conferma
  • Ricarica accreditata
  • Ricarica scaduta
  • Ricarica in verifica
Guida ai webhook
600richieste al minuto per chiave
60acquisti al minuto per chiave
100numeri in attesa contemporaneamente
25secondi di long polling
  • Ogni consegna è firmata con HMAC-SHA256 e un timestamp
  • Solo endpoint HTTPS pubblici, verificati prima di ogni consegna
  • Consegne di test, cronologia di 30 giorni e riconsegna con un clic

Domande degli sviluppatori

Quanto costa l’API per sviluppatori?

Non c’è abbonamento. Ogni numero costa come nell’app e si paga con lo stesso saldo. Le fasce di volume abbassano questo prezzo man mano che cresce la tua spesa a 30 giorni, e i rivenditori approvati ricevono uno sconto fisso. I numeri senza codice vengono rimborsati automaticamente.

Cosa succede se il codice non arriva?

Un numero resta attivo fino all’ora di scadenza indicata, di solito da 10 a 20 minuti. Se in quel tempo non arriva alcun codice, o lo annulli mentre è ancora in attesa, l’addebito viene rimborsato automaticamente sul tuo saldo.

Posso usare la mia integrazione sms-activate esistente?

Sì. Sostituisci l’indirizzo base con il nostro endpoint compatibile e usa la tua chiave SmsGrab. Azioni standard, risposte e ID numerici restano gli stessi.

Quali sono i limiti di frequenza?

Per impostazione predefinita ogni chiave può fare 600 richieste e 60 acquisti al minuto, tutte le chiavi di un account insieme 3.000 richieste al minuto, e fino a 100 numeri possono attendere un codice contemporaneamente.

Come tengo al sicuro la mia chiave?

Tieni le chiavi solo sui tuoi server, dai a ogni app la sua chiave, limitala agli indirizzi dei tuoi server e imposta un limite di spesa giornaliero. Se una chiave potrebbe essere trapelata, ruotala o revocala dal tuo account.

L’app e l’API condividono lo stesso saldo?

Sì. L’API usa il saldo del tuo account SmsGrab, e ogni acquisto e rimborso compare nel tuo portafoglio come gli altri.

Trovi altre risposte nel centro assistenza

Pronto ad automatizzare la verifica?

Crea una chiave nel tuo account e fai la tua prima chiamata in pochi minuti.