QueryFind or create user by phone number

Find or create user by phone number

Looks up a user by their phone number in D1. If none matches, creates the user in both D1 (read model) and the UserAggregate (event sourcing) — the same find-or-create behaviour as /users/by-email — storing the phone number on the new D1 row. A user can have a phone number, an email, or both: pass email to also record one. Idempotent.

curl -X GET "https://api.spkey.co/users/by-phone?phoneNumber=%2B1-555-0123&email=user%40example.com&uuid=example_string" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN (JWT)" \
  -H "X-API-Key: YOUR_API_KEY"
{
  "uuid": "example_string",
  "email": "null",
  "phoneNumber": "null",
  "created_at": "example_string"
}
GET
/users/by-phone
GET
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token (JWT)
Bearer Tokenstring
Required

JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.

JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.
API Key (header: X-API-Key)
X-API-Keystring
Required

API key for B2B organization access. Provided during organization onboarding.

API key for B2B organization access. Provided during organization onboarding.
query
phoneNumberstring
Required

Phone number to look up (exact match)

Min length: 1
query
emailstring

Optional email to also set on the user when one is created. A user can have a phone number, an email, or both — omitting this still creates a phone-only user on a miss.

query
uuidstring

Optional UUID to assign when creating a new user (must not already exist)

Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token (JWT). JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.

header
X-API-Keystring
Required

API Key for authentication. API key for B2B organization access. Provided during organization onboarding.

Query Parameters

phoneNumberstring
Required

Phone number to look up (exact match)

emailstring

Optional email to also set on the user when one is created. A user can have a phone number, an email, or both — omitting this still creates a phone-only user on a miss.

uuidstring

Optional UUID to assign when creating a new user (must not already exist)

Responses

uuidstring
Required
emailstring,null
Required
phoneNumberstring,null
Required
created_atstring
Required