cURL Examples: Quick Command-Line Testing
Copy-paste cURL commands for testing FetchHook webhooks from your terminal.
#Basic Fetch
Fetch all webhooks from your source using a simple GET request.
Fetch Webhooks
curl https://api.fetchhook.app/api/v1/{SOURCE_ID} \
-H "Authorization: Bearer {YOUR_API_KEY}"#Filter Webhooks
Use query parameters to filter by timestamp, limit results, or paginate.
Filtered Fetch
# Get webhooks since yesterday
curl "https://api.fetchhook.app/api/v1/{SOURCE_ID}?since=2024-01-14T00:00:00Z" \
-H "Authorization: Bearer {YOUR_API_KEY}"
# Get only 10 most recent
curl "https://api.fetchhook.app/api/v1/{SOURCE_ID}?limit=10" \
-H "Authorization: Bearer {YOUR_API_KEY}"
# Combine filters
curl "https://api.fetchhook.app/api/v1/{SOURCE_ID}?since=2024-01-14T00:00:00Z&limit=50" \
-H "Authorization: Bearer {YOUR_API_KEY}"#Send Test Webhook
Send test webhooks to verify your integration before connecting real providers.
Simple Test
curl -X POST https://webhook.fetchhook.app/{SOURCE_ID} \
-H "Content-Type: application/json" \
-d '{
"event": "test.webhook",
"message": "Hello from cURL!",
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}'#Stripe-Style Webhook
Simulate Stripe webhooks with signature headers for testing.
Stripe Test
curl -X POST https://webhook.fetchhook.app/{SOURCE_ID} \
-H "Content-Type: application/json" \
-H "Stripe-Signature: t=1234567890,v1=test_signature" \
-d '{
"id": "evt_test_webhook",
"type": "charge.succeeded",
"data": {
"object": {
"id": "ch_test_charge",
"amount": 2000,
"currency": "usd",
"status": "succeeded"
}
},
"created": '$(date +%s)'
}'#GitHub-Style Webhook
Simulate GitHub webhooks with appropriate headers and payload structure.
GitHub Test
curl -X POST https://webhook.fetchhook.app/{SOURCE_ID} \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: push" \
-H "X-Hub-Signature-256: sha256=test_signature" \
-d '{
"ref": "refs/heads/main",
"repository": {
"name": "test-repo",
"full_name": "user/test-repo"
},
"commits": [
{
"id": "abc123",
"message": "Test commit",
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}
]
}'#Pretty Print with jq
Use jq to format JSON output and extract specific fields.
Format Output
# Pretty print all webhooks
curl https://api.fetchhook.app/api/v1/{SOURCE_ID} \
-H "Authorization: Bearer {YOUR_API_KEY}" | jq '.'
# Show only event IDs
curl https://api.fetchhook.app/api/v1/{SOURCE_ID} \
-H "Authorization: Bearer {YOUR_API_KEY}" \
| jq '.webhooks[].event_id'
# Filter by provider
curl https://api.fetchhook.app/api/v1/{SOURCE_ID} \
-H "Authorization: Bearer {YOUR_API_KEY}" \
| jq '.webhooks[] | select(.provider == "stripe")'#Complete Test Script
Full bash script to test the entire webhook flow: send, wait, fetch, verify.
End-to-End Test
#!/bin/bash
SOURCE_ID="your-source-id"
API_KEY="your-api-key"
WEBHOOK_URL="https://webhook.fetchhook.app/$SOURCE_ID"
FETCH_URL="https://api.fetchhook.app/api/v1/$SOURCE_ID"
echo "🚀 Testing FetchHook..."
# Step 1: Send webhook
echo "📤 Sending test webhook..."
RESPONSE=$(curl -s -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{"event":"test","timestamp":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}')
WEBHOOK_ID=$(echo "$RESPONSE" | jq -r '.webhook_id')
echo "✓ Sent: $WEBHOOK_ID"
# Step 2: Wait
echo "⏳ Waiting 2 seconds..."
sleep 2
# Step 3: Fetch
echo "📥 Fetching webhooks..."
FETCH=$(curl -s "$FETCH_URL" -H "Authorization: Bearer $API_KEY")
COUNT=$(echo "$FETCH" | jq '.count')
echo "✓ Fetched $COUNT webhook(s)"
# Step 4: Verify
FOUND=$(echo "$FETCH" | jq --arg id "$WEBHOOK_ID" '.webhooks[] | select(.event_id == $id)')
if [ -n "$FOUND" ]; then
echo "✅ Success! Webhook found"
else
echo "❌ Webhook not found"
exit 1
fi#Using Environment Variables
Store credentials in environment variables for security and convenience.
Environment Setup
# Set environment variables
export FETCHHOOK_SOURCE_ID="your-source-id"
export FETCHHOOK_API_KEY="your-api-key"
# Use in commands
curl "https://api.fetchhook.app/api/v1/$FETCHHOOK_SOURCE_ID" \
-H "Authorization: Bearer $FETCHHOOK_API_KEY"
# Save permanently in ~/.bashrc or ~/.zshrc
echo 'export FETCHHOOK_SOURCE_ID="your-source-id"' >> ~/.bashrc
echo 'export FETCHHOOK_API_KEY="your-api-key"' >> ~/.bashrc
source ~/.bashrcAgent Protocol Instruction