OverviewQuickstartREST APIMCP serverPlaywrightTypeScript SDK
Humanless/Docs/REST API reference

REST API reference

The Humanless REST API has five endpoints under https://api.usehumanless.com/v1. They create an identity (email inbox, SMS number, TOTP secret), wait for the next message, read the current TOTP code, read the identity and delete it. Requests and responses are JSON, and every error has a stable machine-readable code.

Basics

json
{
  "error": {
    "code": "channel_not_enabled",
    "message": "This identity was not created with the sms channel"
  }
}

Some errors also include error.details, for example quota numbers and a billing_url. When a Retry-After header is present, wait that many seconds before retrying.

Endpoints

MethodPathWhat it does
POST/v1/identitiesCreate an identity
GET/v1/identities/:idRead an identity
GET/v1/identities/:id/waitLong-poll for the next email or SMS
GET/v1/identities/:id/totpCurrent TOTP code
DELETE/v1/identities/:idDelete an identity (idempotent)

The Identity object

FieldTypeNotes
identity_idstring (UUID)Use it in every other call
channelsarray of "email", "sms", "totp"The channels this identity was created with
emailstring or nullDisposable address, set when email is enabled
phonestring or nullE.164 US number (+1...), set when sms is enabled. Receive-only
totp_secretstring or nullBase32 secret (32 chars), set when totp is enabled. Enter it where the app says "can't scan the QR code?"
status"active", "deleted" or "expired"
expires_atISO 8601 stringWhen the identity expires automatically
created_atISO 8601 string
ended_atISO 8601 string or nullWhen it was deleted or expired

The Message object

FieldTypeNotes
type"otp", "magic_link" or "raw"otp: a code was found (and url may also be set). magic_link: only a link was found. raw: neither was found, so read raw_snippet
codestring or nullThe extracted one-time code
urlstring or nullThe extracted verification or sign-in link
channel"email" or "sms"
senderstringEmail From or the SMS sender number
subjectstring or nullEmail subject. null for SMS
received_atISO 8601 string
raw_snippetstringThe first 280 characters of the message as plain text

POST /v1/identities

Creates a new identity.

Body

FieldTypeDefaultNotes
channelsarray of "email", "sms", "totp" (1 to 3)["email"]sms needs a paid plan or prepaid credits
ttl_secondspositive integer3600 (1 hour)Maximum 86400 (24 hours)
domainstringYour account's default domain, otherwise the platform domainEmail domain to use. It must be a platform domain or one of your verified domains, and only works with the email channel
bash
curl -s -X POST https://api.usehumanless.com/v1/identities \
  -H "Authorization: Bearer $HUMANLESS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"channels":["email","sms","totp"],"ttl_seconds":900}'

Response 201 Created: an Identity.

SMS numbers. Each paid account has dedicated US numbers: 1 on Builder, 5 on Pro, and extra or pay-as-you-go numbers paid from credits. They are never shared with other customers. An SMS identity holds one of your numbers until it is deleted or expires. After that, the number has a short cooldown (about 30 seconds) before the next SMS identity can use it. If every number is held by a live identity, you get 409 all_numbers_busy.

Errors: 400 invalid_request, 400 invalid_domain, 402 payment_required, 402 sms_quota_exceeded, 409 all_numbers_busy, 429 rate_limited, 429 sms_limit_reached, 503 numbers_provisioning, 503 phone_pool_exhausted, 503 email_domain_not_configured.

GET /v1/identities/:id/wait

Blocks until the next message for this identity arrives, then returns it. The wait is push-based, so it returns as soon as the message is received, with no polling interval.

Query parameters

ParamTypeDefaultNotes
channelany, email or smsanyOnly return messages from this channel
timeoutnumber of seconds, 0 to 6030Fractions are allowed
sinceUnix time in millisecondsnoneSee below
bash
curl -s "https://api.usehumanless.com/v1/identities/$ID/wait?channel=sms&timeout=60" \
  -H "Authorization: Bearer $HUMANLESS_API_KEY"

Response 200 OK: a Message. If no message arrives before the timeout, you get 408 timeout. Nothing is wrong, so call it again.

Consumption semantics

Server-Sent Events. Send Accept: text/event-stream to get a stream instead of JSON. The server sends one message event (data: the Message JSON) or one timeout event, then closes. It sends : ping comments every 15 seconds to keep the connection alive. A 404, 409 or 410 is returned as a normal HTTP status before the stream starts. An error that happens during the stream is sent as an error event.

bash
curl -N "https://api.usehumanless.com/v1/identities/$ID/wait?timeout=60" \
  -H "Authorization: Bearer $HUMANLESS_API_KEY" \
  -H "Accept: text/event-stream"

Proxies. The request can stay open for up to 60 seconds. If it passes through your own proxy, set its read timeout above that.

Errors: 400 invalid_request, 404 not_found, 408 timeout, 409 channel_not_enabled (for example channel=sms on an email-only identity), 410 identity_ended.

GET /v1/identities/:id/totp

Returns the current 6-digit code for the identity's TOTP secret.

json
{ "code": "159026", "seconds_remaining": 17 }

If seconds_remaining is very low (3 or less), wait for the next 30-second window before you type the code.

Errors: 404 not_found, 409 channel_not_enabled (the identity has no totp channel), 410 identity_ended.

GET /v1/identities/:id

Returns the Identity, including ones that are deleted or expired, with their status and ended_at.

Errors: 404 not_found.

DELETE /v1/identities/:id

Deletes the identity. Its email address stops receiving mail and its phone number goes back to your account. You can call it again safely: deleting an identity that is already deleted or expired returns the same result.

json
{ "identity_id": "5b0d7c1e-8f2a-4c1b-9a63-2f1d0e7c4b11", "status": "deleted" }

Errors: 404 not_found.

Error codes

StatusCodeMeaning and what to do
400invalid_requestA parameter is invalid. The message names the field
400invalid_jsonThe request body isn't valid JSON
400invalid_domaindomain is not a platform domain or one of your verified domains. Omit it to use the default
401unauthorizedMissing, malformed or revoked API key
402payment_requiredSMS needs Builder, Pro or prepaid credits. Use email or totp, or upgrade
402sms_quota_exceededThe included SMS are used up and your credits can't pay for more. details includes credit_balance_cents and billing_url. Existing SMS identities keep receiving
404not_foundUnknown identity, or it belongs to another account
404route_not_foundNo such API route
408timeoutNo message arrived before timeout. Wait again
409channel_not_enabledThe identity wasn't created with that channel
409all_numbers_busyEvery dedicated number is held by a live identity. Delete the ones you've finished with, then retry
410identity_endedThe identity was deleted or expired. Create a new one
429rate_limitedToo many requests. Honor Retry-After
429sms_limit_reachedYou've hit the daily limit on SMS identities. Honor Retry-After or use email
500internal_errorUnexpected server error
503numbers_provisioningYour dedicated numbers are still being set up after an upgrade. Honor Retry-After (30 s)
503phone_pool_exhaustedNo numbers are available right now. Retry later
503email_domain_not_configuredNo email domain is configured on the server. Retrying won't help, so contact support

Rate limits

Limits apply per API key per minute. Every response includes X-RateLimit-Limit and X-RateLimit-Remaining. A 429 also includes X-RateLimit-Reset and Retry-After.

PlanAPI requests per key per minuteIdentities created per account per hourSMS identities per account per day
Free and pay-as-you-go12030100
Builder600300200
Pro1,8001,0001,000

These are the current defaults and may change. Email hello@usehumanless.com if you need higher limits.

Python example

There's no Python SDK. The API is plain HTTP:

python
import os, time, requests

API = "https://api.usehumanless.com/v1"
H = {"Authorization": f"Bearer {os.environ['HUMANLESS_API_KEY']}"}

me = requests.post(f"{API}/identities", headers=H, json={"channels": ["email"]}).json()
since = int(time.time() * 1000)
# ... submit me["email"] in the app you're testing ...
r = requests.get(f"{API}/identities/{me['identity_id']}/wait",
                 headers=H, params={"channel": "email", "timeout": 60, "since": since})
if r.status_code == 408:
    raise TimeoutError("no code yet: wait again")
print(r.json()["code"])
requests.delete(f"{API}/identities/{me['identity_id']}", headers=H)