LOCALHOST
All pages
API reference

Phone-auth

Every call needs Authorization: Bearer lh_… unless marked No key needed; the example uses $API for https://api.localhost.co.zw and $LH_API_KEY for your key. A * marks a required field.

#

Apps

phone_auth:read

GET /phone-auth/apps

The account's Phone Auth apps: the id to pass as `app`, the name in the text, the sender, the code's length.

Responses

  • 200 list[AppOut]
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/phone-auth/apps" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Send

phone_auth:write Idempotency-Key

POST /phone-auth/send

Text a code to a Zimbabwe mobile number. One per number per minute; it lasts the app's minutes (5 by default),
can be tried 5 times and works once. 402 when the account's SMS credits have run out.

Request body SendIn

NameTypeNotes
phone * string
app string default ""
reference string default ""

Responses

  • 202 SendOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/phone-auth/send" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Idempotency-Key: <a fresh unique string>" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "<phone>"
  }'
#

Verify

phone_auth:write

POST /phone-auth/verify

Is this the code we sent? Give the id from /send, or the phone number (the latest code to it from this app).

Request body VerifyIn

NameTypeNotes
code * string
id string default ""
phone string default ""
app string default ""

Responses

  • 200 VerifyOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/phone-auth/verify" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "<code>"
  }'

Shapes

The objects these endpoints send and receive.

AppOut

NameTypeNotes
id * string
name * string
sender * string
digits * integer
expires_in * integer

SendIn

NameTypeNotes
phone * string
app string default ""
reference string default ""

SendOut

NameTypeNotes
id * string
to * string
sender * string
expires_in * integer

VerifyIn

NameTypeNotes
code * string
id string default ""
phone string default ""
app string default ""

VerifyOut

NameTypeNotes
valid * boolean
reason string default ""