Download OpenAPI specification:Download
Hasun supports SMS, Email, and WhatsApp as transactional communication methods. Some functionality may be still in beta but the documented features will work as this documentation is an export from our API testing collection.
The following two requirements must be met to start working with Hasun API
Visit https://console.hasun.lk and register for a new account. Click on the user icon and generate an API token by visiting API Information > Generate Token.
Once a token has been generated, use the generated token as a Bearer token to authenticate. Our examples are based on cURL, but Hasun API works as an HTTP API.
Check the status of Hasun API. This serves two primary purposes,
organisation_token required | string |
{- "status": "success",
- "version": "v1",
- "message": "Hello world!"
}
Hasun aims to support a few different verification methods in the future. So we have bundled our SMS OTP endpoint into verification/otp/sms
instead of verification/sms
This might be a little different from our other endpoints, but by following this pattern, future verification methods such as Call to Verify will be easier to implement in your application.
Hasun provides an easy-to-use OTP generator, and all OTP codes are scoped to your Organisation, Number Mask. By default, OTP code will expire in 30 minutes, and you can manually define a time using expire
value in seconds.
OTP will expire after the given time and will return an error if tried to validate. You can retry sending an OTP using the same sending endpoint.
A valid mask_token
is required, and the mask_token
should be inside the organisation you're scoping.
organisation_token required | string |
mask_token required | string |
number required | string |
expire | integer |
{- "mask_token": "FD43GDET",
- "number": "07x1234567",
- "expire": "120"
}
{- "otp_code": 123456
}
organisation_token required | string |
mask_token | string |
number | string |
otp | integer |
{- "mask_token": "FD43GDET",
- "number": "07x1234567",
- "otp": 123456
}
{- "verification": true,
- "reason": "verified",
- "message": "OTP code verified"
}
organisation_token required | string |
mask_token | string |
number | string |
message | string |
{- "mask_token": "FD43GDET",
- "number": "07x1234567",
- "message": "Test Message"
}
{- "status": "success",
- "message_uuid": "30ce50d2-7b7c-48b9-9c4b-db5bc8345e87"
}
organisation_token required | string |
mask_token | string |
message_uuid | string |
{- "mask_token": "R432FDESD",
- "message_uuid": "a150722c-c705-46b8-8e80-b7327f2ba6dd"
}
{- "status": "delivered"
}