MENU navbar-image

Introduction

This document aims to provide you with all the necessary information for working with the EasySms API.

Base URL

https://www.easysms.co

Authenticating requests

This API is authenticated by sending an Authorization header with the value "Bearer {YOUR_AUTH_KEY}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve your token by visiting your dashboard and clicking Generate API token.

Security

Protocol

You must use the HTTPS protocol for every request to EasySms. HTTP is not supported.

TLS and certificates

TLS (Transport Layer Security) is a cryptographic protocol that ensures secure communication over a network. It's commonly used to secure connections between web browsers and servers, email servers, and other types of communication. Certificates play a crucial role in TLS. They are digital documents that verify the authenticity of a website or server. When a user connects to a website over HTTPS (HTTP Secure), the server presents its certificate to prove its identity. If the certificate is valid and trusted, a secure connection is established. Certificates contain information such as the issuer (a trusted Certificate Authority), the entity it belongs to, a digital signature, and the public key. This encryption process helps protect data transmitted between the client (such as a web browser) and the server, ensuring confidentiality and integrity.

Status Codes

The errors that API endpoints may return are listed below.

Status Code Meaning
400 Bad request (something wrong with URL or parameters)
401 Not authorized (not logged in)
403 Logged in but access to requested area is forbidden
404 Not Found (page or other resource doesn't exist)
422 Unprocessable Entity (validation failed)
500 General server error
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout

Endpoints

Send Sms

requires authentication

You can use this endpoint to send bulk SMS messages to your recipients. The receiver list can contain a maximum of 1000 recipients.

Example request:
curl --request POST \
    "https://www.easysms.co/api/send-sms" \
    --header "Authorization: Bearer {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"receivers\": [
        {
            \"phone\": \"358403536665\"
        }
    ],
    \"text\": \"Test Sms\"
}"
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://www.easysms.co/api/send-sms',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'receivers' => [
                [
                    'phone' => '358403536665',
                ],
            ],
            'text' => 'Test Sms',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
const url = new URL(
    "https://www.easysms.co/api/send-sms"
);

const headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "receivers": [
        {
            "phone": "358403536665"
        }
    ],
    "text": "Test Sms"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
import requests
import json

url = 'https://www.easysms.co/api/send-sms'
payload = {
    "receivers": [
        {
            "phone": "358403536665"
        }
    ],
    "text": "Test Sms"
}
headers = {
  'Authorization': 'Bearer {YOUR_AUTH_KEY}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "status": true,
    "message": "Messages sent.",
    "data": null
}
 

Example response (401, Authorization Failed):


{
    "status": false,
    "message": "Unauthenticated.",
    "data": null
}
 

Example response (422, Unprocessable Content):


{
    "status": false,
    "message": "The given data was invalid.",
    "data": null,
    "errors": {
        "receivers.0.phone": [
            "The receivers.0.phone format is invalid.",
            "The receivers.0.phone must be at least 10 characters."
        ]
    }
}
 

Request      

POST api/send-sms

Body Parameters

receivers  object[] optional  

receivers[].phone  string  

The value format is invalid. Must be at least 7 characters.

text  string  

Must be at least 4 characters.

Create Otp

requires authentication

This endpoint lets you send a otp code.

Example request:
curl --request POST \
    "https://www.easysms.co/api/create-otp" \
    --header "Authorization: Bearer {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"phone\": \"358403536665\"
}"
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://www.easysms.co/api/create-otp',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'phone' => '358403536665',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
const url = new URL(
    "https://www.easysms.co/api/create-otp"
);

const headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "phone": "358403536665"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
import requests
import json

url = 'https://www.easysms.co/api/create-otp'
payload = {
    "phone": "358403536665"
}
headers = {
  'Authorization': 'Bearer {YOUR_AUTH_KEY}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "status": true,
    "message": "Otp sent.",
    "data": null
}
 

Example response (401, Authorization Failed):


{
    "status": false,
    "message": "Unauthenticated.",
    "data": null
}
 

Example response (422, Unprocessable Content):


{
    "status": false,
    "message": "The given data was invalid.",
    "data": null,
    "errors": {
        "phone": [
            "The phone format is invalid.",
            "The phone must be at least 10 characters."
        ]
    }
}
 

Request      

POST api/create-otp

Body Parameters

phone  string  

The value format is invalid. Must be at least 7 characters.

Validate Otp

requires authentication

This endpoint lets you validate code.

Example request:
curl --request POST \
    "https://www.easysms.co/api/validate-otp" \
    --header "Authorization: Bearer {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"phone\": \"358403536665\",
    \"code\": 123456
}"
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://www.easysms.co/api/validate-otp',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'phone' => '358403536665',
            'code' => 123456.0,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
const url = new URL(
    "https://www.easysms.co/api/validate-otp"
);

const headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "phone": "358403536665",
    "code": 123456
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
import requests
import json

url = 'https://www.easysms.co/api/validate-otp'
payload = {
    "phone": "358403536665",
    "code": 123456
}
headers = {
  'Authorization': 'Bearer {YOUR_AUTH_KEY}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "status": true,
    "message": "OTP is valid",
    "data": null
}
 

Example response (401, Authorization Failed):


{
    "status": false,
    "message": "Unauthenticated.",
    "data": null
}
 

Example response (422, Unprocessable Content):


{
    "status": false,
    "message": "OTP does not exist",
    "data": null
}
 

Request      

POST api/validate-otp

Body Parameters

phone  string  

The value format is invalid. Must be at least 7 characters.

code  number  

Must be 6 digits.

Phone Number Standard

In all requests, the phone number must be sent with the country code added and without + or any special characters at the beginning.

Country Name Country Name Abbreviation Country Code
Afghanistan AF 93
Albania AL 355
Algeria DZ 213
American Samoa AS 1
Andorra AD 376
Angola AO 244
Anguilla AI 1
Antigua and Barbuda AG 1
Argentina AR 54
Armenia AM 374
Aruba AW 297
Ascension AC 247
Australia AU 61
Γ…land Islands AX 672
Austria AT 43
Azerbaijan AZ 994
Bahamas BS 1
Bahrain BH 973
Bangladesh BD 880
Barbados BB 1
Belarus BY 375
Belgium BE 32
Belize BZ 501
Benin BJ 229
Bermuda BM 1
Bhutan BT 975
Bolivia BO 591
Bosnia and Herzegovina BA 387
Botswana BW 267
Brazil BR 55
British Virgin Islans VG 1
Brunei Darussalam BN 673
Bulgaria BG 359
Burkina Faso BF 226
Burundi BI 257
Cambodia KH 855
Cameroon CM 237
Canada CA 1
Cape Verde CV 238
Cayman Islands KY 1
Central African Republic CF 236
Chad TD 235
Chile CL 56
China CN 86
Colombia CO 57
Comoros KM 269
Congo CG 242
Cook Islands CK 682
Costa Rica CR 506
Cote d'Ivorie CI 225
Croatia HR 385
Cuba CU 53
Cyprus CY 357
Czech Republic CZ 420
Democratic Republic of the Congo CD 243
Denmark DK 45
Diego Garcia DG 246
Djibouti DJ 253
Dominica DM 1
Dominican Republic DO 1
East Timor TL 670
Ecuador EC 593
Egypt EG 20
El Salvador SV 503
Equatorial Guinea GQ 240
Eritrea ER 291
Estonia EE 372
Ethiopia ET 251
Falkland Islands FK 500
Faroe Islands FO 298
Fiji FJ 679
Finland FI 358
France FR 33
French Guiana GF 594
French Polynesia PF 689
Gabon GA 241
Gambia GM 220
Georgia GE 995
Germany DE 49
Ghana GH 233
Gibraltar GI 350
Greece GR 30
Greenland GL 299
Grenada GD 1
Guadeloupe GP 590
Guam GU 1
Guatemala GT 502
Guinea GN 224
Guinea-Bissau GW 245
Guyana GY 592
Haiti HT 509
Honduras HN 504
Hong Kong HK 852
Hungary HU 36
Iceland IS 354
India IN 91
Indonesia ID 62
Iran IR 98
Iraq IQ 964
Ireland IE 353
Israel IL 972
Italy IT 39
Jamaica JM 1
Japan JP 81
Jordan JO 962
Kazakhstan KZ 7
Kenya KE 254
Kiribati KI 686
Kuwait KW 965
Kyrgyzstan KG 996
Laos LA 856
Latvia LV 371
Lebanon LB 961
Lesotho LS 266
Liberia LR 231
Libya LY 218
Liechtenstein LI 423
Lithuania LT 370
Luxembourg LU 352
Macao MO 853
Macedonia MK 389
Madagascar MG 261
Malawi MW 265
Malaysia MY 60
Maldives MV 960
Mali ML 223
Malta MT 356
Marshall Islands MH 692
Martinique MQ 596
Mauritania MR 222
Mauritius MU 230
Mexico MX 52
Micronesia FM 691
Moldova MD 373
Monaco MC 377
Mongolia MN 976
Montenegro ME 382
Montserrat MS 1
Morocco MA 212
Mozambique MZ 258
Myanmar MM 95
Namibia NA 264
Nauru NR 674
Nepal NP 977
Netherlands NL 31
Netherlands Antilles* AN 599
New Caledonia NC 687
New Zealand NZ 64
Nicaragua NI 505
Niger NE 227
Nigeria NG 234
Niue NU 683
North Korea KP 850
Northern Mariana Islands MP 1
Norway NO 47
Oman OM 968
Pakistan PK 92
Palau PW 680
Palestine PS 970
Panama PA 507
Papau New Guinea PG 675
Paraguay PY 595
Peru PE 51
Phillippines PH 63
Poland PL 48
Portugal PT 351
Puerto Rico PR 1
Qatar QA 974
Reunion RE 262
Romania RO 40
Russia RU 7
Rwanda RW 250
Saint Helena SH 290
Saint Kitts and Nevis KN 1
Saint Lucia LC 1
Saint Pierre and Miquelon PM 508
Saint Vincent and Grenadines VC 1
Samoa WS 685
San Marino SM 378
Sao Tome and Principe ST 239
Saudi Arabia SA 966
Senegal SN 221
Serbia RS 381
Seychelles SC 248
Sierra Leone SL 232
Singapore SG 65
Slovakia SK 421
Slovenia SI 386
Solomon Islands SB 677
Somalia SO 252
South Africa ZA 27
South Korea KR 82
Spain ES 34
Sri Lanka LK 94
Sudan SD 249
Suriname SR 597
Swaziland SZ 268
Sweden SE 46
Switzerland CH 41
Syria SY 963
Taiwan TW 886
Tajikistan TJ 992
Tanzania TZ 255
Thailand TH 66
Togo TG 228
Tokelau TK 690
Tonga TO 676
Trinidad and Tobago TT 1
Tunisia TN 216
Turkey TR 90
Turkmenistan TM 993
Turks and Caicos Islands TC 1
Tuvalu TV 688
US Virgin Islands VI 1
Uganda UG 256
Ukraine UA 380
United Arab Emirates AE 971
United Kingdom GB 44
United States US 1
Uruguay UY 598
Uzbekistan UZ 998
Vanuatu VU 678
Vatican City VA 379
Venezuela VE 58
Vietnam VN 84
Wallis and Futuna WF 681
Yemen YE 967
Zambia ZM 260
Zimbabwe ZW 263