curl
Form-encoded, JSON, multipart, redirect and idempotency-key requests from the command line, plus the honeypot negative test. The reference for any HTTP client.
Sample: samples/curl (examples.sh, README). Set CONTACTUSIQ_FORM_ID and CONTACTUSIQ_ORIGIN (a verified domain) and run the script.
Every request needs an Origin (or Referer) header matching a domain verified on the form; without one the API returns 200 and silently drops the submission. There is no Turnstile from the command line, so the request runs at stricter heuristics; use a form configured for testing.
Form-encoded
What a plain HTML form sends. Expect 200 and an HTML thank-you page.
curl -i https://api.contactusiq.com/s/au_xxxxxxx \
-H "Origin: https://www.example.com" \
--data-urlencode "name=Test Person" \
--data-urlencode "email=test@example.com" \
--data-urlencode "message=Hello" \
--data-urlencode "_honeypot="With a redirect
Expect 303 and a Location header.
curl -i https://api.contactusiq.com/s/au_xxxxxxx \
-H "Origin: https://www.example.com" \
--data-urlencode "name=Test Person" --data-urlencode "email=test@example.com" \
--data-urlencode "message=Hello" --data-urlencode "_honeypot=" \
--data-urlencode "_redirect=https://www.example.com/thanks.html"JSON
Expect 200 and {"ok":true,"id":"sub_..."}.
curl -i https://api.contactusiq.com/s/au_xxxxxxx \
-H "Origin: https://www.example.com" \
-H "Content-Type: application/json" -H "Accept: application/json" \
--data '{"name":"Test Person","email":"test@example.com","message":"Hello","_honeypot":""}'Multipart
curl -i https://api.contactusiq.com/s/au_xxxxxxx \
-H "Origin: https://www.example.com" -H "Accept: application/json" \
-F "name=Test Person" -F "email=test@example.com" -F "message=Hello" -F "_honeypot="Idempotency key
A repeat within 10 minutes returns the same id and creates nothing. _idempotency as a field works the same way.
curl https://api.contactusiq.com/s/au_xxxxxxx \
-H "Origin: https://www.example.com" \
-H "Content-Type: application/json" -H "Accept: application/json" \
-H "Idempotency-Key: order-1234-contact" \
--data '{"name":"Test Person","email":"test@example.com","message":"Hello","_honeypot":""}'Honeypot negative test
Expect 200 and nothing in the inbox.
curl -s -o /dev/null -w "%{http_code}\n" https://api.contactusiq.com/s/au_xxxxxxx \
-H "Origin: https://www.example.com" \
--data-urlencode "name=Bot" --data-urlencode "email=bot@example.com" \
--data-urlencode "message=spam" --data-urlencode "_honeypot=http://spam.example"Form schema
The field list and validation rules of a published form, no auth:
curl https://api.contactusiq.com/f/au_xxxxxxx/schemaExpected results
| Request | Result |
|---|---|
| Form-encoded | 200, HTML body |
With _redirect | 303, location: https://www.example.com/thanks.html |
JSON or multipart with Accept: application/json | 200, {"ok":true,"id":"sub_..."} |
| Idempotency key twice | one inbox entry, identical id |
| Honeypot filled | 200, nothing in the inbox |
| Six requests in ten minutes from one IP | 429 with retry-after: <seconds> |
| Wrong form id | 404 |
| Missing required field | 400, JSON body names the field when Accept: application/json |
| Body over 64 KB | 413 |