# Quick Send

{% 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`

### 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 %}

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

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

```json
{
    "status": 200,
    "message": "Message sent successfully"
}
```

{% endtab %}

{% tab title="Errors" %}

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

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.textcus.com/overview/editor/quick-send.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
