fal.ai Webhooks: A Complete Guide
Fal.ai webhooks provide a powerful way to get notified about events in your machine learning models, like when a request is done processing. This guide will walk you through receiving and verifying fal.ai webhooks.
What are fal.ai Webhooks?
A fal.ai webhook is a POST request sent to a URL you provide. It's triggered when a long-running process, like model training, completes. Instead of polling for results, fal.ai pushes the results to your application.
Setting Up a Webhook
To receive webhooks, you need to provide a `fal_webhook` query parameter when making a request to the `queue.fal.run` endpoint.
Webhook Payload
Successful Result
A successful webhook payload will have a status of "OK" and include the results of your request.
Error Result
If an error occurs, the status will be "ERROR" and the payload will contain error details.
Verifying Webhook Signatures
To ensure that incoming webhooks are from fal.ai, you should verify the signature of each request. Fal.ai uses a `X-Fal-Webhook-Signature` header.
The verification process involves several steps:
- Fetch the JSON Web Key Set (JWKS) from fal.ai.
- Extract headers from the incoming request.
- Verify the timestamp of the request.
- Construct the message to verify.
- Verify the signature using the public key.
JavaScript Example
Master Webhook Development with Hooklistener
Hooklistener provides the complete webhook development and debugging platform. Capture, inspect, replay, and monitor webhooks with signature verification, team collaboration, and production-ready reliability.
Start Building Webhooks Free →