Webhooks 事件
本指南列出不同的 Logto Webhook 事件,並說明每個事件發生的時機。
使用者互動 Hook 事件
| 事件類型 | 說明 |
|---|---|
| PostRegister | 使用者透過 UI 介面成功建立新帳號。 |
| PostSignIn | 使用者透過 UI 介面成功登入。 |
| PostResetPassword | 使用者透過「忘記密碼」流程成功重設密碼。 |
資料變更 Hook 事件
使用者
| 事件類型 | 說明 |
|---|---|
| User.Created | 建立新使用者帳號。 |
| User.Deleted | 刪除使用者帳號。 |
| User.Data.Updated | 更新使用者個人資料,例如電子郵件、頭像、custom.data、社交識別碼等。 |
| User.SuspensionStatus.Updated | 使用者停權狀態變更(停權或重新啟用)。 |
角色 (Role)
| 事件類型 | 說明 |
|---|---|
| Role.Created | 建立新角色。 |
| Role.Deleted | 刪除角色。 |
| Role.Data.Updated | 更新角色資料,例如角色名稱、描述、預設角色狀態。 |
| Role.Scopes.Updated | 新增或移除指派給角色的權限。 |
權限(Scope)
| 事件類型 | 說明 |
|---|---|
| Scope.Created | 建立新的 API 權限。 |
| Scope.Deleted | 刪除 API 權限。 |
| Scope.Data.Updated | 更新 API 權限資料,例如權限描述。 |
組織 (Organization)
| 事件類型 | 說明 |
|---|---|
| Organization.Created | 建立新組織。 |
| Organization.Deleted | 刪除組織。 |
| Organization.Data.Updated | 更新組織資料,例如組織名稱、描述、custom.data 等。 |
| Organization.Membership.Updated | 新增或移除組織中的使用者或應用程式。Payload 包含 membership delta fields。 |
組織角色 (Organization role)
| 事件類型 | 說明 |
|---|---|
| OrganizationRole.Created | 建立新組織角色。 |
| OrganizationRole.Deleted | 刪除組織角色。 |
| OrganizationRole.Data.Updated | 更新組織角色資料,例如組織角色名稱與描述。 |
| OrganizationRole.Scopes.Updated | 新增或移除指派給組織角色的權限。 |
組織權限(Scope)
| 事件類型 | 說明 |
|---|---|
| OrganizationScope.Created | 建立新組織權限。 |
| OrganizationScope.Deleted | 刪除組織權限。 |
| OrganizationScope.Data.Updated | 更新組織權限資料,例如組織權限描述。 |
Management API 觸發事件
| API endpoint | 事件 |
|---|---|
| POST /users | User.Created |
| DELETE /users/:userId | User.Deleted |
| PATCH /users/:userId | User.Data.Updated |
| PATCH /users/:userId/custom-data | User.Data.Updated |
| PATCH /users/:userId/profile | User.Data.Updated |
| PATCH /users/:userId/password | User.Data.Updated |
| PATCH /users/:userId/is-suspended | User.SuspensionStatus.Updated |
| POST /roles | Role.Created, (Role.Scopes.Update) |
| DELETE /roles/:id | Role.Deleted |
| PATCH /roles/:id | Role.Data.Updated |
| POST /roles/:id/scopes | Role.Scopes.Updated |
| DELETE /roles/:id/scopes/:scopeId | Role.Scopes.Updated |
| POST /resources/:resourceId/scopes | Scope.Created |
| DELETE /resources/:resourceId/scopes/:scopeId | Scope.Deleted |
| PATCH /resources/:resourceId/scopes/:scopeId | Scope.Data.Updated |
| POST /organizations | Organization.Created |
| DELETE /organizations/:id | Organization.Deleted |
| PATCH /organizations/:id | Organization.Data.Updated |
| PUT /organizations/:id/users | Organization.Membership.Updated |
| POST /organizations/:id/users | Organization.Membership.Updated |
| DELETE /organizations/:id/users/:userId | Organization.Membership.Updated |
| PUT /organizations/:id/applications | Organization.Membership.Updated |
| POST /organizations/:id/applications | Organization.Membership.Updated |
| DELETE /organizations/:id/applications/:applicationId | Organization.Membership.Updated |
| PUT /organization-invitations/:id/status (Accepted) | Organization.Membership.Updated |
| POST /organization-roles | OrganizationRole.Created, (OrganizationRole.Scopes.Updated) |
| DELETE /organization-roles/:id | OrganizationRole.Deleted |
| PATCH /organization-roles/:id | OrganizationRole.Data.Updated |
| POST /organization-scopes | OrganizationScope.Created |
| DELETE /organization-scopes/:id | OrganizationScope.Deleted |
| PATCH /organization-scopes/:id | OrganizationScope.Data.Updated |
| PUT /organization-roles/:id/scopes | OrganizationRole.Scopes.Updated |
| POST /organization-roles/:id/scopes | OrganizationRole.Scopes.Updated |
| DELETE /organization-roles/:id/scopes/:organizationScopeId | OrganizationRole.Scopes.Updated |
Experience API 觸發事件
| 使用者互動行為 | 事件 |
|---|---|
| 使用者綁定電子郵件 / 電話 | User.Data.Updated |
| 使用者綁定 MFA | User.Data.Updated |
| 使用者綁定社交 / SSO | User.Data.Updated |
| 使用者重設密碼 | User.Data.Updated |
| 使用者註冊 | User.Created |
| 使用者透過 即時佈建 (Just-in-Time provisioning)(符合電子郵件網域或企業級 SSO 連接器)自動加入組織 | Organization.Membership.Updated |
例外 Hook 事件
安全性
| 事件類型 | 說明 |
|---|---|
| Identifier.Lockout | 使用者帳號因連續身分驗證失敗而被鎖定。可於下列流程觸發:
|
| Message.RateLimited | 終端使用者超過每收件人 發送速率限制 的驗證碼發送次數。僅於終端使用者發送路徑(Experience API 與 Account API)觸發,payload 為 { action, recipient }。 |
常見問題
PostRegister 與 User.Created 有什麼不同?
PostRegister 與 User.Created 有什麼不同?PostRegister 於使用者透過註冊流程成功建立新帳號時觸發;User.Created 則於透過 Management API 建立新使用者帳號時觸發。