You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor: update account api docs
Update Account API and custom domain docs
* chore: update
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* chore: update
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* chore: update user data structure
Add Collect user profile and Account API information into "User data structure > Custom data" docs
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@@ -128,9 +130,9 @@ The response fields may vary depending on the account center settings.
128
130
129
131
### Update basic account information \{#update-basic-account-information}
130
132
131
-
Basic account information includes the username, name, avatar, and profile.
133
+
Basic account information includes the username, name, avatar, custom data, and other profile information.
132
134
133
-
To update username, name, and avatar, you can use the `PATCH /api/my-account` endpoint.
135
+
To update **username, name, avatar, and customData**you can use the [`PATCH /api/my-account`](https://openapi.logto.io/operation/operation-updateprofile) endpoint.
To update profile, you can use the `PATCH /api/my-account/profile` endpoint.
144
+
To update other profile information, including **familyName, givenName, middleName, nickname, profile (profile page URL), website, gender, birthdate, zoneinfo, locale, and address**, you can use the [`PATCH /api/my-account/profile`](https://openapi.logto.io/operation/operation-updateotherprofile) endpoint.
@@ -154,11 +156,9 @@ For security reasons, the Account API requires an additional layer of authorizat
154
156
155
157
### Get a verification record id \{#get-a-verification-record-id}
156
158
157
-
First, you need to get a verification record ID. This can be used to verify the user's identity when updating identifiers.
158
-
159
-
To get a verification record ID, you can verify the user's password or send a verification code to the user's email or phone.
159
+
First, you need to get a **verification record ID** with a 10-minute expiration (TTL). This can be used to verify the user's identity before updating sensitive information. This means once a user successfully verifies their identity via password, email verification code, or SMS verification code, they have 10 minutes to update their authentication-related data, including identifiers, credentials, social account linking, and MFA.
160
160
161
-
To learn more about verifications, please refer to [Security verification by Account API](/end-user-flows/security-verification).
161
+
To get a verification record ID, you can [verify the user's password](#verify-the-users-password) or [send a verification code to the user's email or phone](#verify-by-sending-a-verification-code-to-the-users-email-or-phone).
162
162
163
163
#### Verify the user's password \{#verify-the-users-password}
164
164
@@ -213,13 +213,15 @@ curl -X POST https://[tenant-id].logto.app/api/verifications/verification-code/v
213
213
214
214
After verifying the code, you can now use the verification record ID to update the user's identifier.
215
215
216
+
To learn more about verifications, please refer to [Security verification by Account API](/end-user-flows/security-verification).
217
+
216
218
### Send request with verification record id \{#send-request-with-verification-record-id}
217
219
218
220
When sending a request to update the user's identifier, you need to include the verification record ID in the request header with the `logto-verification-id` field.
To update the user's password, you can use the `POST /api/my-account/password` endpoint.
224
+
To update the user's password, you can use the [`POST /api/my-account/password`](https://openapi.logto.io/operation/operation-updatepassword) endpoint.
223
225
224
226
```bash
225
227
curl -X POST https://[tenant-id].logto.app/api/my-account/password \
@@ -237,7 +239,7 @@ To use this method, you need to [configure the email connector](/connectors/emai
237
239
238
240
To update or link a new email, you should first prove the ownership of the email.
239
241
240
-
Call the `POST /api/verifications/verification-code` endpoint to request a verification code.
242
+
Call the [`POST /api/verifications/verification-code`](https://openapi.logto.io/operation/operation-createverificationbyverificationcode) endpoint to request a verification code.
241
243
242
244
```bash
243
245
curl -X POST https://[tenant-id].logto.app/api/verifications/verification-code \
@@ -255,7 +257,7 @@ curl -X POST https://[tenant-id].logto.app/api/verifications/verification-code/v
After verifying the code, you can now update the user's email, set the `verificationId` to the request body as `newIdentifierVerificationRecordId`.
260
+
After verifying the code, you can now call [`PATCH /api/my-account/primary-email`](https://openapi.logto.io/operation/operation-updateprimaryemail) to update the user's email, set the `verificationId` to the request body as `newIdentifierVerificationRecordId`.
259
261
260
262
```bash
261
263
curl -X POST https://[tenant-id].logto.app/api/my-account/primary-email \
@@ -267,7 +269,7 @@ curl -X POST https://[tenant-id].logto.app/api/my-account/primary-email \
267
269
268
270
### Remove the user's email \{#remove-the-users-email}
269
271
270
-
To remove the user's email, you can use the `DELETE /api/my-account/primary-email` endpoint.
272
+
To remove the user's email, you can use the [`DELETE /api/my-account/primary-email`](https://openapi.logto.io/operation/operation-deleteprimaryemail) endpoint.
To use this method, you need to [configure the SMS connector](/connectors/sms-connectors/), and make sure the `BindNewIdentifier` template is configured.
282
284
:::
283
285
284
-
Similar to updating email, you can use the `PATCH /api/my-account/primary-phone` endpoint to update or link a new phone. And use the `DELETE /api/my-account/primary-phone` endpoint to remove the user's phone.
286
+
Similar to updating email, you can use the [`PATCH /api/my-account/primary-phone`](https://openapi.logto.io/operation/operation-updateprimaryphone) endpoint to update or link a new phone. And use the [`DELETE /api/my-account/primary-phone`](https://openapi.logto.io/operation/operation-deleteprimaryphone) endpoint to remove the user's phone.
285
287
286
288
### Link a new social connection \{#link-a-new-social-connection}
287
289
288
-
To link a new social connection, first you should request an authorization URL:
290
+
To link a new social connection, first you should request an authorization URL with [`POST /api/verifications/social`](https://openapi.logto.io/operation/operation-createverificationbysocial).
289
291
290
292
```bash
291
293
curl -X POST https://[tenant-id].logto.app/api/verifications/social \
@@ -300,7 +302,7 @@ curl -X POST https://[tenant-id].logto.app/api/verifications/social \
300
302
301
303
In the response, you will find a `verificationRecordId`, keep it for later use.
302
304
303
-
After the user authorizes the application, you will receive a callback at the `redirectUri` with the `state` parameter. Then you can use the `POST /api/verifications/social/verify` endpoint to verify the social connection.
305
+
After the user authorizes the application, you will receive a callback at the `redirectUri` with the `state` parameter. Then you can use the [`POST /api/verifications/social/verify`](https://openapi.logto.io/operation/operation-verifyverificationbysocial) endpoint to verify the social connection.
304
306
305
307
```bash
306
308
curl -X POST https://[tenant-id].logto.app/api/verifications/social/verify \
@@ -311,7 +313,7 @@ curl -X POST https://[tenant-id].logto.app/api/verifications/social/verify \
311
313
312
314
The `connectorData` is the data returned by the social connector after the user authorizes the application, you need to parse and get the query parameters from the `redirectUri` in your callback page, and wrap them as a JSON as the value of the `connectorData` field.
313
315
314
-
Finally, you can use the `POST /api/my-account/identities` endpoint to link the social connection.
316
+
Finally, you can use the [`POST /api/my-account/identities`](https://openapi.logto.io/operation/operation-adduseridentities) endpoint to link the social connection.
315
317
316
318
```bash
317
319
curl -X POST https://[tenant-id].logto.app/api/my-account/identities \
@@ -323,7 +325,7 @@ curl -X POST https://[tenant-id].logto.app/api/my-account/identities \
323
325
324
326
### Remove a social connection \{#remove-a-social-connection}
325
327
326
-
To remove a social connection, you can use the `DELETE /api/my-account/identities` endpoint.
328
+
To remove a social connection, you can use the [`DELETE /api/my-account/identities`](https://openapi.logto.io/operation/operation-deleteidentity) endpoint.
@@ -338,27 +340,36 @@ Remember to [enable MFA and WebAuthn](/end-user-flows/mfa) first.
338
340
:::
339
341
340
342
:::note
341
-
To use this method, you need to enable the `mfa` field in the account center settings.
343
+
To use this method, you need to enable the `mfa` field in the [account center settings](#how-to-enable-account-api).
342
344
:::
343
345
344
-
**Step 0: Add your front-end app origin to the related origins.**
346
+
**Step 1: Add your front-end app origin to the related origins**
345
347
346
-
A passkey in Browser is linked to a specific hostname (RP ID), and only the origin of the RP ID can be used to register or verify a passkey. However, your front-end app which is sending the request to the Account API is not the same as Logto's sign-in page, so you need to add your front-end app origin to the related origins list. This will allow your front-end app to register and verify a passkey under other RP IDs.
348
+
WebAuthn passkeys are bound to a specific hostname called the **Relying Party ID (RP ID)**. Only applications hosted on the RP ID's origin can register or authenticate with those passkeys.
347
349
348
-
By default, Logto will set the RP ID to the tenant domain, for example, if your tenant domain is `https://example.logto.app`, the RP ID will be `example.logto.app`. If you are using a custom domain, the RP ID will be the custom domain, for example, if your custom domain is `https://auth.example.com`, the RP ID will be `auth.example.com`.
350
+
Since your front-end application calls the Account API from a different domain than Logto's authentication pages, you need to configure **Related Origins** to allow cross-origin passkey operations.
349
351
350
-
Now, let's add your front-end app origin to the related origins, for example, if your front-end app origin is `https://account.example.com`:
352
+
**How Logto determines the RP ID:**
353
+
354
+
-**Default setup**: If you only use Logto's default domain `https://[tenant-id].logto.app`, the RP ID is `[tenant-id].logto.app`
355
+
-**Custom domain**: If you've configured a [custom domain](/logto-cloud/custom-domain) like `https://auth.example.com`, the RP ID becomes `auth.example.com`
356
+
357
+
**Configure Related Origins:**
358
+
359
+
Use the [`PATCH /api/account-center`](https://openapi.logto.io/operation/operation-updateaccountcentersettings) endpoint to add your front-end application's origin. For example, if your app's account center runs on `https://account.example.com`:
To learn more about the related origins, please refer to [Related Origin Requests](https://passkeys.dev/docs/advanced/related-origins/) documentation.
360
369
361
-
**Step 1: request new registration options.**
370
+
**Step 2: Request new registration options**
371
+
372
+
Use the [`POST /api/verifications/web-authn/registration`](https://openapi.logto.io/operation/operation-generatewebauthnregistrationoptions) endpoint to request registration for a new passkey. Logto allows each user account to register multiple passkeys.
362
373
363
374
```bash
364
375
curl -X POST https://[tenant-id].logto.app/api/verifications/web-authn/registration \
@@ -376,7 +387,7 @@ You'll get a response like:
376
387
}
377
388
```
378
389
379
-
**Step 2: register the passkey in local browser.**
390
+
**Step 3: Register the passkey in local browser**
380
391
381
392
Take [`@simplewebauthn/browser`](https://simplewebauthn.dev/) as an example, you can use the `startRegistration` function to register the passkey in local browser.
Use the [`POST /api/verifications/web-authn/registration/verify`](https://openapi.logto.io/operation/operation-verifywebauthnregistration) endpoint to verify the passkey registration.
407
+
408
+
This step verifies the cryptographic signature generated by the authenticator to ensure the passkey was legitimately created and hasn't been tampered with during transmission.
394
409
395
410
```bash
396
411
curl -X POST https://[tenant-id].logto.app/api/verifications/web-authn/registration/verify \
@@ -402,7 +417,9 @@ curl -X POST https://[tenant-id].logto.app/api/verifications/web-authn/registrat
402
417
-`payload`: The response from the local browser in step 2.
403
418
-`verificationRecordId`: The verification record ID returned by the server in step 1.
404
419
405
-
**Step 4: finally, you can link the passkey.**
420
+
**Step 5: Link the passkey**
421
+
422
+
Finally, you can link the passkey to the user's account using the [`POST /api/my-account/mfa-verifications`](https://openapi.logto.io/operation/operation-addmfaverification) endpoint.
406
423
407
424
```bash
408
425
curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications \
@@ -416,9 +433,9 @@ curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications \
416
433
-`type`: the type of the MFA factor, currently only `WebAuthn` is supported.
417
434
-`newIdentifierVerificationRecordId`: the verification record ID returned by the server in step 1.
To manage an existing WebAuthn passkey, you can use the `GET /api/my-account/mfa-verifications` endpoint to get current passkeys and other MFA verification factors.
438
+
To manage existing WebAuthn passkeys, you can use the [`GET /api/my-account/mfa-verifications`](https://openapi.logto.io/operation/operation-getmfaverifications) endpoint to get current passkeys and other MFA verification factors.
@@ -445,7 +462,7 @@ The response body would be like:
445
462
-`name`: the name of the passkey, optional field.
446
463
-`agent`: the user agent of the passkey.
447
464
448
-
Update the passkey name:
465
+
Update the passkey name using [`PATCH /api/my-account/mfa-verifications/{verificationId}/name`](https://openapi.logto.io/operation/operation-updatemfaverificationname) endpoint:
Delete the passkey using [`DELETE /api/my-account/mfa-verifications/{verificationId}`](https://openapi.logto.io/operation/operation-deletemfaverification) endpoint:
@@ -470,10 +487,12 @@ Remember to [enable MFA and TOTP](/end-user-flows/mfa) first.
470
487
:::
471
488
472
489
:::note
473
-
To use this method, you need to enable the `mfa` field in the account center settings.
490
+
To use this method, you need to enable the `mfa` field in the [account center settings](#how-to-enable-account-api).
474
491
:::
475
492
476
-
**Step 1: Generate a TOTP secret.**
493
+
**Step 1: Generate a TOTP secret**
494
+
495
+
Use the [`POST /api/my-account/mfa-verifications/totp-secret/generate`](https://openapi.logto.io/operation/operation-generatetotpsecret) endpoint to generate a TOTP secret.
477
496
478
497
```bash
479
498
curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications/totp-secret/generate \
@@ -489,7 +508,7 @@ The response body would be like:
489
508
}
490
509
```
491
510
492
-
**Step 2: Display the TOTP secret to the user.**
511
+
**Step 2: Display the TOTP secret to the user**
493
512
494
513
Use the secret to generate a QR code or display it directly to the user. The user should add it to their authenticator app (such as Google Authenticator, Microsoft Authenticator, or Authy).
After the user has added the secret to their authenticator app, they need to verify it and bind it to their account:
529
+
After the user has added the secret to their authenticator app, they need to verify it and bind it to their account. Use the [`POST /api/my-account/mfa-verifications`](https://openapi.logto.io/operation/operation-addmfaverification) endpoint to bind the TOTP factor.
511
530
512
531
```bash
513
532
curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications \
@@ -532,10 +551,12 @@ Remember to [enable MFA and backup codes](/end-user-flows/mfa) first.
532
551
:::
533
552
534
553
:::note
535
-
To use this method, you need to enable the `mfa` field in the account center settings.
554
+
To use this method, you need to enable the `mfa` field in the [account center settings](#how-to-enable-account-api).
536
555
:::
537
556
538
-
**Step 1: Generate new backup codes:**
557
+
**Step 1: Generate new backup codes**
558
+
559
+
Use the [`POST /api/my-account/mfa-verifications/backup-codes/generate`](https://openapi.logto.io/operation/operation-generatemyaccountbackupcodes) endpoint to generate a new set of 10 backup codes.
539
560
540
561
```bash
541
562
curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications/backup-codes/generate \
@@ -551,9 +572,8 @@ The response body would be like:
551
572
}
552
573
```
553
574
554
-
**Step 2: Display backup codes to the user:**
575
+
**Step 2: Display backup codes to the user**
555
576
556
-
:::important
557
577
Before binding the backup codes to the user's account, you must display them to the user and instruct them to:
558
578
559
579
- Download or write down these codes immediately
@@ -562,9 +582,10 @@ Before binding the backup codes to the user's account, you must display them to
562
582
- Know that these codes are their last resort if they lose access to their primary MFA methods
563
583
564
584
You should display the codes in a clear, easy-to-copy format and consider providing a download option (e.g., as a text file or PDF).
565
-
:::
566
585
567
-
**Step 3: Bind backup codes to the user account:**
586
+
**Step 3: Bind backup codes to the user account**
587
+
588
+
Use the [`POST /api/my-account/mfa-verifications`](https://openapi.logto.io/operation/operation-addmfaverification) endpoint to bind the backup codes to the user's account.
568
589
569
590
```bash
570
591
curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications \
@@ -586,7 +607,9 @@ curl -X POST https://[tenant-id].logto.app/api/my-account/mfa-verifications \
586
607
587
608
:::
588
609
589
-
**View existing backup codes:**
610
+
**View existing backup codes**
611
+
612
+
To view existing backup codes and their usage status, use the [`GET /api/my-account/mfa-verifications/backup-codes`](https://openapi.logto.io/operation/operation-getbackupcodes) endpoint:
0 commit comments