Webhook URLs are exposed on the internet. To ensure that a request really came from iFood, we implement the X-IFood-Signature header in all webhook requests. This header allows validating the authenticity of received messages.Reject requests with invalid signatures. This validation is mandatory for webhook homologation. iFood may send events with invalid signatures to test your integration. This check also protects against fraud. We audit all delivered events, delivery attempts, and discarded events.
Validation
The webhook uses (HMAC) with SHA256 to sign each message. The final value is encoded in hexadecimal. The signature uses the application's client secret (the same one used to generate tokens), available in the "Credentials" tab of the Developer Portal. Each request includes this signature in the X-IFood-Signature header. To validate, generate the HMAC of the received message using your secret (in a secure location) and compare with the received signature using secure comparison (example). Most languages have libraries with native support:
Fields can be added to any event at any time, without causing breaking changes. Therefore, validate the signature before converting the message content to an object. Generate the signature using the body byte array exactly as received.This care is essential in JSON, since {"prop1": "value1", "prop2": "value2"} and {"prop2": "value2", "prop1": "value1"} are equivalent for parsers, but form different byte arrays. Special characters may also vary according to the library or language.
Examples
All examples are valid for the same JSON, but with different formatting and should be supported by your integration: