<<<<<<< HEAD UGSMS Documentation MENU navbar-image

Introduction

API Documentation

This documentation provides comprehensive information for developers looking to integrate with our SMS messaging API. Before using the API, you must create an account to obtain your credentials (username and password). Here, you'll find everything you need to understand the API's capabilities, including endpoints, request and response formats, authentication methods, and more.

Send SMS Message API

Endpoint

POST /v1/sms/send

Description

This endpoint allows you to send SMS messages to multiple recipients. Users can provide their credentials via URL parameters or form parameters.


Authentication

Credentials

Users must provide the following credentials for authentication:

Credentials can be passed either as URL parameters or form parameters.


Request Parameters

Body Parameters

Parameter Type Required Description
numbers string Yes The phone numbers to send the message to. Comma separated. Example: 0701234567, 0712345678
message_body string Yes The content of the message to be sent. Example: "Hello, this is a test message."
username string Yes Your username for authentication. Example: "user123"
password string Yes Your password for authentication. Example: "pass123"

Responses

Success Response


400 Bad Request

{ "error": "Invalid phone number format." }


401 Unauthorized

{ "error": "Unauthorized." }


Explanation of Sections

  1. Endpoint: Specifies the URL and method used to access the API.
  2. Description: Provides a brief overview of what the endpoint does.
  3. Authentication: Details the credentials needed for access.
  4. Request Parameters: Lists the body parameters that can be sent with the request, including their types and descriptions.
  5. Responses: Describes the possible responses, including success and error responses with example JSON outputs.
  6. Notes: Additional information relevant to the API usage.

Endpoints

Display Swagger API page.

Example request:
curl --request GET \
    --get "http://localhost/api/v2" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://localhost/api/v2"
);

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

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (500):

Show headers
cache-control: no-cache, private
content-type: application/json
access-control-allow-origin: *
 

{
    "message": "Server Error"
}
 

Request      

GET api/v2

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Display Oauth2 callback pages.

Example request:
curl --request GET \
    --get "http://localhost/api/oauth2-callback" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://localhost/api/oauth2-callback"
);

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

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):

Show headers
content-type: text/html; charset=UTF-8
cache-control: no-cache, private
access-control-allow-origin: *
 

<!doctype html>
<html lang="en-US">
<body>
<script src="oauth2-redirect.js"></script>
</body>
</html>

 

Request      

GET api/oauth2-callback

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

GET api/v2/sms/send

Example request:
curl --request GET \
    --get "http://localhost/api/v2/sms/send" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://localhost/api/v2/sms/send"
);

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

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 59
access-control-allow-origin: *
 

{
    "error": "API key is required",
    "help": "Provide X-API-Key header or api_key parameter"
}
 

Request      

GET api/v2/sms/send

POST api/v2/sms/send

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

GET api/v2/account/balance

Example request:
curl --request GET \
    --get "http://localhost/api/v2/account/balance" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://localhost/api/v2/account/balance"
);

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

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 58
access-control-allow-origin: *
 

{
    "error": "API key is required",
    "help": "Provide X-API-Key header or api_key parameter"
}
 

Request      

GET api/v2/account/balance

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

POST api/generate-key

Example request:
curl --request POST \
    "http://localhost/api/generate-key" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"expiry_days\": 3
}"
const url = new URL(
    "http://localhost/api/generate-key"
);

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

let body = {
    "expiry_days": 3
};

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

Request      

POST api/generate-key

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

expiry_days   integer  optional  

Must be at least 1. Must not be greater than 365. Example: 3

POST api/revoke-key

Example request:
curl --request POST \
    "http://localhost/api/revoke-key" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://localhost/api/revoke-key"
);

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

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/revoke-key

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

POST api/regenerate-key

Example request:
curl --request POST \
    "http://localhost/api/regenerate-key" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"expiry_days\": 9
}"
const url = new URL(
    "http://localhost/api/regenerate-key"
);

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

let body = {
    "expiry_days": 9
};

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

Request      

POST api/regenerate-key

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

expiry_days   integer  optional  

Must be at least 1. Must not be greater than 365. Example: 9

======= UgSms - Documentation MENU navbar-image

Introduction

API Documentation

This documentation provides comprehensive information for developers looking to integrate with our SMS messaging API. Before using the API, you must create an account to obtain your credentials (username and password). Here, you'll find everything you need to understand the API's capabilities, including endpoints, request and response formats, authentication methods, and more.

Send SMS Message API

Endpoint

POST /v1/sms/send

Description

This endpoint allows you to send SMS messages to multiple recipients. Users can provide their credentials via URL parameters or form parameters.


Authentication

Credentials

Users must provide the following credentials for authentication:

Credentials can be passed either as URL parameters or form parameters.


Request Parameters

Body Parameters

Parameter Type Required Description
numbers string Yes The phone numbers to send the message to. Comma separated. Example: 0701234567, 0712345678
message_body string Yes The content of the message to be sent. Example: "Hello, this is a test message."
username string Yes Your username for authentication. Example: "user123"
password string Yes Your password for authentication. Example: "pass123"

Responses

Success Response

200 OK

{
    "message": "Message Sent Successfully."
}

400 Bad Request

{
    "error": "Invalid phone number format."
}

401 Unauthorized

{
    "error": "Unauthorized."
}

Check Balance API

Endpoint

GET /v1/balance

Description

This endpoint allows authenticated users to check their current SMS balance. The balance represents the number of SMS credits available in the user's account.


Authentication

Credentials

Users must provide the following credentials for authentication:

Credentials must be passed as query parameters or form parameters.


Request Parameters

Query Parameters

Parameter Type Required Description
username string Yes Your username for authentication. Example: "user123"
password string Yes Your password for authentication. Example: "pass123"

Body Parameters (Alternative)

You can also send credentials in the request body as JSON:

{
    "username": "your_username",
    "password": "your_password"
}

Responses

Success Response

200 OK

{
    "status": true,
    "balance": 150
}

Response Fields:


401 Unauthorized

{
    "status": false,
    "message": "Invalid username or password"
}

400 Bad Request

{
    "status": false,
    "message": "Validation error messages"
}

Usage Examples

URL with Query Parameters:

GET https://ugsms.com/v1/balance?username=user123&password=pass123

cURL Example:

curl -X GET "https://ugsms.com/v1/balance?username=user123&password=pass123"

Postman Collection:

{
    "item": [
        {
            "name": "Check Balance",
            "request": {
                "method": "GET",
                "url": {
                    "raw": "{{baseUrl}}/balance?username=your_username&password=your_password",
                    "host": ["{{baseUrl}}"],
                    "path": ["balance"],
                    "query": [
                        {
                            "key": "username",
                            "value": "your_username"
                        },
                        {
                            "key": "password",
                            "value": "your_password"
                        }
                    ]
                }
            },
            "response": [
                {
                    "code": 200,
                    "name": "Success Response",
                    "body": "{\n    \"status\": true,\n    \"balance\": 150\n}",
                    "description": "Returns the current balance of the user."
                },
                {
                    "code": 401,
                    "name": "Unauthorized Response",
                    "body": "{\n    \"status\": false,\n    \"message\": \"Invalid username or password\"\n}",
                    "description": "Returns an error message if the authentication fails."
                }
            ]
        }
    ]
}

Explanation of Sections

  1. Endpoint: Specifies the URL and method used to access the API.
  2. Description: Provides a brief overview of what the endpoint does.
  3. Authentication: Details the credentials needed for access.
  4. Request Parameters: Lists the parameters that can be sent with the request, including their types and descriptions.
  5. Responses: Describes the possible responses, including success and error responses with example JSON outputs.
  6. Usage Examples: Provides practical examples of how to use the API.

// PHP example for sending SMS via API
$url = "https://ugsms.com/v1/sms/send";
$data = [
    'username' => 'your_username',
    'password' => 'your_password',
    'numbers' => '0701234567, 0712345678',
    'message_body' => 'Hello, this is a test message.'
];
$options = [
    'http' => [
        'header'  => "Content-Type: application/json\r\n",
        'method'  => 'POST',
        'content' => json_encode($data),
    ],
];
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
echo $result;

// PHP example for checking balance
$balanceUrl = "https://ugsms.com/v1/balance?username=your_username&password=your_password";
$balanceResult = file_get_contents($balanceUrl);
if ($balanceResult === FALSE) { /* Handle error */ }
$balanceData = json_decode($balanceResult, true);
echo "Current Balance: " . $balanceData['balance'];
                        
>>>>>>> 168a011 (update)