cURL
cURL is the fastest way to test the FormSentry API from your terminal.
Basic Request
Section titled “Basic Request”curl -X POST https://api.formsentry.ai/v1/verify \ -H "Content-Type: application/json" \ -d '{ "apiKey": "YOUR_API_KEY", "formId": "YOUR_FORM_ID", "payload": { "name": "John Doe", "email": "john@example.com", "message": "I would like to learn more about your services." } }'Using Environment Variables
Section titled “Using Environment Variables”Set your credentials once:
export FORMSENTRY_API_KEY="fs_your_api_key_here"export FORMSENTRY_FORM_ID="your_form_id_here"Then use them in requests:
curl -X POST https://api.formsentry.ai/v1/verify \ -H "Content-Type: application/json" \ -d "{ \"apiKey\": \"$FORMSENTRY_API_KEY\", \"formId\": \"$FORMSENTRY_FORM_ID\", \"payload\": { \"name\": \"John Doe\", \"email\": \"john@example.com\", \"message\": \"Hello, I need help with my account.\" } }"Testing Spam Detection
Section titled “Testing Spam Detection”Send a clearly spammy submission to verify detection:
curl -X POST https://api.formsentry.ai/v1/verify \ -H "Content-Type: application/json" \ -d "{ \"apiKey\": \"$FORMSENTRY_API_KEY\", \"formId\": \"$FORMSENTRY_FORM_ID\", \"payload\": { \"name\": \"SEO Expert\", \"email\": \"spammer@example.com\", \"message\": \"Buy cheap SEO services! Get 10000 backlinks for just $5! Visit our website now for guaranteed Google rankings!\" } }"Expected response:
{ "status": "spam", "confidence": 0.95, "reasoning": "Submission contains promotional content and unsolicited marketing", "submissionId": "550e8400-e29b-41d4-a716-446655440000", "processingTime": 180, "formId": "your_form_id"}Viewing Response Headers
Section titled “Viewing Response Headers”Use -i to see rate limit headers:
curl -i -X POST https://api.formsentry.ai/v1/verify \ -H "Content-Type: application/json" \ -d '{"apiKey":"YOUR_API_KEY","formId":"YOUR_FORM_ID","payload":{"name":"Test","email":"test@test.com","message":"Hello"}}'Response headers include:
X-RateLimit-Limit: 10X-RateLimit-Remaining: 9X-RateLimit-Reset: 1640995200Pretty-Print Response
Section titled “Pretty-Print Response”Pipe the output through jq for formatted JSON:
curl -s -X POST https://api.formsentry.ai/v1/verify \ -H "Content-Type: application/json" \ -d '{"apiKey":"YOUR_API_KEY","formId":"YOUR_FORM_ID","payload":{"name":"John","email":"john@example.com","message":"Hello"}}' \ | jq .Request with Timeout
Section titled “Request with Timeout”Set a 5-second timeout:
curl -X POST https://api.formsentry.ai/v1/verify \ --max-time 5 \ -H "Content-Type: application/json" \ -d '{"apiKey":"YOUR_API_KEY","formId":"YOUR_FORM_ID","payload":{"name":"John","email":"john@example.com","message":"Hello"}}'