> For the complete documentation index, see [llms.txt](https://developers.textcus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.textcus.com/overview/editor/quick-send.md).

# Quick Send

The HTTP API enables you to send SMS quickly. To send an SMS, simply call the following URL with the relevant parameters appended to the URL, as shown below:

{% hint style="info" %}
`https://api.textcus.com/api/v2/send?destination={recipient}&source={sender}&dlr={0}&type={0}&message={message}`
{% endhint %}

<mark style="color:red;">NB: Please remove the curly bracket in the URL when testing</mark>

## Endpoint <a href="#endpoint" id="endpoint"></a>

<mark style="color:green;">**`GET`**</mark> `https://api.textcus.com/api/v2/send`

### GET /send

```bash
curl -G https://api.textcus.com/api/v2/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "source=TextCus" \
  --data-urlencode "destination=233244000001" \
  --data-urlencode "message=Your order ORD-1042 has shipped."
```

### Headers <a href="#headers" id="headers"></a>

`Authorization: Bearer API_KEY`

## **Request Parameters**

Below is a list of parameters when issuing an HTTP Request.

<table><thead><tr><th width="226">Parameters</th><th width="160">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td>Required</td><td>It indicates the type of message.<br>Values for "type" include:<br>0 : Plain text (GSM 3.38 Character encoding)<br>1 : Flash (GSM 3.38 Character encoding)<br>2 : Unicode<br>3 : Reserved<br>5 : Plain text (ISO-8859-1 Character encoding)<br>6 : Unicode Flash<br>7 : Flash (ISO-8859-1 Character encoding)</td></tr><tr><td><code>source</code></td><td>Required</td><td>The source address that should appear in the message.<br>- Max Length of 18 if numeric.<br>- Max Length of 11 if alphanumeric.<br>To prefix the plus sign (+) to the sender’s address when the message is displayed on their mobile phone, please prefix the plus sign to your sender’s address while submitting the message.<br>Note: You need to URL encode the plus sign. The SMSC may enforce additional restrictions on this field.</td></tr><tr><td><code>destination</code></td><td>Required</td><td>Recipient phone number<br>Must be a valid MSIDSN<br>Must be in the international telephone number format (may or may not include a plus [+] sign) symbol. e.g. 233241234567 or +233241234567<br>Multiple mobile numbers need to be separated by a comma (,) (the comma should be URL encoded).</td></tr><tr><td><code>dlr</code></td><td>Required</td><td>Indicates whether the client wants a delivery report for this message.<br>The values for "dlr" include:<br>0 : No delivery report required<br>1 : Delivery report required</td></tr><tr><td><code>message</code></td><td>Required</td><td>The message to be sent. Must be URL encoded.</td></tr><tr><td><code>time</code></td><td>Optional</td><td>To schedule the message to be sent sometime or date in the future<br>Format: YYYY-MM-DD HH:MM:SS or UNIX TIMESTAMP<br>The Scheduled time must be at least 10 minutes ahead of the current time in UTC</td></tr></tbody></table>

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}

```php
<?php

$data = [
  'destination' => $recipient,
  'source' => $sender,
  'dlr' => 0,
  'type' => 0,
  'message' => $message
];

$url = 'https://api.textcus.com/api/v2/send';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY',  // Replace 'API_KEY' with your actual API key
    'Content-Type: application/json' 
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
const axios = require('axios');

const recipient = 'RECIPIENT_NUMBER'; // Replace with the recipient's phone number
const sender = 'SENDER_NAME'; // Replace with the sender name
const message = 'YOUR_MESSAGE'; // Replace with the message to be sent

const data = {
  destination: recipient,
  source: sender,
  dlr: 0,
  type: 0,
  message: message
};

const url = 'https://api.textcus.com/api/v2/send';

axios({
  method: 'get',
  url: url,
  data: data,
  headers: {
    'Authorization': 'Bearer API_KEY',  // Replace 'API_KEY' with your actual API Key
    'Content-Type': 'application/json'
  },
  timeout: 30000  // Set timeout to 30 seconds
})
  .then(response => {
    console.log(response.data);  // Handle successful response
  })
  .catch(error => {
    console.error('Error:', error.response ? error.response.data : error.message);  // Handle errors
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# Replace with your actual values
recipient = 'RECIPIENT_NUMBER'
sender = 'SENDER_NAME'
message = 'YOUR_MESSAGE'

url = 'https://api.textcus.com/api/v2/send'

params = {
    'destination': recipient,
    'source': sender,
    'dlr': 0,
    'type': 0,
    'message': message
}

headers = {
    'Authorization': 'Bearer API_KEY'
}

try:
    response = requests.get(url, params=params, headers=headers, timeout=30)

    if response.status_code == 200:
        print(response.json())
    else:
        print(f"Failed to send message. Status code: {response.status_code}")
        print(response.text)

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")
```

{% endtab %}

{% tab title="Dart" %}

```dart
import 'package:http/http.dart' as http;

void main() async {
  String recipient = 'RECIPIENT_NUMBER';
  String sender = 'SENDER_NAME';
  String message = 'YOUR_MESSAGE';

  final uri = Uri.https(
    'api.textcus.com',
    '/api/v2/send',
    {
      'destination': recipient,
      'source': sender,
      'dlr': '0',
      'type': '0',
      'message': message,
    },
  );

  try {
    final response = await http.get(
      uri,
      headers: {
        'Authorization': 'Bearer API_KEY',
      },
    );

    if (response.statusCode == 200) {
      print(response.body);
    } else {
      print('Failed to send message. Status code: ${response.statusCode}');
      print(response.body);
    }
  } catch (e) {
    print('Error: $e');
  }
}

```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;

public class SendSMS {

    public static void main(String[] args) {
        String recipient = "RECIPIENT_NUMBER"; // Replace with the recipient's phone number
        String sender = "SENDER_NAME"; // Replace with the sender name
        String message = "YOUR_MESSAGE"; // Replace with the message to be sent

        String url = "https://api.textcus.com/api/v2/send";

        Map<String, Object> data = new HashMap<>();
        data.put("destination", recipient);
        data.put("source", sender);
        data.put("dlr", 0);
        data.put("type", 0);
        data.put("message", message);

        try {
            // Convert the data map to JSON string using Jackson ObjectMapper
            ObjectMapper objectMapper = new ObjectMapper();
            String requestBody = objectMapper.writeValueAsString(data);

            // Create an HttpClient
            HttpClient client = HttpClient.newHttpClient();

            // Build the HTTP request
            HttpRequest request = HttpRequest.newBuilder()
                    .uri(URI.create(url))
                    .header("Authorization", "Bearer API_KEY")  // Replace 'API_KEY' with your actual API Key
                    .header("Content-Type", "application/json")
                    .POST(BodyPublishers.ofString(requestBody, StandardCharsets.UTF_8))
                    .build();

            // Send the request and get the response
            HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

            // Handle response
            if (response.statusCode() == 200) {
                System.out.println("Response: " + response.body());
            } else {
                System.out.println("Failed to send message. Status code: " + response.statusCode());
                System.out.println("Response: " + response.body());
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

```

{% endtab %}

{% tab title="VB.Net" %}

```vbnet
Imports System.Net.Http
Imports System.Text
Imports Newtonsoft.Json

Module SendSMS
    Sub Main()
        Dim recipient As String = "RECIPIENT_NUMBER" ' Replace with the recipient's phone number
        Dim sender As String = "SENDER_NAME" ' Replace with the sender name
        Dim message As String = "YOUR_MESSAGE" ' Replace with the message to be sent

        Dim url As String = "https://api.textcus.com/api/v2/send"

        ' Prepare the data to be sent
        Dim data As New Dictionary(Of String, Object) From {
            {"destination", recipient},
            {"source", sender},
            {"dlr", 0},
            {"type", 0},
            {"message", message}
        }

        ' Convert data to JSON string
        Dim jsonData As String = JsonConvert.SerializeObject(data)

        ' Create HttpClient
        Using client As New HttpClient()
            client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY") ' Replace 'API_KEY' with your actual API key
            client.DefaultRequestHeaders.Add("Content-Type", "application/json")

            ' Create HttpContent from JSON data
            Dim content As New StringContent(jsonData, Encoding.UTF8, "application/json")

            Try
                ' Send the POST request
                Dim response As HttpResponseMessage = client.PostAsync(url, content).Result

                ' Check the status code
                If response.IsSuccessStatusCode Then
                    ' Read the response content
                    Dim responseBody As String = response.Content.ReadAsStringAsync().Result
                    Console.WriteLine("Response: " & responseBody)
                Else
                    Console.WriteLine("Failed to send message. Status code: " & response.StatusCode)
                    Console.WriteLine("Response: " & response.Content.ReadAsStringAsync().Result)
                End If

            Catch ex As Exception
                Console.WriteLine("Error: " & ex.Message)
            End Try
        End Using
    End Sub
End Module

```

{% endtab %}
{% endtabs %}

#### How credits are counted

Credits are charged per provider-billed SMS part, per unique valid recipient:

```
credits = message_parts × recipients_submitted
```

* GSM-7 text: 160 septets for one part; long messages use 153 septets per concatenated part.
* Unicode text: 70 UTF-16 units for one part; long messages use 67 units per concatenated part.
* GSM extension characters such as `^`, `{`, `}` and `€` consume two septets.
* Failed gateway submissions are refunded by part and are excluded from `credits_used`.

For example, 460 ordinary GSM characters are four parts. Sending that message to three recipients uses `4 × 3 = 12` credits. Your per-credit rate is on the Account API as `sms_rate`.

***

## Sample Response <a href="#sample-response" id="sample-response"></a>

{% tabs %}
{% tab title="Success" %}

```json
{
    "status": true,
    "message": "Message sent successfully",
    "data": {
        "message_parts": 4,
        "recipient_count": 3,
        "submitted_count": 3,
        "failed_count": 0,
        "credits_used": 12,
        "balance": 88
    }
}
```

{% endtab %}

{% tab title="Errors" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
}, 

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}
