Agent events
The money itself moves with the standard
INCOMING_PAYMENT and OUTGOING_PAYMENT webhooks, and agent cards send the same card status and card transaction webhooks as any card.
Pending approval example
Handling agent webhooks
- Respond
200quickly and do the work asynchronously. A webhook whoseidyou have already processed can be acknowledged and skipped. - On
AGENT_ACTION.PENDING_APPROVAL, notify the customer immediately. A send withoutpriceToleranceexpires with its quote, often within minutes. - Don’t rely on webhooks alone for the approval queue.
GET /agents/approvalsrebuilds it if your endpoint was down. - Send a signed test event to your endpoint at any time with
POST /webhooks/test.
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 available in your dashboard under Developers webhook settings.
- 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
idfield to prevent processing duplicate webhooks. - Timeout handling: Implement proper timeout handling and respond to webhooks promptly.