# Use Webhook

Webhooks allow you to monitor user registration, login and other behaviors, so as to do some custom processing.

The method of using Webhook is to configure the HTTP URL in the Authing platform. When your user logs in, registers, and changes the password, a POST request will be sent to the remote HTTP URL.

# Configure Webhook

On the Rules & Hooks-Webhooks page, you can manage your defined webhooks:

Webhook list

Click the Create button in the upper right corner to create a new Webhook to subscribe to specific events:

Configure Webhook

# Form Descriptions

Field name Description
Callback URL HTTP URL address for remotely receiving webhook events
Request Key After setting the key (the value is set by the developer), Authing will attach this key to each request (HTTP Header: X-Authing-Token), you can avoid it by verifying this key Some illegal operations
Request data format Specify the data format of the Request body when initiating a Webhook request. The optional values ​​are application/json and application/x-www-form-urlencoded
Trigger events [Please view supported events] (use-webhook.md# supported events)
Activate Whether to enable this Hook

# Debug Webhook

The newly created Hook request events are all empty, then you can click "Test" to trigger a "Test Event":

Webhook test

The requested data is:

{
    "description": "A test from Authing Webhook"
}

After the test is successful, you will see detailed request information and return information.

# Supported events

# Event list

Event Descriptions
login Login event, this event is triggered when the user logs in, regardless of whether the login is successful or not.
register Register event, this event will be triggered when a user registers or the administrator manually creates a user, whether it is successful or not, it will be triggered
user:updated Password modification event, this event is triggered when the user changes the password or the administrator manually changes the password, regardless of success or failure
mfaVerify MFA verification event, when a user logs in and triggers MFA, and enters the MFA verification code after the second login, it will be triggered regardless of success or failure
user:password-changed Modify the user information time. When the user modifies their own information or the administrator manually modifies the user information, the word time will be triggered, regardless of success or failure
user:email-verified User mailbox verified event

# Request type

Specify the data format of the Request body when initiating a Webhook request. The optional values ​​are application/json and application/x-www-form-urlencoded

# Attached data

Each event will carry some specific request parameters.

# Request headers

We will carry some custom header information in the HTTP POST header, as shown in the following table:

Header Description
user-agent The value is 'authing-webhook@2.0', indicating that this request comes from Authing
x-authing-webhook-secret Request secret key, the value is the secret key you set in the Webhook configuration. This secret key is verified and can be used to prevent malicious requests from third parties
x-authing-userpool-id Authing user pool ID

# Request body

The request body will also carry some specific parameters

Parameter name Description
eventName Event name, possible values ​​are login, register, user:updated, user:password-changed, user:email-verified
data The corresponding detailed information of the event

# Request example

  • Login event

    {
      "eventName": "login",
      "data": {
        "id": "5f702fcc913544c358cb2123",
        "arn": "arn:cn:authing:59f86b4832eb28071bdd9214:user:5f702fcc913544c358cb2123",
        "userPoolId": "59f86b4832eb28071bdd9214",
        "username": "xxx",
        "email": null,
        "emailVerified": false,
        "phone": null,
        "phoneVerified": false,
        "unionid": "35447896",
        "openid": "35447896",
        "identities": [],
        "nickname": "xxxx",
        "registerSource": ["social:github"],
        "photo": "https://avatars2.githubusercontent.com/u/35447896?v=4",
        "password": null,
        "oauth": "",
        "token": "",
        "tokenExpiredAt": "1602484037172",
        "loginsCount": 4,
        "lastLogin": "1601188037190",
        "lastIP": null,
        "signedUp": "2020-09-27T14:23:08+08:00",
        "blocked": false,
        "isDeleted": false,
        "device": null,
        "browser": null,
        "company": "Authing",
        "name": null,
        "givenName": null,
        "familyName": null,
        "middleName": null,
        "profile": "",
        "preferredUsername": null,
        "website": null,
        "gender": "U",
        "birthdate": null,
        "zoneinfo": null,
        "locale": null,
        "address": null,
        "formatted": null,
        "streetAddress": null,
        "locality": null,
        "region": null,
        "postalCode": null,
        "country": null,
        "createdAt": "2020-09-27T14:23:08+08:00",
        "updatedAt": "2020-09-27T14:27:17+08:00",
        "customData": ""
      }
    }
    
    • Registration issue
    {
      "eventName": "register",
      "data": {
        "id": "5f702fcc913544c358cb2123",
        "arn": "arn:cn:authing:59f86b4832eb28071bdd9214:user:5f702fcc913544c358cb2123",
        "userPoolId": "59f86b4832eb28071bdd9214",
        "username": "xxx",
        "email": null,
        "emailVerified": false,
        "phone": null,
        "phoneVerified": false,
        "unionid": "35447896",
        "openid": "35447896",
        "identities": [],
        "nickname": "xxxx",
        "registerSource": ["social:github"],
        "photo": "https://avatars2.githubusercontent.com/u/35447896?v=4",
        "password": null,
        "oauth": "",
        "token": "",
        "tokenExpiredAt": "1602484037172",
        "loginsCount": 4,
        "lastLogin": "1601188037190",
        "lastIP": null,
        "signedUp": "2020-09-27T14:23:08+08:00",
        "blocked": false,
        "isDeleted": false,
        "device": null,
        "browser": null,
        "company": "Authing",
        "name": null,
        "givenName": null,
        "familyName": null,
        "middleName": null,
        "profile": "",
        "preferredUsername": null,
        "website": null,
        "gender": "U",
        "birthdate": null,
        "zoneinfo": null,
        "locale": null,
        "address": null,
        "formatted": null,
        "streetAddress": null,
        "locality": null,
        "region": null,
        "postalCode": null,
        "country": null,
        "createdAt": "2020-09-27T14:23:08+08:00",
        "updatedAt": "2020-09-27T14:27:17+08:00",
        "customData": ""
      }
    }
    
  • Change password event

    {
      "eventName": "user:password-changed",
      "data": {
        "userId": "5f702fcc913544c358cb2123"
      }
    }
    
  • Modify user information event

    {
      "eventName": "user:updated",
      "data": {
        "user": {
          "id": "5f702fcc913544c358cb2123",
          "arn": "arn:cn:authing:59f86b4832eb28071bdd9214:user:5f702fcc913544c358cb2123",
          "userPoolId": "59f86b4832eb28071bdd9214",
          "username": "xxx",
          "email": null,
          "emailVerified": false,
          "phone": null,
          "phoneVerified": false,
          "unionid": "35447896",
          "openid": "35447896",
          "identities": [],
          "nickname": "xxxx",
          "registerSource": ["social:github"],
          "photo": "https://avatars2.githubusercontent.com/u/35447896?v=4",
          "password": null,
          "oauth": "",
          "token": "",
          "tokenExpiredAt": "1602484037172",
          "loginsCount": 4,
          "lastLogin": "1601188037190",
          "lastIP": null,
          "signedUp": "2020-09-27T14:23:08+08:00",
          "blocked": false,
          "isDeleted": false,
          "device": null,
          "browser": null,
          "company": "Authing",
          "name": null,
          "givenName": null,
          "familyName": null,
          "middleName": null,
          "profile": "",
          "preferredUsername": null,
          "website": null,
          "gender": "U",
          "birthdate": null,
          "zoneinfo": null,
          "locale": null,
          "address": null,
          "formatted": null,
          "streetAddress": null,
          "locality": null,
          "region": null,
          "postalCode": null,
          "country": null,
          "createdAt": "2020-09-27T14:23:08+08:00",
          "updatedAt": "2020-09-27T14:27:17+08:00",
          "customData": ""
        },
        "updates": {
          "nickname": "xxxx"
        }
      }
    }
    
  • User email is verified event

{
  "eventName": "user:email-verified",
  "data": {
    "userId": "xxxxx",
    "email": "xxxx"
  }
}
  • User MFA verify event
{
  "eventName": "mfaVerify",
  "data": {
    "userId": "xxxxx",
    "isValid": true // Is MFA code verified
  }
}