Getting started overview

Getting started with MessageBird (Bird) involves a sequence of steps designed to integrate their communication APIs into an application. The process begins with account creation, followed by the generation and secure handling of API keys. These credentials authenticate requests to MessageBird's REST API, enabling programmatic access to services like SMS, Voice, and WhatsApp. The final stage of initial setup typically involves making a first successful API call to confirm the integration is functioning correctly. MessageBird offers various SDKs to simplify interaction with their API, alongside comprehensive documentation for direct HTTP requests.

This guide outlines the essential steps to move from a new account to sending your first MessageBird API request successfully. While MessageBird supports multiple communication channels, this guide focuses on the SMS API for the initial request due to its common use case and straightforward implementation.

Here is a quick reference for the getting started process:

Step What to do Where
1. Create Account Sign up for a MessageBird account. MessageBird homepage
2. Get API Keys Locate and copy your Access Key and Secret Key from the dashboard. MessageBird Developers Dashboard
3. Install SDK (Optional) Install a MessageBird SDK for your preferred language. MessageBird SDKs
4. Write Code Construct an API request using your keys to send an SMS. Your development environment
5. Send Request Execute the code to send your first message. Your development environment

Create an account and get keys

To begin using MessageBird's services, you must first create an account. This process typically involves providing an email address, setting a password, and verifying your email. While MessageBird operates on a pay-as-you-go model, new accounts often receive a small credit for testing purposes, though this is not explicitly listed as a permanent free tier.

  1. Sign Up: Navigate to the MessageBird website and click the "Sign Up" or "Get Started" button. Follow the prompts to create your account, which may include email verification and providing basic contact information.
  2. Access Dashboard: Once your account is created and verified, log in to the MessageBird Dashboard. This is your central hub for managing services, viewing usage, and accessing API credentials.
  3. Locate API Keys: Within the dashboard, navigate to the "Developers" or "API Settings" section. MessageBird uses two primary API keys for authentication: an Access Key and a Secret Key. The Access Key is generally used for identifying your account in requests, while the Secret Key provides authentication and should be kept confidential. You may need to generate a new Secret Key if one is not already visible. It is critical to store your Secret Key securely, as it grants full access to your account's API capabilities. The MessageBird authentication documentation provides further details on managing these keys.
  4. Fund Your Account (if necessary): Depending on the services you intend to use and your testing credit status, you may need to add funds to your account. MessageBird's pricing is channel and destination-specific, so review the rates for your intended use case.

After successfully obtaining your API keys, you are ready to make your first authenticated request.

Your first request

This section demonstrates how to send your first SMS message using the MessageBird API. We will use a cURL example for a direct HTTP request and provide a Node.js SDK example for a more integrated approach. Ensure you have your Access Key and Secret Key ready.

Prerequisites

  • A MessageBird account with API keys.
  • Sufficient credit in your account for sending an SMS.
  • A phone number associated with your MessageBird account to use as the originator (sender ID). This might be a virtual number purchased through MessageBird or an alphanumeric sender ID approved for your region.
  • A recipient phone number for testing.
  • For Node.js: Node.js runtime installed (Node.js official download) and npm.

cURL Example (Direct HTTP POST)

This example sends an SMS message using a direct HTTP POST request. Replace YOUR_ACCESS_KEY, YOUR_SECRET_KEY, YOUR_ORIGINATOR, and RECIPIENT_NUMBER with your actual values.

curl -X POST "https://rest.messagebird.com/messages" \
  -H "Authorization: AccessKey YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "originator": "YOUR_ORIGINATOR",
    "recipients": [
      RECIPIENT_NUMBER
    ],
    "body": "Hello from MessageBird! This is my first API message."
  }'

The originator can be an alphanumeric sender ID (e.g., "MyCompany") or a virtual mobile number purchased from MessageBird. The recipients array should contain one or more phone numbers in E.164 format (e.g., "+12025550100"). Upon success, the API returns a JSON object containing details of the sent message, including its ID and status.

Node.js SDK Example

First, install the MessageBird Node.js SDK:

npm install messagebird --save

Then, create a JavaScript file (e.g., send_sms.js) and add the following code. Remember to replace the placeholder values.

const messagebird = require('messagebird')('YOUR_API_KEY'); // Use your Secret Key here

const originator = 'YOUR_ORIGINATOR'; // e.g., 'MyCompany' or a virtual number
const recipient = 'RECIPIENT_NUMBER'; // e.g., '+12025550100' (E.164 format)
const messageBody = 'Hello from MessageBird Node.js SDK!';

messagebird.messages.create({
  originator: originator,
  recipients: [recipient],
  body: messageBody
}, function (err, response) {
  if (err) {
    console.log('Error sending message:', err);
  } else {
    console.log('Message sent successfully!', response);
  }
});

Execute the script:

node send_sms.js

The MessageBird SDK handles the underlying HTTP requests and authentication, simplifying the development process. The MessageBird SDK documentation provides examples for other supported languages like Python, Java, and PHP.

Common next steps

After successfully sending your first message, consider these common next steps to further integrate and optimize your use of MessageBird:

  • Explore Other APIs: MessageBird offers a range of APIs beyond SMS, including Voice API, WhatsApp Business API, and Email API. Explore these to broaden your communication capabilities.
  • Webhooks: Implement webhooks to receive real-time updates on message status (delivery reports), inbound messages, or voice call events. This is crucial for building interactive applications and tracking communication flows. The MessageBird Webhooks documentation explains how to configure these.
  • Error Handling and Logging: Implement robust error handling and logging in your application to manage potential API failures, network issues, or invalid requests. This helps in debugging and maintaining reliable communication.
  • Security Best Practices: Review MessageBird's security recommendations for API key management, webhook signature verification, and secure coding practices. For instance, do not hardcode API keys directly in your application code; use environment variables or a secure configuration management system. This aligns with general API security principles, as outlined by resources such as the Google Cloud security best practices for API keys.
  • Flow Builder: Utilize the Flow Builder, a visual interface for creating complex communication workflows without extensive coding. This can be particularly useful for automating responses, routing messages, or building interactive voice menus.
  • Monitoring and Analytics: Leverage the MessageBird Dashboard's monitoring tools to track message delivery rates, costs, and overall API usage. This data is essential for optimizing performance and managing expenses.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting steps and common problems:

  • Invalid API Key: Double-check that you are using the correct Access Key and Secret Key. Ensure there are no leading or trailing spaces if copied manually. Remember that the Node.js SDK example uses the Secret Key for initialization.
  • Insufficient Balance: If your account balance is too low, messages will fail to send. Check your account balance in the MessageBird Dashboard and top up if necessary.
  • Incorrect Originator: The originator (sender ID) must be a valid number or alphanumeric sender ID associated with your MessageBird account and approved for the destination country. Ensure it's correctly formatted and provisioned.
  • Invalid Recipient Number: Recipient numbers must be in E.164 format (e.g., +12025550100). Missing the + sign or country code is a frequent error.
  • Network Issues: Verify your internet connection and ensure no firewalls or proxies are blocking outbound connections to rest.messagebird.com.
  • API Rate Limits: While unlikely for a first call, be aware that MessageBird imposes rate limits. If you are rapidly testing, you might hit these limits. Consult the MessageBird rate limiting documentation for details.
  • API Error Messages: Pay close attention to the error messages returned by the API. They often provide specific clues about what went wrong. For example, a 401 Unauthorized error indicates an authentication problem, while a 403 Forbidden might suggest an issue with permissions or account status.
  • SDK-specific issues: If using an SDK, ensure it's correctly installed and configured. Check the SDK's documentation or GitHub repository for common issues and examples.

If you continue to experience problems, consult the comprehensive MessageBird Developer Documentation or contact MessageBird support for assistance.