AgentSkillsCN

phone-verification

通过Didit API,利用短信一次性验证码验证电话号码。适用于需要确认用户是否拥有某部电话号码、实施基于短信的双因素认证,或在注册/入职流程中对电话号码进行校验的场景。

SKILL.md
--- frontmatter
name: phone-verification
description: Verify phone numbers using SMS one-time codes via the Didit API. Use when you need to confirm a user owns a phone number, implement SMS-based 2FA, or validate phone during signup/onboarding flows.

Phone Verification

Verify phone numbers by sending SMS one-time verification codes via Didit.

Quick Start

bash
# Send verification code via SMS
orth run didit /v3/phone/send -d '{"phone_number": "+14155551234"}'

# Verify the code user provides
orth run didit /v3/phone/check -d '{"phone_number": "+14155551234", "code": "123456"}'

Workflow

1. Send Verification Code

bash
orth run didit /v3/phone/send \
  -d '{"phone_number": "+14155551234"}'

Request format:

  • Phone must be in E.164 format (e.g., +14155551234)
  • Include country code with + prefix

Response:

json
{
  "success": true,
  "message": "Verification code sent"
}

2. Verify Code

When the user provides the code they received:

bash
orth run didit /v3/phone/check \
  -d '{"phone_number": "+14155551234", "code": "123456"}'

Response (success):

json
{
  "success": true,
  "verified": true
}

Phone Number Format

Always use E.164 format:

  • US: +14155551234
  • UK: +447911123456
  • Germany: +4915123456789

Use Cases

  • User signup: Verify phone before creating account
  • SMS 2FA: Add phone-based second factor authentication
  • Account recovery: Verify ownership via SMS
  • Delivery confirmation: Confirm contact number for orders

Integration Example (TypeScript)

typescript
import Orthogonal from "@orth/sdk";

const orthogonal = new Orthogonal({
  apiKey: process.env.ORTHOGONAL_API_KEY,
});

// Send verification code via SMS
const sendResult = await orthogonal.run({
  api: "didit",
  path: "/v3/phone/send",
  body: { phone_number: "+14155551234" }
});

// Verify the code
const verifyResult = await orthogonal.run({
  api: "didit",
  path: "/v3/phone/check",
  body: { 
    phone_number: "+14155551234",
    code: "123456"
  }
});

if (verifyResult.data.verified) {
  console.log("Phone verified!");
}