Documentation Index
Fetch the complete documentation index at: https://wordsmithai.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
About webhooks
Webhooks allow you to receive real-time notifications when asynchronous operations complete in Wordsmith. Instead of polling the API to check if a task is finished, you can configure a webhook URL to receive callbacks when processing completes.How webhooks work
- Configure a webhook URL: When making an API request, include a
callback_urlparameter - Receive notifications: Wordsmith will send a POST request to your URL when processing completes
- Verify signatures: Use the webhook secret to verify that requests are genuinely from Wordsmith
- Process the data: Handle the notification data in your application
Setting up webhooks
Step 1: Create an API key with webhook secret
When creating an API key, you can optionally provide a webhook secret. If you don’t provide one, Wordsmith will automatically generate a secure secret for you.Step 2: Use webhooks in your requests
Include acallback_url when making async requests (sync_mode is false):
Webhook payload format
When processing completes, Wordsmith sends a POST request to your callback URL with the following payload:Payload fields
The unique session ID for the completed question
The final status:
"completed" or "error"The assistant’s response. Present when
status is "completed", contains
error message when status is "error"Array of generated files (e.g., analysis reports, summaries). Only present
when
status is "completed"Validating webhook signatures
To ensure webhook requests are genuinely from Wordsmith and haven’t been tampered with, you should validate the signature before processing the payload.About signature validation
Wordsmith uses HMAC-SHA256 to sign webhook payloads with your webhook secret. The signature is included in theWordsmith-Signature header and follows this format:
tis the timestamp when the signature was createdv1is the HMAC-SHA256 signature
Signature verification process
- Extract the timestamp and signature from the
Wordsmith-Signatureheader - Create the signed payload by concatenating the timestamp and the request body:
{timestamp}.{payload} - Generate the expected signature using HMAC-SHA256 with your webhook secret
- Compare the expected signature with the received signature using a constant-time comparison
- Verify the timestamp is within 60 seconds of the current time
Example implementations
Python
JavaScript/Node.js
Ruby
Testing webhook signatures
You can test your signature verification implementation using these values:- Secret:
whsec_test_secret_123 - Payload:
{"id":"test","status":"completed"} - Timestamp:
1234567890 - Expected signature:
c60c0cc7241d79e8bf2a88fdc6ce257c2fd547048bb244495309b27ad07884bf - Header value:
t=1234567890,v1=c60c0cc7241d79e8bf2a88fdc6ce257c2fd547048bb244495309b27ad07884bf
Security best practices
Store secrets securely
- Never hardcode webhook secrets in your application
- Use environment variables or secure configuration management
- Rotate webhook secrets periodically
Validate all webhooks
- Always verify webhook signatures before processing
- Use constant-time comparison functions to prevent timing attacks
- Check timestamp tolerance to prevent replay attacks
Handle errors gracefully
- Return appropriate HTTP status codes (401 for invalid signatures)
- Log failed signature verifications for monitoring
- Don’t expose sensitive information in error messages
Use HTTPS
- Always use HTTPS for webhook endpoints
- Validate that callback URLs use secure protocols
- Consider using certificate pinning for additional security
Troubleshooting
Common issues
Signature verification fails- Ensure you’re using the correct webhook secret
- Check that the payload hasn’t been modified by middleware
- Verify you’re parsing the signature header correctly
- Check that your endpoint is publicly accessible
- Verify the callback URL is correct and uses HTTPS
- Ensure your server can handle POST requests
- Check that your server’s clock is synchronized
- Verify you’re using the correct tolerance (60 seconds)
- Ensure you’re parsing the timestamp correctly
Testing locally
For local development, you can use tools like ngrok to expose your local server:Rate limiting
Webhook delivery is subject to rate limits to prevent abuse. If you receive too many webhooks in a short period, some may be dropped. Implement idempotency in your webhook handlers to handle potential duplicate deliveries.Next steps
- API Reference - Explore all available endpoints
- Authentication - Learn about API key authentication
- Quickstart - Get started with the Wordsmith API