/ DOCS

API Dokümanları

WhatsApp OTP API — kısa ve uygulamalı.

01 / QUICKSTART

Başlarken

wpotp, WhatsApp üzerinden OTP göndermek için tasarlanmış basit bir REST API'dir. Üç istekte canlı olursun:

bash
# 1) API anahtarını al — Dashboard → API anahtarları
export WPOTP_KEY=wpotp_live_xxxxxxxxxxxxxxxxxxxxxxxx

# 2) Kullanılabilir sistem şablonlarını listele
curl https://api.wpotp.com/v1/templates \
  -H "Authorization: Bearer $WPOTP_KEY"

# 3) İlk OTP'ni gönder — kodu wpotp üretir
curl -X POST https://api.wpotp.com/v1/otp/send \
  -H "Authorization: Bearer $WPOTP_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "recipient": "+905551112233" }'
base url
https://api.wpotp.com
02 / AUTH

Kimlik doğrulama

Tüm istekler Bearer Token ile kimlik doğrulanır. Anahtarını Dashboard → API anahtarlarından alırsın.

http
Authorization: Bearer wpotp_live_xxxxxxxxxxxxxxxxxxxxxxxx

// Tüm istekler HTTPS üzerinden; kimlik Authorization header'ı ile.
// API anahtarları Dashboard → API anahtarları'ndan oluşturulur ve
// yalnızca oluşturulurken bir kez gösterilir.
// Geçersiz veya iptal edilmiş anahtar → 401 unauthorized.
03 / SEND OTP

OTP gönder

Tek POST isteği ve E.164 formatında bir numara yeterli. Şablonlar sistem tarafından yönetilir; templateId opsiyoneldir, verilmezse varsayılan doğrulama şablonu kullanılır.

http
POST /v1/otp/send
{
  "recipient":  "+905551112233",  // E.164, zorunlu
  "templateId": "tpl_xxx",         // opsiyonel; yoksa varsayılan AUTH şablonu
  "code":       "482913",          // opsiyonel; kendi kodun (4-8 hane)
  "reference":  "order-9f3a2c"     // opsiyonel; kendi benzersiz anahtarın
}

// 201 Created
{
  "id":        "otp_a1b2c3",
  "status":    "SENT",
  "recipient": "+905551112233",
  "expiresAt": "2026-05-17T12:05:00.000Z"
}
04 / VERIFY

Kod doğrula

Kullanıcının girdiği kodu bizim tarafa POST'lersen, deneme sayısı, TTL ve başarı durumunu yöneten endpoint biziz.

http
POST /v1/otp/{id}/verify
{ "code": "482913" }

// 200 OK
{ "verified": true, "status": "VERIFIED" }

// 400 Bad Request — yanlış kod
{ "error": { "code": "INVALID_CODE", "message": "Invalid OTP code" } }
05 / WEBHOOKS

Webhooks

Her durum değişikliği için sunucuna anlık POST atarız. İmzayı doğrulamak için x-wpotp-signature header'ını kullan.

http
// OTP durumu her değiştiğinde sunucuna POST atarız.
POST https://app.acme.com/webhooks/wpotp
Content-Type: application/json
X-Wpotp-Event: otp.delivered
X-Wpotp-Signature: sha256=8a2f1e9c...b4f

{
  "id": "evt_7c1a",
  "event": "otp.delivered",
  "createdAt": "2026-05-17T12:00:00.000Z",
  "data": {
    "id": "otp_a1b2c3",
    "recipient": "+905551112233",
    "reference": "order-9f3a2c",
    "status": "DELIVERED",
    "templateId": "tpl_xxx"
  }
}

// Olaylar: otp.sent, otp.delivered, otp.read, otp.verified, otp.failed, otp.expired
// İmza: HMAC-SHA256(secret, ham gövde) — X-Wpotp-Signature ile doğrula.
06 / ERRORS

Hata kodları

codetypedescription
400INVALID_PHONENumara geçerli E.164 formatında değil
401unauthorizedGeçersiz veya iptal edilmiş API anahtarı
404TEMPLATE_NOT_FOUNDBelirtilen şablon ID'si bulunamadı
404OTP_NOT_FOUNDOTP kaydı bulunamadı
400INVALID_CODEDoğrulama kodu hatalı
400OTP_EXPIREDOTP'nin geçerlilik süresi doldu
429RATE_LIMITEDİstek limiti aşıldı — kısa süre bekleyin
502WA_SEND_FAILEDWhatsApp mesajı iletilemedi
07 / REST & ARAÇLAR

Kütüphaneler

wpotp düz bir REST API'dir — herhangi bir dilin HTTP istemcisiyle (fetch, axios, requests, Guzzle, net/http…) doğrudan kullanılır, ayrı bir SDK gerekmez.

başlangıç
  • Base URL: https://api.wpotp.com
  • Tüm uçlar için canlı dokümantasyon: /v1/docs (Swagger)
  • Hazır Postman koleksiyonu sağdaki panelden indirilebilir.