# Send SMS with PHP | VeloBotix

> PHP example for VeloBotix SEND_SINGLE using cURL, Basic Auth, and JSON body.

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

Languages

# PHP

## Prerequisites

PHP with the cURL extension enabled. Portal email, API key, and an approved senderID.

## Authentication

Pass email and API key to CURLOPT\_USERPWD (Basic Auth).

## SEND\_SINGLE example

Equivalent to the documented curl POST:

```
<?php
$email = 'YOUR_EMAIL';
$apiKey = 'YOUR_API_KEY';
$url = 'https://portal.velobotix.app/api.php?FUN=SEND_SINGLE';

$payload = json_encode([
  'senderID' => 'VeloBotix',
  'to'       => '0701234567',
  'msg'      => 'Your OTP is 483920. Valid for 5 minutes.',
]);

$ch = curl_init($url);
curl_setopt_array($ch, [
  CURLOPT_POST           => true,
  CURLOPT_POSTFIELDS     => $payload,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_USERPWD        => $email . ':' . $apiKey,
  CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $status . "\n" . $response;
```

## Common mistakes

Forgetting Content-Type: application/json.

Using an unapproved senderID.

Putting API keys in front-end or public repos.

## 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)
