Testing
The HelloSMS API provides a testMode
parameter for several endpoints, allowing you to simulate API requests without actually sending SMS messages or using credits. This is incredibly useful for testing your integration, debugging code, and understanding how different parameters affect your messages.
The testMode
parameter helps developers:
- Simulate SMS sending without delivering messages.
- Check the message segmentation and length calculations.
- Verify the request structure and API responses.
- Test integrations without affecting real users.
How to Use testMode
To activate test mode, simply include the testMode
property with a value of true
in the request body of supported endpoints.
Test mode is available on the following endpoints:
Testing Scenarios
Here are some examples of how you can utilize testMode
:
Verifying Integration:
When you're first integrating with the HelloSMS API, testMode
lets you confirm that your requests are correctly formatted and that you're receiving the expected responses without incurring any costs.
Example:
{
"to": [
"46701740610"
],
"from": "46701740609",
"subject": "API Test",
"message": "Testing API. Visit https://hellosms.se/#contact for more information. ",
"testMode": true
}
Estimating SMS Length and Cost:
SMS messages are typically limited to 160 characters. Longer messages are split into multiple segments, which can affect pricing. By using testMode
, you can see how your message will be segmented and estimate the cost before sending it.
Example:
{
"to": [
"46701740610"
],
"from": "46701740609",
"subject": "API Test",
"message": "This is a long test message designed to exceed the usual SMS character limit and trigger message splitting. It will help you understand how the HelloSMS API handles longer messages and segments them for delivery. You can track the segments using the message IDs in the API response.",
"testMode": true
}
The API response will indicate the number of segments the message will be divided into (messageCount
field in the response).
Testing Group Management:
You can use testMode with the Create a new group and Add numbers to a group endpoints to practice creating and managing contact groups without permanently altering your account data.
Example of creating a new group:
{
"name": "Test group",
"testMode": true,
"fields": [
{
"type": "text",
"field": "Example text."
},
{
"type": "text",
"field": "Example text 2."
}
]
}
Example of adding a number to a group:
{
"groupId": "aa26c157b79",
"numbers": [
{
"_number": "46701740610",
"Firstname": "John",
"Lastname": "Doe"
}
],
"testMode": true
}
Remember to always set testMode
to false
when you're ready to send real SMS messages.