Skip to main content

PHP SDK

The official Orbit PHP SDK provides a clean, fluent API for interacting with all Orbit services. Supports PHP 8.1+ with full type declarations, automatic retries, and Guzzle-based HTTP transport.

Installation

composer require devotel/orbit-php

Quick Start

<?php

use Devotel\Orbit;

$orbit = new Orbit('dv_live_sk_your_key_here');

// Send an SMS
$message = $orbit->messages->send('+14155552671', 'Hello from Orbit!', 'sms');

echo $message['data']['message_id']; // msg_abc123

Messaging

// Send WhatsApp message
$waMessage = $orbit->messages->send('+14155552671', 'Hello from Orbit on WhatsApp!', 'whatsapp');

// Send SMS shorthand
$sms = $orbit->messages->sendSms('+14155552671', 'Quick SMS hello!');

Voice

// Make an outbound call
$call = $orbit->voice->createCall('+14155552671', '+18005551234');

// Retrieve call details
$callDetails = $orbit->voice->getCall($call['data']['id']);

Verify

// Send OTP
$verification = $orbit->verify->send('+14155552671', 'sms');

// Check OTP
$result = $orbit->verify->check($verification['data']['verification_id'], '482901');

echo $result['data']['status']; // "approved"

Webhooks

use Devotel\Orbit\Webhook\WebhookVerifier;

// Laravel controller
class WebhookController extends Controller
{
    public function handle(Request $request): JsonResponse
    {
        $verifier = new WebhookVerifier('whsec_your_secret');

        $isValid = $verifier->verify(
            $request->getContent(),
            $request->header('X-Devotel-Signature'),
        );

        if (! $isValid) {
            return response()->json(['error' => 'Invalid signature'], 401);
        }

        $event = json_decode($request->getContent(), true);

        match ($event['type']) {
            'message.delivered' => $this->handleDelivery($event),
            'call.completed' => $this->handleCallComplete($event),
            default => null,
        };

        return response()->json(['received' => true]);
    }
}

Error Handling

try {
    $orbit->messages->send('invalid', 'Hi', 'sms');
} catch (\RuntimeException $e) {
    echo $e->getMessage(); // "HTTP 422: {\"error\":{\"code\":\"INVALID_PHONE_NUMBER\",...}}"
}

Configuration

$orbit = new Orbit('dv_live_sk_your_key_here');

// Or with a custom base URL
$orbit = new Orbit('dv_live_sk_your_key_here', 'https://orbit-api.devotel.io/api/v1');
OptionTypeDefaultDescription
$apiKeystringYour Devotel API key (required)
$baseUrlstringhttps://orbit-api.devotel.io/api/v1API base URL

Requirements

  • PHP 8.1 or later
  • ext-json (enabled by default)
  • guzzlehttp/guzzle (installed automatically)