Gigya webhooks offer a flexible way to extend Gigya's flows by sending out to your server a notification of a specific Gigya event that has occurred. With webhooks, you can implement your own code, and set it to trigger when the relevant hook is fired. Webhook notifications are sent in near real-time and are delivered at least once.
They may contain multiple events to improve efficiency and bandwidth utilization.
Events are ordered per UID, meaning that per UID, events are delivered in the order in which they occur.
You may configure the platform to deliver notifications for specific event types. Common use cases include:
- Sending personalized marketing materials to a user based on particular actions.
- Replicating your user database.
Watch an Instructional Video
The following events are supported:
- Account created - fired when a new account record is actually created in Gigya's database.
- Account registered - fired when a user completes registration.
- Account updated - fired when a user record is updated.
- Account deleted - fired when an account is deleted.
- Account logged in - fired when a user logs in.
- Account locked out - fired when an account is locked out, due to suspicious login attempts, as detected by Risk Based Authentication.
- Subscription updated - fired when the status of a subscription changes (subscribed / unsubscribed, or a change in the double opt-in status). For more information, see Subscription Management.
Subscribing to Events
Perform the following for each site in which you want to use webhooks. Note that for site groups, every site that has a webhook defined for a specific event will receive that event from any other site in the group, whether they have any webhooks defined or not. For more information see Site Group Notifications.
- Go to the Webhooks page In Gigya's Console. You may also access it from the Settings menu, under Registration-as-a-Service.
- Click Create Webhook.
- In the Create Webhook page:
- Enter a unique name.
- Enter the Notification URL in your server to which webhook notification objects will be sent when the subscribed event is fired.
- Choose whether to sign the notifications using your partner secret key, or a user/app key, in which case you should also enter the key.
- Select the events to which this webhook is subscribed.
- Click Create.
- You may subscribe multiple Notification URLs to any combination of events. This may be useful where you want notifications for the same event sent to multiple systems to be processed independently.
- Creating a webhook uses the accounts.webhooks.set API.
Retrieving Webhook Data
Use the accounts.webhooks.getAll API to retrieve all currently defined webhooks.
The notification consists of an HTTP POST request containing a Notification Object in the body. Gigya may include up to 100 multiple events in a single notification.
Notification Object Members
An array of JSON objects, each one consisting of:
|nonce||string||A random string used as part of the hash. For more information, see Notification Security.|
|timestamp||number||The GMT time when the notification was sent, in UNIX time format, i.e., the number of seconds since Jan. 1st 1970.|
Example Notification Object
Site Group Notifications
Notifications from any site are automatically sent to all sites, including the parent, as long as each site is subscribed to the given event type. This means that all events within the group will be sent to all the URLs of all children that are subscribed to the specific event.
For example, given the following Site Group and configuration, if an account is created on Site B, an accountCreated notification will be sent to Sites P, A and B:
To ensure that a given notification originated from Gigya and that none of its data has been tampered with in transit, notifications contain a signature in the X-Gigya-Sig-Hmac-Sha1 header.
The signature is constructed by BASE64 encoding the HMAC-SHA1 hash of the JSON payload, using your User Secret or Partner Secret as the key.
Verifying the Hash
It's important to verify the hash passed in the X-Gigya-Sig-Hmac-Sha1 header to ensure the authenticity of the notification. To verify the hash:
- Create an HMAC-SHA1 hash of the JSON payload using a User Secret or Partner Secret as the key. For more information on signing notifications using a User Secret, see the signingUserKey property of accounts.webhooks.set.
- Compare your hash to the one received in the X-Gigya-Sig-Hmac-Sha1 header.
If the hashes match, the notification is considered valid.
Return a Valid HTTP Status Code
Gigya considers notifications delivered if a 2XX Success HTTP status code is received (e.g., 200 OK, 201 Created, 202 Accepted). Gigya will wait 10 seconds before considering the notification unsuccessful. If we receive anything other than a Success response from your server, we will resend the notification at increasing intervals up to one hour. If we receive no response at all, we assume that your callback endpoint is offline. When your callback endpoint comes back online, we will deliver notifications from the three previous hours in the prior to the endpoint being detected as being active (if they were not already delivered).
We recommend that once a notification is received, you return a 2XX Success immediately, before continuing to process it. Waiting too long to respond may cause the notification to be resent unnecessarily.
In the event that your endpoint is out of service for more than 3 hours, you may retrieve any missed webhook data manually via alternate methods as you would normally, i.e., using the accounts.search API for the time frame in question.
Additionally, it is not necessary to contact Gigya to re-enable webhooks in the event of an outage, Gigya is able to detect when your server is back online and will automatically continue sending the notifications.
Gigya recommends enqueuing the webhook data after sending the 200 Success HTTP status code, and processing the data asynchronously. A queue data structure is recommended to maintain the order of event data.
The following is a sample PHP file used as a callback url endpoint. The page receives Gigya's notification and authenticates the hash. If the hash is valid, it outputs the event type and UID to the screen and responds with a 200 OK so Gigya won't resend the notification; if it's not valid, it responds with a 400 Bad Request.
API Event Mapping
The following table lists API methods and the events they fire when called.
|accounts.finalizeRegistration||accountRegistered | accountUpdated | subscriptionUpdated|
|accounts.login||accountLoggedIn | accountLockedOut|
|accounts.notifyLogin||accountUpdated | accountLoggedIn | accountRegistered | accountCreated (for new site users)|
accountCreated | accountRegistered | accountLoggedIn* | subscriptionUpdated
* If the site policy requires email verification, accountLoggedIn will not fire following accounts.register.
|accountUpdated | subscriptionUpdated|
|SAML login||accountCreated | accountRegistered | accountLoggedIn|
|socialize.notifyLogin||accountUpdated | accountLoggedIn | accountRegistered | accountCreated (for new site users)|
|socialize.notifyRegistration||accountRegistered | accountUpdated|
|Social Login (if new user)||accountCreated | accountRegistered | accountLoggedIn | accountUpdated|
|Facebook Social Sync||accountUpdated (The event is fired when the following fields are updated via Social Sync - birthday, books, education, email, first_name, hometown, last_name, likes, link, locale, location, movies, music, name, relationship_status, religion, verified, timezone and work).|
HTTPS webhooks support TLS protocols 1.1 and 1.2.