send sms with sparrow api

How to Send Bulk SMS with Sparrow SMS API (PHP, Python, Node.js & More)

Need to programmatically send SMS from your application in Nepal? Whether you’re building OTP verification, transaction alerts, or automated sms marketing campaigns, the Sparrow SMS API provides a simple, reliable way to integrate SMS functionality. This post is a comprehensive, practical guide for integrating our SMS API gateway. We’ll cover everything from getting your credentials to sending your first message, complete with copy-and-paste code examples for the most popular languages. What is the Sparrow SMS API? The Sparrow SMS API is a simple yet powerful HTTP-based interface that allows developers to connect their applications directly to our SMS gateway. Instead of logging into a dashboard to send messages, your software can send them automatically based on triggers you define, like a new user signup or a completed purchase. Our API supports both sending messages (MT/Push) and receiving them (MO/Pull), making it a versatile tool for any communication need. Why Developers in Nepal Choose the Sparrow SMS API As a leading bulk SMS provider, we’ve built our API with developers in mind. Here’s why technical teams across Nepal trust Sparrow SMS. Simplicity and Ease of Integration Our platform is a standard RESTful API using GET/POST requests. There are no complex protocols to learn. If you can make an HTTP request, you can send an sms. It’s that easy. Unmatched Reliability and Direct Connectivity We have direct connections to major Nepali telecom operators like NTC and Ncell. This ensures high deliverability and speed, which is critical for time-sensitive messages like OTPs and critical alerts. This direct connectivity is what makes us a premier sms service provider. Scalable for Any Application Whether you’re sending 10 messages a day or managing a mass messaging campaign of 100,000, our API is built to handle the load. Our infrastructure is designed for high-volume bulk messaging, growing seamlessly with your business needs. Comprehensive and Clear Documentation We provide clear documentation and real-world code examples (like the ones in this post!) to get you up and running in minutes, not hours. Getting Started: Your Pre-flight Checklist Before you write any code, make sure you have the following essentials ready. Core API Endpoints: Sending SMS and Checking Credits Our API is built around a few core endpoints. Here are the two you’ll use most often. Endpoint 1: Sending an SMS (/sms/) This is the primary endpoint for our bulk sms service. It accepts both GET and POST requests, but we strongly recommend using POST for better security and reliability, especially when sending longer messages or to multiple numbers. Mandatory Parameters: Parameter Description Example token Your unique API token from the dashboard. Abc123xyz… from Your approved Sender ID. YourBrand to A 10-digit mobile number, or comma-separated numbers for bulk sms. 98xxxxxxxx,… text The URL-encoded message content you want to send. Your OTP is… Endpoint 2: Checking Your Credit Balance (/credit/) Before sending a large batch of messages, it’s good practice to programmatically check if you have enough credits. This simple GET endpoint lets you do just that. Mandatory Parameters: Parameter Description Example token Your unique API token from the dashboard. Abc123xyz… Integration Examples: Send Your First SMS in 5 Minutes Here are practical, copy-and-paste examples to get you sending messages immediately. PHP Integration (using cURL) PHP is one of the most popular languages for web development in Nepal. Here’s how you can send an SMS using the robust cURL extension. PHP Understanding API Responses and Error Handling A successful API call is only half the story. You need to know how to handle both success and failure in your code. The Success Response (Status Code 200) A 200 OK status means our server has accepted your request and queued the messages for delivery. The response body will contain more details. Common Error Responses (Status Code 403) If something goes wrong with your request parameters, you’ll likely receive a 403 Forbidden status. Here are the most common causes. response_code Message Common Cause & Solution 1002 Invalid Token Your API token is incorrect or has been revoked. Double-check it in your dashboard. 1008 Invalid Sender The from parameter doesn’t match an approved Sender ID on your account. 1011 No valid receiver The to parameter contains invalid or incorrectly formatted phone numbers. Ensure 10 digits. 1013 Insufficient Credits Your account doesn’t have enough credits to send the requested number of SMS. Advanced: Receiving SMS (Mobile Originated) Our API also supports two way messaging. You can receive messages sent to your dedicated shortcode or number, which is perfect for building interactive services like polls, keyword-based subscriptions, or two-way support channels. This works via a webhook: you provide a URL in your dashboard, and when an SMS comes in, our system sends a GET request to your URL with the message details (from, to, text, keyword). Your application can then process this and send back a reply. For a detailed guide on setting up incoming SMS, please refer to our full API documentation. Ready to Build? Start Integrating Today The Sparrow SMS API is simple, reliable, and powerful. It’s the fastest way to add professional SMS capabilities to your application in Nepal. Have a question or need help with a specific integration? Our developer support team is here to help. Sign up for your free Sparrow SMS account today and get your API token to start building. [View Full API Documentation]