Hasun API (1.0.0)

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

  1. An account with Hasun.lk
  2. Valid API Token to authenticate

How to register with Hasun

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.

Status

Status

Check the status of Hasun API. This serves two primary purposes,

  1. Act as an endpoint to check your connection
  2. Serve as a way to get Hasun API status
Authorizations:
bearerAuth
path Parameters
organisation_token
required
string

Responses

Response samples

Content type
application/json
{
  • "status": "success",
  • "version": "v1",
  • "message": "Hello world!"
}

Verification

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.

Verification > OTP

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.

Send

A valid mask_token is required, and the mask_token should be inside the organisation you're scoping.

Authorizations:
bearerAuth
path Parameters
organisation_token
required
string
Request Body schema: application/json
mask_token
required
string
number
required
string
expire
integer

Responses

Request samples

Content type
application/json
{
  • "mask_token": "FD43GDET",
  • "number": "07x1234567",
  • "expire": "120"
}

Response samples

Content type
application/json
{
  • "otp_code": 123456
}

Verify

Authorizations:
bearerAuth
path Parameters
organisation_token
required
string
Request Body schema: application/json
mask_token
string
number
string
otp
integer

Responses

Request samples

Content type
application/json
{
  • "mask_token": "FD43GDET",
  • "number": "07x1234567",
  • "otp": 123456
}

Response samples

Content type
application/json
Example
{
  • "verification": true,
  • "reason": "verified",
  • "message": "OTP code verified"
}

Transactional

Transactional > SMS

Send

Authorizations:
bearerAuth
path Parameters
organisation_token
required
string
Request Body schema: application/json
mask_token
string
number
string
message
string

Responses

Request samples

Content type
application/json
{
  • "mask_token": "FD43GDET",
  • "number": "07x1234567",
  • "message": "Test Message"
}

Response samples

Content type
application/json
{
  • "status": "success",
  • "message_uuid": "30ce50d2-7b7c-48b9-9c4b-db5bc8345e87"
}

Status

Authorizations:
bearerAuth
path Parameters
organisation_token
required
string
Request Body schema: application/json
mask_token
string
message_uuid
string

Responses

Request samples

Content type
application/json
{
  • "mask_token": "R432FDESD",
  • "message_uuid": "a150722c-c705-46b8-8e80-b7327f2ba6dd"
}

Response samples

Content type
application/json
Example
{
  • "status": "delivered"
}

Number Mask

GetOrganisationNumberMasks

Number Masks

You can have multiple number masks available for a single organisation. Getting the number mask list for a single organisation can be performed.

path Parameters
organisation_token
required
string

Responses