I want my webhooks firing only when I use the web interface, how can I do that?
-
Example:
Update an user using the API will not fire the webhook, but if I update it using the web interface it would fire.
I am asking because I have enabled it and I am receiving a timeout error when I use the API to apply a patch. I am trying to use the webhook to keep a local database synchronized, is it a correct usage? If not, how can I keep a local database sync?
Thanks!
Tito
-
Seems that it is a strange behavior...
Scenario: I have just 1 application available called "myapp"
Behavior 1:If I go to Settings -> Webhooks -> Edit -> Application -> Check All aplications
As expected if I update an user via API or Admin interface it fires a webhook.If I go to Settings -> Webhooks -> Edit -> Application -> Check only FusionAuth
It is not firing if I update and user via API (expected) nor via Admin interface.Is it expected? Is there a way to fire webhooks only when the admin application executes an action?
-
As per documentation:
When the All applications is disabled, this field will be exposed. Select the application for which you would like to receive events.
Not all events are considered application specific and selecting an application will limit you to only receiving application events. The following events are considered Application events:
jwt.public-key.update
jwt.refresh-token.revoke
user.action
In most cases you will want to use the
All applications
configuration.So this is expected behavior.
In general, WebHooks are intended to be executed on certain events, and these events occur whether or not they are triggered by the GUI or via API. It is not possible to enable them only for GUI initiated operations and disable for API, but that should not be an issue for any legitimate use case.
You should probably inspect your webhook receiver to find out why it times out for some requests and for some it doesn't.
BTW, we may be facing some XY problem. What exactly are you trying to achieve with those webhooks? What does keeping a local database synchronized mean for your use case?
-
I do have an extended data of my users in another database, like addresses etc... so if, for some reason I update the email or username on the admin gui, I'd like to reflect this change on my local DB.
-
I would probably leave user email in FA only, and fetch it via API when it's needed. But apart from that, you should focus on debugging your webhook receiver - why is it causing the timeout - rather than trying to fire webhooks only on GUI initiated changes.
-
@titogarrido said in I want my webhooks firing only when I use the web interface, how can I do that?:
Is there a way to fire webhooks only when the admin application executes an action
I'm not aware of any way to do this. The webhook actions for API calls are indistinguishable from the webhook actions caused by the admin UI because the admin UI uses the API.
I am trying to use the webhook to keep a local database synchronized, is it a correct usage? If not, how can I keep a local database sync?
I think you are on the right path. I'm not sure why it is timing out, but as @mgetka says, that's what I'd investigate.