คำขอ Webhooks
เมื่อมีการปล่อยเหตุการณ์ hook ที่ถูกต้อง Logto จะค้นหา webhooks ที่เกี่ยวข้องและส่งคำขอ POST ต่อ hook config แต่ละรายการ
ส่วนหัวของคำขอ
Key | ปรับแต่งได้ | หมายเหตุ |
---|---|---|
user-agent | ✅ | ค่าเริ่มต้นคือ Logto (https://logto.io/) |
content-type | ✅ | ค่าเริ่มต้นคือ application/json |
logto-signature-sha-256 | ลายเซ็นของเนื้อหา request ดูที่ การรักษาความปลอดภัย webhook ของคุณ |
คุณสามารถเขียนทับส่วนหัวที่ปรับแต่งได้โดย ปรับแต่ง request ด้วย key เดียวกัน
เนื้อหาคำขอของเหตุการณ์ interaction hook
เหตุการณ์ที่ใช้ได้: PostRegister
, PostSignIn
, PostResetPassword
เนื้อหาคำขอเป็นวัตถุ JSON ที่มีข้อมูล 3 ประเภทดังนี้:
type UserEntity = {
id: string;
username?: string;
primaryEmail?: string;
primaryPhone?: string;
name?: string;
avatar?: string;
customData?: object;
identities?: object;
lastSignInAt?: string;
createdAt?: string;
applicationId?: string;
isSuspended?: boolean;
};
type ApplicationEntity = {
id: string;
name: string;
description?: string;
};
Field | Type | Optional | หมายเหตุ |
---|---|---|---|
hookId | string | ตัวระบุใน Logto | |
event | string | เหตุการณ์ที่เรียกใช้ hook นี้ | |
createdAt | string | เวลาสร้าง payload ในรูปแบบ ISO | |
interactionEvent | string | เหตุการณ์ interaction ที่เรียกใช้ hook นี้ | |
sessionId | string | ✅ | Session ID (ไม่ใช่ Interaction ID) สำหรับเหตุการณ์นี้ (ถ้ามี) |
userAgent | string | ✅ | user-agent ของคำขอที่เรียกใช้ hook นี้ |
userIp | string | ✅ | ที่อยู่ IP ของคำขอที่เรียกใช้ hook นี้ |
userId | string | ✅ | User ID ที่เกี่ยวข้องกับเหตุการณ์นี้ (ถ้ามี) |
user | UserEntity | ✅ | user entity ที่เกี่ยวข้องกับเหตุการณ์นี้ (ถ้ามี) |
applicationId | string | ✅ | Application ID ที่เกี่ยวข้องกับเหตุการณ์นี้ (ถ้ามี) |
application | ApplicationEntity | ✅ | ข้อมูลแอปพลิเคชันที่เกี่ยวข้องกับเหตุการณ์นี้ (ถ้ามี) |
ดูข้อมูลอ้างอิง ผู้ใช้ และ แอปพลิเคชัน สำหรับคำอธิบายแต่ละฟิลด์โดยละเอียด
เนื้อหาคำขอของเหตุการณ์ data mutation hook
ฟิลด์มาตรฐานของเนื้อหาคำขอ
Field | Type | Optional | หมายเหตุ |
---|---|---|---|
hookId | string | ตัวระบุใน Logto | |
event | string | เหตุการณ์ที่เรียกใช้ hook นี้ | |
createdAt | string | เวลาสร้าง payload ในรูปแบบ ISO | |
userAgent | string | ✅ | user-agent ของคำขอ |
ip | string | ✅ | ที่อยู่ IP ของคำขอ |
ฟิลด์ context body ของ Interaction API
เหตุการณ์ data mutation hook ที่ถูกเรียกโดยการเรียก API interaction ของผู้ใช้
เหตุการณ์ที่ใช้ได้: User.Created
, User.Data.Updated
Field | Type | Optional | หมายเหตุ |
---|---|---|---|
interactionEvent | string | ✅ | เหตุการณ์ interaction ที่เรียกใช้ hook นี้ |
sessionId | string | ✅ | Session ID (ไม่ใช่ Interaction ID) สำหรับเหตุการณ์นี้ (ถ้ามี) |
applicationId | string | ✅ | Application ID ที่เกี่ยวข้องกับเหตุการณ์นี้ (ถ้ามี) |
application | ApplicationEntity | ✅ | ข้อมูลแอปพลิเคชันที่เกี่ยวข้องกับเหตุการณ์นี้ (ถ้ามี) |
ฟิลด์ context body ของ Management API
เหตุการณ์ data mutation hook ที่ถูกเรียกโดยการเรียก Management API
Field | Type | Optional | หมายเหตุ |
---|---|---|---|
path | string | ✅ | path ของ API call ที่เรียกใช้ hook นี้ |
method | string | ✅ | method ของ API call ที่เรียกใช้ hook นี้ |
status | number | ✅ | รหัสสถานะตอบกลับของ API call ที่เรียกใช้ hook นี้ |
params | object | ✅ | koa path params ของ API call ที่เรียกใช้ hook นี้ |
matchedRoute | string | ✅ | koa matched route ของ API call ที่เรียกใช้ hook นี้ Logto ใช้ฟิลด์นี้เพื่อจับคู่กับเหตุการณ์ hook ที่เปิดใช้งาน |
ฟิลด์เนื้อหาข้อมูล (data payload body fields)
เหตุการณ์ผู้ใช้
Event | Field | Type | Optional | หมายเหตุ |
---|---|---|---|---|
User.Created | data | UserEntity | user entity ที่ถูกสร้างสำหรับเหตุการณ์นี้ | |
User.Data.Updated | data | UserEntity | user entity ที่ถูกอัปเดตสำหรับเหตุการณ์นี้ | |
User.Deleted | data | null | / |
เหตุการณ์บทบาท (Role events)
type Role = {
id: string;
name: string;
description: string;
type: 'User' | 'MachineToMachine';
isDefault: boolean;
};
type Scope = {
id: string;
name: string;
description: string;
resourceId: string;
createdAt: number;
};
Event | Field | Type | Optional | หมายเหตุ |
---|---|---|---|---|
Role.Created | data | Role | entity บทบาทที่ถูกสร้างสำหรับเหตุการณ์นี้ | |
Role.Data.Updated | data | Role | entity บทบาทที่ถูกอัปเดตสำหรับเหตุการณ์นี้ | |
Role.Deleted | data | null | ||
Role.Scope.Updated | data | Scope[] | scopes ที่ถูกอัปเดตและกำหนดให้กับบทบาทนี้ | |
Role.Scope.Updated | roleId | string | ✅ | role ID ที่ scopes ถูกกำหนดให้ (มีเฉพาะเมื่อเหตุการณ์ถูกเรียกโดยการสร้างบทบาทใหม่พร้อมกำหนด scopes ล่วงหน้า) |
เหตุการณ์สิทธิ์ (Permission / Scope events)
Event | Field | Type | Optional | หมายเหตุ |
---|---|---|---|---|
Scope.Created | data | Scope | entity scope ที่ถูกสร้างสำหรับเหตุการณ์นี้ | |
Scope.Data.Updated | data | Scope | entity scope ที่ถูกอัปเดตสำหรับเหตุการณ์นี้ | |
Scope.Deleted | data | null | / |
เหตุการณ์องค์กร (Organization events)
type Organization = {
id: string;
name: string;
description?: string;
customData: object;
createdAt: number;
};
Event | Field | Type | Optional | หมายเหตุ |
---|---|---|---|---|
Organization.Created | data | Organization | entity องค์กรที่ถูกสร้างสำหรับเหตุการณ์นี้ | |
Organization.Data.Updated | data | Organization | entity องค์กรที่ถูกอัปเดตสำหรับเหตุการณ์นี้ | |
Organization.Deleted | data | null | / | |
Organization.Membership.Updated | data | null | / |
เหตุการณ์ OrganizationRole
type OrganizationRole = {
id: string;
name: string;
description?: string;
};
type OrganizationScope = {
id: string;
name: string;
description?: string;
};
Event | Field | Type | Optional | หมายเหตุ |
---|---|---|---|---|
OrganizationRole.Created | data | OrganizationRole | entity บทบาทองค์กรที่ถูกสร้างสำหรับเหตุการณ์นี้ | |
OrganizationRole.Data.Updated | data | OrganizationRole | entity บทบาทองค์กรที่ถูกอัปเดตสำหรับเหตุการณ์นี้ | |
OrganizationRole.Deleted | data | null | / | |
OrganizationRole.Scope.Updated | data | null | / | |
OrganizationRole.Scope.Updated | organizationRoleId | string | ✅ | role ID ที่ scopes ถูกกำหนดให้ (มีเฉพาะเมื่อเหตุการณ์ถูกเรียกโดยการสร้างบทบาทใหม่พร้อมกำหนด scopes ล่วงหน้า) |
เหตุการณ์สิทธิ์ขององค์กร (Organization permission / OrganizationScope events)
Event | Field | Type | Optional | หมายเหตุ |
---|---|---|---|---|
OrganizationScope.Created | data | OrganizationScope | entity scope ขององค์กรที่ถูกสร้าง | |
OrganizationScope.Data.Updated | data | OrganizationScope | entity scope ขององค์กรที่ถูกอัปเดต | |
OrganizationScope.Deleted | data | null | / |