BITMORO API

    SEND INSTANT OTP/MESSAGE

    This endpoint allows the user to send instant message to the specified phone number.This endpoint is specifically used for sending instant message to a designated phone number. It's ideal for scenarios where immediate delivery is crucial (e.g., OTPs, emergency alerts).

    The request body must include a phone number, the message content, and an optional sender ID.

    Note: This endpoint is given highest priority in the queue and the message is dispatched instantly, bypassing any regular queuing mechanisms that might delay other types of messages.

    ROUTE:

    https://api.bitmoro.com/message/api/single-message

    REQUEST METHOD:

    POST

    REQUEST-HEADERS :

    To successfully send a request to this endpoint, the following headers must be included in the request:

    • Authorization: This header must contain a valid bearer token in the format Bearer <token>, where <token> is your authentication token.
    • Content-Type: This should be set to application/json to indicate that the request body contains JSON data.
    • Content-Length: This should reflect the length of the request body in bytes.
          
            "headers": {
              "Authorization": "Bearer <your_token>",
              "Content-Type": "application/json",
              "Content-Length": "<length_of_your_data>"
            }
          
        

    Request Body

    The request body should be a JSON object with the following fields:

    Field Type Description Required
    number string A valid phone number to send the message to. Yes
    message string The message content that will be sent. Yes
    senderId string An optional field to specify the sender ID. No
    countryCode string The code of the country (e.g. np, in,us). Yes
    callbackUrl string An optional field to provide a callback URL, i.e, a valid URL to receive message reports via a POST request. No

    Note: ensure that no extra fields are present in the request body.

    Example Request Body:

          
            {
              "number": "98XXXXXXXX",
              "message": "Your otp is 5342",
              "senderId": "bit_alert",
              "countryCode":"np",
              "callbackUrl":"https://xyz.com/test"
            }
          
        

    SUCCESS RESPONSE

    Field Type Description
    messageId string A unique identifier for the message.
    status "DISPATCHED" "DISPATCHED" indicates it's ready to be sent.
    statusUrl string The API endpoint to fetch message delivery status using your API token.

    Example Of Success Response:

          
            {
              "messageId": "tqtkIYTQpSAneKYMLJEC",
              "status": "DISPATCHED",
              "statusUrl": "https://api.bitmoro.com/message/api/message-report/y9tjZBqBpQhzkArRSqdA"
            }
          
        

    ERROR RESPONSE

    Every required field must be provided in the request. If any required field is missing, the API will return a 400 error with a clear, descriptive message indicating which field(s) are absent.

    Note: Once a message is added to the dispatch queue, it is considered processed, and no further error responses will be returned. Errors are only returned for invalid requests or those that fail before reaching the queue. Messages in the queue are sent unless flagged as spam, in which case they are dropped.

    ErrorCode ErrorMessage StatusCode
    01 Must include auth header 400
    02 Invalid Authorization Format 400
    03 Permission not granted for ip ${ip} 403
    04 Number length cannot exceed 100 for instant use 400
    05 Cannot send message until the number is verified 403
    06 Insufficient credit for user with ID: ${userId} 400
    08 Invalid api token 403
    09 No senderId found 400
    10 Choosen senderId is not active contact admin 400
    11 Choosen senderId has crossed billing cycle contact admin for renewal 400
    12 Choosen senderId is not active , contact your organization 400
    13 Invalid Nepali phone number: ${number} 400
    14 Account deactivated due to spamming contact admin 403

    Example Of Error Response

          
            {
              "message": "Cannot send message until the number is verified",
              "errorCode": "05"
            }
          
        

    CALLBACK RESPONSE

    We strongly recommend including a callbackUrl to receive updates on sent messages. The callback response provides an accurate representation of the message and includes the following fields:

    Field Type Description
    messageId string A unique identifier for the message.
    message string The body of the message.
    status MESSAGE_STATUS The status of the message.
    report object Detailed information about the message sent.
    report.number string The phone number to which the message was sent.
    report.message string (optional) If there's an error, this contains the error message.
    report.status "failed" or "success" or "cancelled" The status of the message.
    report.creditCount number The number of credits spent to send the message.
    senderId string The sender ID of the message.
    deliveredDate Date The date when the message was delivered.
    refunded number The number of credits refunded.

    Message Status Enum

    The MESSAGE_STATUS enum represents the different states a message can be in:

    • pending The message is being processed.
    • sent The message has been successfully sent.
    • failed The message could not be delivered.
    • cancel The message was canceled before sending.
    • spam The message was flagged as spam.
    • queue The message is waiting in the queue to be sent.

    EXAMPLE OF CALLBACK RESPONSE

        
        {
          messageId: 'Gy2tr24Ti3UgRTiXOZq3',
          message: 'Hello',
          status: 'sent',
          report: [
              {
              number: '98XXXXXXXX',
              status: 'success',
              creditCount: 1
              }
          ],
          failed: 0,
          senderId: 'bit_alert',
          deliveredDate: '2024-12-16T08:01:01.762Z',
          refunded: 0
        }
        
      
    WARN: You cannot send the same message to a number more than three times within a 5-minute window. Each message must differ by at least 5%. Otherwise, it will be flagged as spam and dropped. Repeated spamming may result in the deactivation of the user.

    Send Messages in Bulk

    This endpoint allows users to send bulk messages to specified phone numbers, typically for sending SMS in bulk or scheduling messages.

    Additionally, it allows users to include a callback URL to receive a detailed report after the SMS is sent.

    ROUTE: https://api.bitmoro.com/message/api/bulk

    REQUEST-METHOD : POST

    REQUEST-HEADERS :

    To successfully send a request to this endpoint, the following headers must be included in the request:

    • Authorization: This header must contain a valid bearer token in the format Bearer <token>, where <token> is your authentication token.
    • Content-Type: This should be set to application/json to indicate that the request body contains JSON data.
    • Content-Length: This should reflect the length of the request body in bytes.
                
                "headers": {
                    "Authorization": "Bearer <your_token>",
                    "Content-Type": "application/json",
                    "Content-Length": "<length_of_your_data>"
                }
                
              

    Request Body

    Field Type Validation Required
    number array of strings An array of valid phone numbers to send the message to. Yes
    message string The message content that will be sent. Yes
    senderId string An optional field to specify the sender ID. No
    countryCode string The code of the country (e.g. np, in,us). Yes
    scheduledDate number A valid unix timestamp in future. No
    callbackUrl string An optional field to provide a callback URL, i.e, a valid URL to receive message reports via a POST request. No

    Note: Ensure no extra fields are present in the request body.

    Example Request Body

    {
      "number": ["98XXXXXXXX", "98XXXXXXXX"],
      "message": "Hello, this is a test message!",
      "senderId": "BIT_MORE",
      "countryCode":"np",
      "scheduledDate": 1734420765,
      "callbackUrl": "https://xyz.com/test"
    }
                  

    Success Response

    The API returns a JSON object with the following fields upon successfully queuing the message. For a more detailed delivery report, we recommend providing a callback URL.

    Field Type Description
    status "SCHEDULED" or "QUEUED" Indicates whether the message is scheduled or in the queue to be sent.
    report object Detailed information about the message sent.
    report.to string The phone number to which the message was sent.
    report.messageId string The unique messageId for the entire message.
    report.text string The content of the message body.
    report.type number The type of the message: 1 for ASCII, 2 for Unicode.
    report.from string The sender ID of the message.
    report.credit number The credit spent to send the message.
    creditSpent number Total credits spent to send the message.
    messageId string A unique identifier for the message.
    senderId string The sender ID of the message.

    EXAMPLE SUCCESS RESPONSE

          
            {
              status: 'SCHEDULED',
              report: [
                {
                  to: '98XXXXXXXX',
                  messageId: '1SdAarCiIjWNSbHMa40x',
                  from: 'BIT_MORE',
                  text: 'Hello, this is a test message!',
                  type: 1,
                  credit: 1
                },
                {
                  to: '98YYYYYYYY',
                  messageId: '1SdAarCiIjWNSbHMa40x',
                  from: 'BIT_MORE',
                  text: 'Hello, this is a test message!',
                  type: 1,
                  credit: 1
                }
              ],
              creditSpent: 2,
              messageId: '1SdAarCiIjWNSbHMa40x',
              senderId: 'BIT_MORE'
            }
          
        

    ERROR RESPONSE

    Every required field must be provided in the request. If any required field is missing, the API will return a 400 error with a clear, descriptive message indicating which field(s) are absent.

    Note: Once a message is added to the dispatch queue, it is considered processed, and no further error responses will be returned. Errors are only returned for invalid requests or those that fail before reaching the queue. Messages in the queue are sent unless flagged as spam, in which case they are dropped.

    tr>
    ErrorCode ErrorMessage StatusCode
    01 Must include auth header 400
    02 Invalid Authorization Format 400
    03 Permission not granted for ip ${ip} 403
    05 Cannot send message until the number is verified 403
    06 Insufficient credit for user with ID: ${userId} 400
    08 Invalid api token 403
    09 No senderId found 400
    10 Choosen senderId is not active contact admin 400
    11 Choosen senderId has crossed billing cycle contact admin for renewal 400
    12 Choosen senderId is not active, contact your organization 400
    14 Account deactivated due to spamming contact admin 403
    19 No numbers found 400
    18 Can't find any valid nepali numbers 400

    Example Of Error Response

          
            {
              "message": "Cannot send message until the number is verified",
              "errorCode": "05"
            }
          
        

    CALLBACK RESPONSE

    We strongly recommend including a callbackUrl to receive updates on sent messages. The callback response provides an accurate representation of the message and includes the following fields:

    Field Type Description
    messageId string A unique identifier for the message.
    message string The body of the message.
    status MESSAGE_STATUS The status of the message.
    report object Detailed information about the message sent.
    report.number string The phone number to which the message was sent.
    report.message string (optional) If there's an error, this contains the error message.
    report.status "failed" or "success" or "cancelled" The status of the message.
    report.creditCount number The number of credits spent to send the message.
    senderId string The sender ID of the message.
    deliveredDate Date The date when the message was delivered.
    refunded number The number of credits refunded.

    Message Status Enum

    The MESSAGE_STATUS enum represents the different states a message can be in:

    • pending The message is being processed.
    • sent The message has been successfully sent.
    • failed The message could not be delivered.
    • cancel The message was canceled before sending.
    • spam The message was flagged as spam.
    • queue The message is waiting in the queue to be sent.

    EXAMPLE OF CALLBACK RESPONSE

          
          {
            messageId: 'Gy2tr24Ti3UgRTiXOZq3',
            message: 'Hello',
            status: 'sent',
            countryCode: 'np',
            report: [
                {
                number: '98XXXXXXXX',
                status: 'success',
                creditCount: 1
                },
                {
                number: '98YYYYYYYY',
                status: 'failed',
                message: 'number not available',
                creditCount: 1
                }
            ],
            failed: 1,
            senderId: 'bit_alert',
            deliveredDate: '2024-12-16T08:01:01.762Z',
            refunded: 1
          }
          
        
    WARN: You cannot send the same message to a number more than three times within a 5-minute window. Each message must differ by at least 5%. Otherwise, it will be flagged as spam and dropped. Repeated spamming may result in the deactivation of the user.

    SEND DYNAMIC MESSAGES IN BULK

    This endpoint allows users to send dynamic message. A dynamic message allows users to send personalized content to multiple recipients in a single request. Unlike static messages, where the same content is sent to all recipients, dynamic messages are customized for each recipient using placeholders or variables.

    Additionally, it allows users to include a callback URL to receive a detailed report after the SMS is sent.

    ROUTE: https://api.bitmoro.com/message/api/dynamic

    REQUEST-METHOD: POST

    REQUEST-HEADERS :

    To successfully send a request to this endpoint, the following headers must be included in the request:

    • Authorization: This header must contain a valid bearer token in the format Bearer <token>, where <token> is your authentication token.
    • Content-Type: This should be set to application/json to indicate that the request body contains JSON data.
    • Content-Length: This should reflect the length of the request body in bytes.
    
    "headers": {
        "Authorization": "Bearer <your_token>",
        "Content-Type": "application/json",
        "Content-Length": "<length_of_your_data>"
    }
    
    

    Request Body

    Field Type Description Required
    contacts array of objects An array of contact object, each containing a number field and additional dynamic fields. Yes
    contacts.number string The phone number of the contact. Yes
    message string Message body with placeholders ${key} which are replaced by values from the contact or if missing, by defaultValues. Yes
    senderId string The sender ID for the message. No
    countryCode string The code of the country (e.g. np, in,us). Yes
    scheduledDate number A valid unix timestamp in future. No
    callbackUrl string callbackUrl is a valid URL to receive message report via POST request from our server No
    defaultValues object A set of default key-value pairs to be used for dynamic message content. No

    Note: ensure that no extra fields are present in the request body.

    Example Request Body

    
    {
      contacts: [
        {number: "98XXXXXXXX", name: "joe"},
        {number: "98YYYYYYYY"},
        {number: "98ZZZZZZZZ", city: "kathmandu"}
      ],
      message: "Hello ${name}. I am from ${city}",
      countryCode:"np",
      callbackUrl: "http://192.168.1.10:4000/test",
      scheduledDate: Date.now() + 1000 * 60,
      defaultValues: {name: "ramu", city: "Biratnagar"}
    }
    
    

    SUCCESS RESPONSE

    Field Type Description
    status "SCHEDULED" or "QUEUED" "SCHEDULED" indicates the message is scheduled, "QUEUED" indicates it's in the queue to be sent.
    report object Detailed information about the message sent.
    report.to string The phone number to which the message was sent.
    report.messageId string The unique messageId for the entire message.
    report.text string The content of the message body.
    report.type number The type of the message: 1 for ASCII, 2 for Unicode.
    report.from string The sender ID of the message. If not provided, the default sender ID will be used.
    report.credit number The credit spent to send the message.
    creditSpent number Total credits spent to send the message.
    messageId string A unique identifier for the message.
    senderId string The sender ID of the message.

    Example Success Response

        {
          status: 'QUEUED',
          report: [
            {
              to: '98XXXXXXXX',
              messageId: 'PjTii5xfoL1nKRFveMTt',
              from: 'BIT_MORE',
              text: 'Hello Joe. I am from Biratnagar.',
              type: 1,
              credit: 1
            },
            {
              to: '98YYYYYYYY',
              messageId: 'PjTii5xfoL1nKRFveMTt',
              from: 'BIT_MORE',
              text: 'Hello Ramu. I am from Biratnagar.',
              type: 1,
              credit: 1
            },
            {
              to: '98ZZZZZZZZ',
              messageId: 'PjTii5xfoL1nKRFveMTt',
              from: 'BIT_MORE',
              text: 'Hello Ramu. I am from Kathmandu.',
              type: 1,
              credit: 1
            }
          ],
          creditSpent: 3,
          messageId: 'PjTii5xfoL1nKRFveMTt',
          senderId: 'BIT_MORE',
          countryCode: 'np'
        }
      

    CALLBACK RESPONSE

    We strongly recommend including a callbackUrl to receive updates on sent messages. The callback response provides an accurate representation of the message and includes the following fields:

    Field Type Description
    messageId string A unique identifier for the message.
    message string The body of the message.
    status MESSAGE_STATUS The status of the message.
    report object Detailed information about the message sent.
    report.number string The phone number to which the message was sent.
    report.message string (optional) If there's an error, this contains the error message.
    report.status "failed" or "success" or "cancelled" The status of the message.
    report.creditCount number The number of credits spent to send the message.
    senderId string The sender ID of the message.
    deliveredDate Date The date when the message was delivered.
    refunded number The number of credits refunded.

    Message Status Enum

    The MESSAGE_STATUS enum represents the different states a message can be in:

    • pending The message is being processed.
    • sent The message has been successfully sent.
    • failed The message could not be delivered.
    • cancel The message was canceled before sending.
    • spam The message was flagged as spam.
    • queue The message is waiting in the queue to be sent.

    EXAMPLE OF CALLBACK RESPONSE

        
        {
          messageId: 'Yf0mzK1GX1dvmxtmV5XN',
          message: 'Hello ${name}. I am from ${city}',
          status: 'sent',
          report: [
            {
              number: '98XXXXXXXX',
              status: 'success',
              creditCount: 1
            },
            {
              number: '98YYYYYYYY',
              status: 'success',
              creditCount: 1
            },
            {
              number: '98ZZZZZZZZ',
              status: 'failed',
              message: 'number not available',
              creditCount: 1
            }
          ],
          failed: 1,
          senderId: 'bit_alert',
          countryCode: 'np',
          deliveredDate: '2024-12-16T08:55:56.855Z',
          refunded: 1
        }
        
      

    ERROR RESPONSE

    Every required field must be provided in the request. If any required field is missing, the API will return a 400 error with a clear, descriptive message indicating which field(s) are absent.
    Note: Once a message is added to the dispatch queue, it is considered processed, and no further error responses will be returned. Errors are only returned for invalid requests or those that fail before reaching the queue. Messages in the queue are sent unless flagged as spam, in which case they are dropped.

    ErrorCode ErrorMessage StatusCode
    01 Must include auth header 400
    02 Invalid Authorization Format 400
    03 Permission not granted for IP ${ip} 403
    05 Cannot send message until the number is verified 403
    06 Insufficient credit for user with ID: ${userId} 400
    08 Invalid api token 403
    09 No senderId found 400
    10 Choosen senderId is not active contact admin 400
    11 Choosen senderId has crossed billing cycle contact admin for renewal 400
    12 Choosen senderId is not active , contact your organization 400
    14 Account deactivated due to spamming contact admin 403
    19 No numbers found 400
    18 Can't find any valid nepali numbers 400

    Example Of Error Response

    
    {
      "message": "Cannot send message until the number is verified",
      "errorCode": "05"
    }
    
    WARN: You cannot send the same message to a number more than three times within a 5-minute window. Each message must differ by at least 5%. Otherwise, it will be flagged as spam and dropped. Repeated spamming may result in the deactivation of the user.
    • SEND MESSAGES IN BATCH

      This endpoint allows the user to send messages in batch to the specified phone numbers. The request body must include a list of phone numbers, the message content, and an optional sender ID.

      This endpoint is given high priority in the queue.

      ROUTE: https://api.bitmoro.com/message/api

      REQUEST-METHOD: POST

      REQUEST-HEADERS:

      To successfully send a request to this endpoint, the following headers must be included in the request:

      • Authorization: This header must contain a valid bearer token in the format Bearer <token>, where <token> is your authentication token.
      • Content-Type: This should be set to application/json to indicate that the request body contains JSON data.
      • Content-Length: This should reflect the length of the request body in bytes.
      {
        "headers": {
          "Authorization": "Bearer <your_token>",
          "Content-Type": "application/json",
          "Content-Length": "<length_of_your_data>"
        }
      }
            

      Request Body

      The request body should be a JSON object with the following fields:

      Field Type Description Required
      number array An array of valid phone numbers to send the message to. Yes
      message string The message content that will be sent. Yes
      senderId string An optional field to specify the sender ID. No
      countryCode string The code of the country (e.g. np, in,us). Yes
      Note: ensure that no extra fields are present in the request body.

      Example Request Body:

      {
        "number": ["98XXXXXXXX", "98XXXXXXXXX"],
        "message": "Hello, this is a test message!",
        "senderId": "bit_alert",
        "countryCode":"np",
        "countryCode":"np"
      }
            

      SUCCESS RESPONSE

      Field Type Description
      messageId string A unique identifier for the message.
      status QUEUED QUEUED indicates it's in the queue to be sent.
      statusUrl string The API endpoint to fetch message delivery status using your API token.

      Example Of Success Response:

      {
        "messageId": "tqtkIYTQpSAneKYMLJEC",
        "status": "QUEUED",
        "statusUrl": "https://api.bitmoro.com/message/message-report/y9tjZBqBpQhzkArRSqdA"
      }
            

      ERROR RESPONSE

      Every required field must be provided in the request. If any required field is missing, the API will return a 400 error with a clear, descriptive message indicating which field(s) are absent.
      Note: Once a message is added to the dispatch queue, it is considered processed, and no further error responses will be returned. Errors are only returned for invalid requests or those that fail before reaching the queue. Messages in the queue are sent unless flagged as spam, in which case they are dropped.

      ErrorCode ErrorMessage StatusCode
      01 Must include auth header 400
      02 Invalid Authorization Format 400
      03 Permission not granted for ip ${ip} 403
      04 Number length cannot exceed 100 for instant use 400
      05 Cannot send message until the number is verified 403
      06 Insufficient credit for user with ID: ${userId} 400
      08 Invalid api token 403
      09 No senderId found 400
      10 Choosen senderId is not active contact admin 400
      11 Choosen senderId has crossed billing cycle contact admin for renewal 400
      12 Choosen senderId is not active, contact your organization 400
      14 Account deactivated due to spamming contact admin 403
      19 No numbers found 400
      18 Can't find any valid nepali numbers 400

      Example Of Error Response

      {
        "message": "Cannot send message until the number is verified",
        "errorCode": "05"
      }
            

      WARN: - You cannot send the same message to a number more than three times within a 5-minute window. Each message must differ by at least 5%. Otherwise, it will be flagged as spam and dropped. Repeated spamming may result in the deactivation of the user.
      - The maximum number of recipients for a single request is 100. If you need to send messages to more than 100 recipients, you can use the SEND MESSAGES IN BULK endpoint.

    • GET MESSAGE REPORT

      This feature allows users to retrieve a detailed report of their sent messages. It provides a clear overview for tracking and managing message performance and delivery outcomes.

      ROUTE: https://api.bitmoro.com/message/api/message-report/:messageId

      REQUEST-METHOD: GET

      REQUEST-HEADERS:

      To successfully send a request to this endpoint, the following headers must be included in the request:

      • Authorization: This header must contain a valid bearer token in the format Bearer <token>, where <token> is your authentication token.
      • Content-Type: This should be set to application/json to indicate that the request body contains JSON data.
      • Content-Length: This should reflect the length of the request body in bytes.
                
                  "headers": {
                    "Authorization": "Bearer <your_token>",
                    "Content-Type": "application/json",
                    "Content-Length": "<length_of_your_data>"
                  }
                
              

      SUCCESS RESPONSE

      Field Type Description
      messageId string Unique identifier for the message.
      status string Status of the message (e.g., pending, sent, failed, cancel).
      total number Total number of messages attempted to send.
      failed number Total number of failed messages.
      creditSpent number Total credits used to send the message(s).
      refunded number Total number of credits refunded.
      senderName string Name of the sender.
      deliveredDate Date Date and time when the message was delivered.
      scheduleDate Date Date and time when the message is scheduled to be sent.

      ERROR RESPONSE

      ErrorCode ErrorMessage StatusCode
      01 Must include auth header 400
      02 Invalid Authorization Format 400
      03 Permission not granted for IP ${ip} 403
      07 No message found with messageId :${messageId} 400
      08 Invalid api token 403
      16 No message id found in params 400
    • CANCEL SCHEDULED MESSAGE

      This endpoint allows user to cancel the messages scheduled to be sent in future.

      ROUTE: https://api.bitmoro.com/message/api/cancel/:messageId

      REQUEST-METHOD: PUT

      REQUEST-HEADERS:

      To successfully send a request to this endpoint, the following headers must be included in the request:

      • Authorization: This header must contain a valid bearer token in the format Bearer <token>, where <token> is your authentication token.
      • Content-Type: This should be set to application/json to indicate that the request body contains JSON data.
      • Content-Length: This should reflect the length of the request body in bytes.
                
                  "headers": {
                    "Authorization": "Bearer <your_token>",
                    "Content-Type": "application/json",
                    "Content-Length": "<length_of_your_data>"
                  }
                
              

      SUCCESS RESPONSE

      Field Type Description
      status string Confirmation message regarding the cancellation of the scheduled message.

      ERROR RESPONSE

      ErrorCode ErrorMessage StatusCode
      01 Must include auth header 400
      02 Invalid Authorization Format 400
      03 Permission not granted for IP ${ip} 403
      07 No messages found with messageId :${messageId} 400
      08 Invalid api token 403
      17 No message id found 403

    Verifying Callback

    Body param in callBack:

    {
      "messageId": "Gy2tr24Ti3UgRTiXOZq3",
      "message": "Hello",
      "signature": "2345saddsfds876543",
      "status": "sent",
      "report": [
        {
          "number": "98XXXXXXXX",
          "status": "success",
          "creditCount": 1
        }
      ],
      "failed": 0,
      "senderId": "bit_alert",
      "countryCode":"np",
      "deliveredDate": "2024-12-16T08:01:01.762Z",
      "refunded": 0
    }

    HMAC SHA512 Verification

    Generate an HMAC signature using your key and the messageId. Then compare it with the signature received in the callback. If they match, the request is verified and coming from Bitmoro.

    Generate key from Bitmoro:

    Generate Key from Bitmoro