SMS भेजें

आपके हर टेक्स्ट के लिए एक API।

इसमें सेट अप करें:
Cursor

एक ही SMS API के जरिए एक मैसेज भेजें या सौ। SDK भेजने से पहले सेगमेंट गिनता है, आपके लिए GSM-7 या Unicode चुनता है, और हर सेंड idempotent होता है, हर डिलीवरी स्टेट पर एक webhook के साथ।

send-notification.ts
202 · 0.4s
import { BirdClient } from "@messagebird/sdk";

const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });

const { data, error } = await bird.sms.send({
  from:     "Bird",
  to:       "+31612345678",
  text:     "Your order #4821 has shipped. Track it: bird.ly/t/4821x",
  category: "transactional",
}).safe();

if (error) throw error;
console.log(data.id);
// → "sms_01m11jw130e7svjzv70kgqr38w"
Hi Ada, reminder of your appointment tomorrow at 14:30 with Dr. Kowalski.
Your order #4821 has shipped. Track it: bird.ly/t/4821x
Your subscription renews on 3 Sep for €12/mo. Manage it here: bird.ly/account

पांच मिनट में अपना पहला SMS भेजें।

उसी भाषा से जो आप पहले से इस्तेमाल करते हैं।

भेजना Bird SMS API का मूल है। पहला सेंड एक स्वीकृत टेस्ट रिसीपिएंट (+15005550006) पर जाता है, ताकि आप नंबर प्रोविज़न करने से पहले एक CI जांच शिप कर सकें और webhooks वायर कर सकें।

1
2
3
4
5
6
7
const msg = await bird.sms.send({
  from: "+15557654321",
  to: "+14155550100",
  text: "Your verification code is 123456.",
  category: "authentication",
});
console.log(msg.id, msg.status);

पांच चीज़ें जो आप खुद नहीं बनाते।

हर Bird चैनल पर वही कॉन्ट्रैक्ट।

  1. 01

    भेजने से पहले सेगमेंट गिनना।

    SDK एन्कोड की गई लंबाई मापता है और बताता है कि एक मैसेज कितने सेगमेंट में पड़ता है, ताकि कोई भटका हुआ वर्ण चुपचाप एक टेक्स्ट को तीन में न बांट दे।

  2. 02

    GSM-7 और Unicode, आपके लिए तय किया गया।

    सादा टेक्स्ट GSM-7 पर चलता है; एक emoji या गैर-Latin स्क्रिप्ट पूरे मैसेज को UCS-2 में बदल देती है। Bird एन्कोडिंग चुनता है और तब चेतावनी देता है जब एक अकेला वर्ण लागत बदल देता है।

  3. 03

    एक कॉल में बैच करें।

    एक रिक्वेस्ट में कई स्वतंत्र मैसेज भेजें, हर एक का अपना रिसीपिएंट और टेक्स्ट, जो एक इकाई के रूप में वैलिडेट होते हैं ताकि आप कभी आधा-अधूरा न भेजें।

  4. 04

    कॉन्ट्रैक्ट के हिसाब से idempotent।

    हर सेंड एक idempotency key स्वीकार करता है, ताकि टाइमआउट के बाद रिट्राई की गई रिक्वेस्ट किसी को दो बार टेक्स्ट करने के बजाय मूल परिणाम लौटा दे।

  5. 05

    हर स्टेट बदलाव पर एक webhook।

    Queued, sent, delivered, failed. हर एक HMAC-signed, replay-protected, idempotent, हर चैनल पर वही envelope।

पहले से कहीं और भेज रहे हैं? क्लाइंट बदलें, कॉल वही रखें।

आकार में मुश्किल से बदलाव आता है: क्लाइंट स्वैप करें, अपना from, to, और text रखें, अपने webhooks को एक endpoint पर पॉइंट करें। आपके email, voice, और WhatsApp सेंड जैसा ही auth मॉडल।

twilio.ts
Twilio
import twilio from "twilio";

const client = twilio(accountSid, authToken);

await client.messages.create({
  from: "+14155550172",
  to:   "+15005550006",
  body: "Your code is 123456.",
});
bird.ts
Bird
import { BirdClient } from "@messagebird/sdk";

const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });

await bird.sms.send({
  from:     "+14155550172",
  to:       "+15005550006",
  text:     "Your code is 123456.",
  category: "authentication",
});

कैरियर से पहले लागत जान लें।

A GSM-7 message fits 160 characters per segment; a single emoji or non-Latin character flips the whole message to UCS-2 and drops that to 70. Bird counts the segments when it accepts the send and returns the breakdown in the response, so the number you are billed on is in hand before the carrier ever sees the message, and a concatenated message is always a deliberate choice.

segments.ts
200 · 1 segment
const { data, error } = await bird.sms.send({
  from:     "Bird",
  to:       "+31612345678",
  text:     "Your code is 123456.",
  category: "authentication",
}).safe();
if (error) throw error;

console.log(data.segments);
// → { characters: 20, count: 1, encoding: "GSM_7BIT" }

एक मैसेज या सौ, एक कॉल।

एक रिक्वेस्ट में स्वतंत्र मैसेज बैच करें, हर एक का अपना रिसीपिएंट और टेक्स्ट। बैच एक इकाई के रूप में वैलिडेट होता है: एक गलत नंबर 422 के साथ कॉल को रिजेक्ट कर देता है, ताकि आप कभी आधा-अधूरा न भेजें। एक अकेली idempotency key पूरी रिक्वेस्ट को रिट्राई के लिए सुरक्षित बना देती है।

reminders.ts
202 · batch
const { data: batch, error } = await bird.sms
  .sendBatch(
    users.map((u) => ({
      from: "Bird",
      to:   u.phone,
      text: `Hi ${u.name}, your appointment is tomorrow at ${u.time}.`,
    })),
    { idempotencyKey: `reminders-${runId}` },
  )
  .safe();

if (error) throw error;
console.log(`queued ${batch.data.length} messages`);

हर मैसेज को उसके पूरे जीवन में देखें।

एक सेंड तुरंत 202 लौटाता है; परिणाम एक webhook के रूप में आता है। एक signature वेरिफाई करें, type पर स्विच करें: वही envelope जो आप email, voice, और WhatsApp के लिए पहले से संभालते हैं।

app/api/webhooks/bird/route.ts
signed
import { bird } from "@/lib/bird";

export async function POST(req: Request) {
  const event = bird.webhooks.unwrap(
    await req.text(),
    Object.fromEntries(req.headers),
  );

  switch (event.type) {
    case "sms.delivered":
      await markDelivered(event.data.sms_id);
      break;
    case "sms.failed":
      await flag(event.data.to, event.data.error?.description);
      break;
  }

  return new Response(null, { status: 204 });
}

विफल सेंड और STOP रिप्लाई आपकी suppression लिस्ट को अपने आप अपडेट कर देते हैं, ताकि एक गलत नंबर आपको दो बार महंगा न पड़े।

  • sms.acceptedAPI द्वारा स्वीकृत और कैरियर हैंड-ऑफ के लिए queued।
  • sms.sentगंतव्य कैरियर के SMSC को सबमिट किया गया।
  • sms.deliveredकैरियर से डिलीवरी रसीद प्राप्त (DLR)।
  • sms.failedPermanent failure: carrier rejection, invalid number, or suppression hit.

डॉक्यूमेंटेशन में और गहराई से जाएं।

webhooks वायर करें, idempotency keys से हर सेंड को रिट्राई के लिए सुरक्षित बनाएं, और error reference पढ़ें ताकि आप हर विफलता को सही तरीके से संभालें।

दुनिया का लगभग 40% कमर्शियल SMS पहले से ही Bird पर चलता है।

भेजना Bird SMS API की एक क्षमता है: नंबर, दो-तरफा इनबाउंड, कंप्लायंस, रूटिंग, और एनालिटिक्स इसके साथ आते हैं, उस इंफ्रास्ट्रक्चर पर जिसे हमने एक दशक से चलाया है।

एक चैनल से शुरुआत करें।
तैयार होने पर बाकी जोड़ें।

एक test API key तुरंत आपकी है। जब आप payment method जोड़ते हैं और sender verify करते हैं, तब production अनलॉक हो जाता है।

Claude Code, Cursor या Codex इस्तेमाल कर रहे हैं? एक setup prompt कॉपी करें और आपका agent आपके लिए Bird CLI और skills इंस्टॉल कर देगा। अपना चुनें:

Cursor