Guide · updated November 2026

Receive SMS verification codes with PHP

By the Noir SMS team3 min read

Quick answer

PHP's cURL extension is enough to use the Noir SMS API. Send a POST to /api/v1/numbers with your Bearer key and a JSON body with service and country, then poll GET /api/v1/numbers/{id} until status is received. The SMS code is in sms[0].code. Unused numbers are refunded automatically, and you can cancel after 2 minutes.

Many SMS panels and reseller sites run on PHP. This helper shows the full flow with cURL and no framework.

The helper

php
<?php
$api = 'https://noirsms.com/api/v1';
$key = getenv('NOIRSMS_KEY');

function noir($method, $path, $body = null) {
    global $api, $key;
    $ch = curl_init($api . $path);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => ["Authorization: Bearer $key", 'Content-Type: application/json'],
        CURLOPT_POSTFIELDS => $body ? json_encode($body) : null,
    ]);
    $res = json_decode(curl_exec($ch), true);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if ($status >= 400) throw new Exception($res['error']['code'] ?? 'http_' . $status);
    return $res;
}

$n = noir('POST', '/numbers', ['service' => 'go', 'country' => 'ca']);
echo "Number: {$n['phone']}\n";
for ($i = 0; $i < 300; $i++) {
    $s = noir('GET', '/numbers/' . $n['id']);
    if ($s['status'] === 'received') { echo "Code: {$s['sms'][0]['code']}\n"; break; }
    if (in_array($s['status'], ['canceled', 'expired'])) break;
    sleep(4);
}

Inside a web panel

  • Don't hold a web request open for minutes. Create the order, return, and let a cron job or webhook update the code.
  • Store the number id, status and code in your database.
  • Show customers your own price; your cost comes from GET /services.

Use it responsibly

Use the API only for your own legitimate accounts or apps you're authorized to test, and make sure your customers follow the same Acceptable Use Policy.

Frequently asked questions

Which PHP version do I need?

Any supported PHP version with the cURL and JSON extensions.

Can I use Guzzle?

Yes. The API is standard REST, so any HTTP client works.

Services in this guide

Keep reading

Ready to receive your code?

Create a free account, add funds from $5 and get your first verification code in under a minute.