# Send SMS with Java | VeloBotix

> Java HttpClient example for VeloBotix SEND_SINGLE with Basic Auth.

Source: https://www.velobotix.app/docs/java

Languages

# Java

## Prerequisites

Java 11+ (java.net.http.HttpClient). Portal credentials and approved senderID.

## Authentication

Set Authorization: Basic with Base64-encoded email:apiKey.

## SEND\_SINGLE example

Equivalent to the documented curl POST:

```
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

String email = "YOUR_EMAIL";
String apiKey = "YOUR_API_KEY";
String auth = Base64.getEncoder()
    .encodeToString((email + ":" + apiKey).getBytes(StandardCharsets.UTF_8));

String body = """
    {"senderID":"VeloBotix","to":"0701234567","msg":"Your OTP is 483920. Valid for 5 minutes."}
    """;

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://portal.velobotix.app/api.php?FUN=SEND_SINGLE"))
    .header("Authorization", "Basic " + auth)
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();

HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
```

## Common mistakes

URL-encoding issues if building the URI incorrectly.

Using a Sender ID that is not approved.

Blocking the UI thread — call the API from a backend service.

## Create account

Sign up in the portal and get your API key — username is your email, password is the key.

[Open portal — get API key](https://portal.velobotix.app)
