X-Grid-Signature header, which allows you to verify the authenticity of the webhook. This is critical for security, as it ensures that only legitimate webhooks from Grid are processed by your system.
Signature Verification Process
-
Obtain your Grid public key
- This is provided to you during the integration process. Reach out to us at support@lightspark.com or over Slack to get the public key.
- The key is in PEM format and can be used with standard cryptographic libraries
-
Verify incoming webhooks
- Extract the signature from the
X-Grid-Signatureheader - Decode the base64 signature
- Create a SHA-256 hash of the entire request body
- Verify the signature using the Grid webhook public key and the hash
- Only process the webhook if the signature verification succeeds
- Extract the signature from the
Verification Examples
Node.js Example
Python Example
Testing
To test your webhook implementation, you can trigger a test webhook from the Grid dashboard. This will send a test webhook to the endpoint you provided during the integration process. The test webhook will also be sent automatically when you update your platform configuration with a new webhook URL. An example of the test webhook payload is shown below:Security Considerations
- Always verify signatures: Never process webhooks without verifying their signatures.
- Use HTTPS: Ensure your webhook endpoint uses HTTPS to prevent man-in-the-middle attacks.
- Implement idempotency: Use the
webhookIdfield to prevent processing duplicate webhooks. - Timeout handling: Implement proper timeout handling and respond to webhooks promptly.
Retry Policy
The Grid API will retry webhooks with the following policy based on the webhook type:| Webhook Type | Retry Policy | Notes |
|---|---|---|
| TEST | No retries | Used for testing webhook configuration |
| OUTGOING_PAYMENT | Retry with exponential backoff up to 7 days with maximum interval of 30 mins | No retry on 409 (duplicate webhooks) |
| INCOMING_PAYMENT | Retry with exponential backoff up to 7 days with maximum interval of 30 mins | No retry on: 409 (duplicate webhook) or PENDING status since it is served as an approval mechanism in-flow |
| BULK_UPLOAD | Retry with exponential backoff up to 7 days with maximum interval of 30 mins | No retry on 409 (duplicate webhooks) |
| INVITATION_CLAIMED | Retry with exponential backoff up to 7 days with maximum interval of 30 mins | No retry on 409 (duplicate webhooks) |
| KYC_STATUS | Retry with exponential backoff up to 7 days with maximum interval of 30 mins | No retry on 409 (duplicate webhooks) |
| ACCOUNT_STATUS | Retry with exponential backoff up to 7 days with maximum interval of 30 mins | No retry on 409 (duplicate webhooks) |