Sign in with Apple (mobile)
Access: Public, no token needed. Also requires: Account active.
Native Sign in with Apple. Verifies the identity token (signature against Apple's published keys, issuer, audience and expiry), then signs the user in and returns the same body as POST /auth/signin.
The account is matched by Apple's stable user ID first. Otherwise Apple must have shared a verified email: an existing account with that email gets Apple linked and is marked email-verified; if none exists a new account is created, already email-verified and with no password, with the requested role (TENANT by default, or AGENT, which starts with a PENDING KYC record). Apple only provides the user's name on the very first authorisation and never in the token, so the app should forward firstName and lastName then; when they are missing the first name falls back to the email's local part (not for Hide My Email relay addresses) or Apple, and the last name to User. role and the names are ignored for existing accounts.
If authorizationCode is sent and the server has an Apple key configured, it is exchanged for an Apple refresh token that is stored so the link can be revoked when the account is deleted; a failure there is logged and does not block sign-in. A session record is stored for the device (device name and browser are derived from the User-Agent header, location is the first X-Forwarded-For address or the request IP); only the 10 most recent sessions are kept. The account holds one refresh token, so signing in overwrites the previous one and refresh tokens issued to other devices stop working. If the account already had at least one session, a new_device_login notification ("New Login Detected") is created: it is delivered over the notifications:new socket event and as a push only if the user's systemUpdates.inApp preference is on (off by default), and by email if systemUpdates.email is on (on by default). Accounts created this way have no avatar, so user.avatar is omitted.
application/json- body
identityToken*stringThe identity token (JWT) returned by Sign in with Apple on the device.
authorizationCode?|The one-time authorisation code from the same Apple response. Optional; may be empty or null.
firstName?|Given name from Apple's first-authorisation response. Optional, up to 100 characters; only used when the account is created.
length <= 100lastName?|Family name from Apple's first-authorisation response. Optional, up to 100 characters; only used when the account is created.
length <= 100role?stringAccount type to create if this Apple ID is new: TENANT (default) or AGENT. Ignored when the account already exists.
"TENANT""AGENT"Signed in (existing, newly linked or newly created account)
application/json- response
status*integersuccess*booleanmessage*stringdata*curl -X POST 'http://localhost:4000/api/v1/auth/apple/native' \ -H 'Content-Type: application/json' \ -d '{ "identityToken": "eyJraWQiOiJXNldjT0tCIiwiYWxnIjoiUlMyNTYifQ...", "authorizationCode": "c6a1f2b3d4e5f67890ab.0.rrtw.Xy1Zq2Wv3Ut4Sr5Qp6On7M", "firstName": "Adaeze", "lastName": "Okonkwo", "role": "TENANT"}'{ "status": 200, "success": true, "message": "Apple sign-in successful.", "data": { "accessToken": "eyJhbGciOiJIUzI1NiIs...", "refreshToken": "eyJhbGciOiJIUzI1NiIs...", "user": { "id": "665f1c2e9b1d4a0012ab34cd", "firstName": "Adaeze", "lastName": "Okonkwo", "email": "adaeze.okonkwo@icloud.com", "role": "TENANT", "isKYCVerified": false } }}