JavaScript
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const verification = await client.verifications.create('acct_01j9a43avnfqzbjfch6pygv1td', {
phone_number: '+18015551234',
});
console.log(verification.id);import os
from surge import Surge
client = Surge(
api_key=os.environ.get("SURGE_API_KEY"), # This is the default and can be omitted
)
verification = client.verifications.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
phone_number="+18015551234",
)
print(verification.id)package main
import (
"context"
"fmt"
"github.com/stainless-sdks/surge-go"
"github.com/stainless-sdks/surge-go/option"
)
func main() {
client := surge.NewClient(
option.WithAPIKey("My API Key"),
)
verification, err := client.Verifications.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.VerificationNewParams{
PhoneNumber: "+18015551234",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", verification.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
verification = surge.verifications.create("acct_01j9a43avnfqzbjfch6pygv1td", phone_number: "+18015551234")
puts(verification)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Surge\Client;
use Surge\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API Key');
try {
$verification = $client->verifications->create(
'acct_01j9a43avnfqzbjfch6pygv1td', phoneNumber: '+18015551234'
);
var_dump($verification);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/verifications \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number": "+18015551234"
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/verifications")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone_number\": \"+18015551234\"\n}")
.asString();{
"attempt_count": 0,
"id": "vfn_01jayh15c2f2xamftg0xpyq1nj",
"phone_number": "+18015551234",
"status": "pending"
}{
"error": {
"message": "This number has opted out of receiving verification messages. Send START to (801) 555-1234 to opt in again.",
"type": "opted_out"
}
}{
"error": {
"message": "Too many codes have been sent to this number. Please wait 10 minutes and try again.",
"type": "destination_rate_limit"
}
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Verifications
Create verification
Send a one-time passcode (OTP) to a phone number to begin the verification flow.
POST
/
accounts
/
{account_id}
/
verifications
JavaScript
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const verification = await client.verifications.create('acct_01j9a43avnfqzbjfch6pygv1td', {
phone_number: '+18015551234',
});
console.log(verification.id);import os
from surge import Surge
client = Surge(
api_key=os.environ.get("SURGE_API_KEY"), # This is the default and can be omitted
)
verification = client.verifications.create(
account_id="acct_01j9a43avnfqzbjfch6pygv1td",
phone_number="+18015551234",
)
print(verification.id)package main
import (
"context"
"fmt"
"github.com/stainless-sdks/surge-go"
"github.com/stainless-sdks/surge-go/option"
)
func main() {
client := surge.NewClient(
option.WithAPIKey("My API Key"),
)
verification, err := client.Verifications.New(
context.TODO(),
"acct_01j9a43avnfqzbjfch6pygv1td",
surge.VerificationNewParams{
PhoneNumber: "+18015551234",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", verification.ID)
}
require "surge_api"
surge = SurgeAPI::Client.new(api_key: "My API Key")
verification = surge.verifications.create("acct_01j9a43avnfqzbjfch6pygv1td", phone_number: "+18015551234")
puts(verification)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Surge\Client;
use Surge\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API Key');
try {
$verification = $client->verifications->create(
'acct_01j9a43avnfqzbjfch6pygv1td', phoneNumber: '+18015551234'
);
var_dump($verification);
} catch (APIException $e) {
echo $e->getMessage();
}curl --request POST \
--url https://api.surge.app/accounts/{account_id}/verifications \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number": "+18015551234"
}
'HttpResponse<String> response = Unirest.post("https://api.surge.app/accounts/{account_id}/verifications")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone_number\": \"+18015551234\"\n}")
.asString();{
"attempt_count": 0,
"id": "vfn_01jayh15c2f2xamftg0xpyq1nj",
"phone_number": "+18015551234",
"status": "pending"
}{
"error": {
"message": "This number has opted out of receiving verification messages. Send START to (801) 555-1234 to opt in again.",
"type": "opted_out"
}
}{
"error": {
"message": "Too many codes have been sent to this number. Please wait 10 minutes and try again.",
"type": "destination_rate_limit"
}
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The account to associate with the verification.
Example:
"acct_01j9a43avnfqzbjfch6pygv1td"
Body
application/json
Parameters for creating a Verification
The phone number to be verified. In E.164 format.
Pattern:
^\+[1-9]\d{6,14}$Example:
"+18015551234"
Response
Created verification
A phone number verification
The number of times the code has been attempted.
Unique identifier for the object.
The phone number being verified. In E.164 format.
Pattern:
^\+[1-9]\d{6,14}$Example:
"+18015551234"
The current status of the verification.
Available options:
pending, verified, exhausted, expired