Send a contact form
const url = 'https://api.threadkite.app/f/example';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"Sarah Turner","email":"sarah.turner@example.co.uk","message":"Is the Focus still available?","consent":["marketing_email"],"_tk_token":"m1abc.signature"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.threadkite.app/f/example \ --header 'Content-Type: application/json' \ --data '{ "name": "Sarah Turner", "email": "sarah.turner@example.co.uk", "message": "Is the Focus still available?", "consent": [ "marketing_email" ], "_tk_token": "m1abc.signature" }'Posts the answers by field name, as JSON or application/x-www-form-urlencoded, with consent for each ticked box, _tk_token from the form, and optionally _tk_page, _tk_landing, _tk_referrer, utm_* (with utm_id), _tk_click_id (the ad click id, as gclid:...) _tk_item (repeatable: what the lead is about, as an external id, an identifier such as a registration, or a SKU; the first is the main item, and unknown ones are left out) and _tk_addon (repeatable: options added to the main item, as an identifier or, when not in the catalogue, its own words up to 200 characters), and _tk_proof, the robot check’s proof, when the form’s robotCheck is on (without it, the message goes to the Spam folder; without it and without _tk_token as well, it is refused with robot_check_required). Without page details (a plain HTML form on a page without the website script), the Referer is taken as the page, with any UTMs in its address. A plain HTML form is redirected (303) to the thank-you page, or back to the hosted form with a problem; JSON callers get JSON. Spam is answered like any other submission.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The form’s public key
Request Bodyrequired
Section titled “Request Bodyrequired”object
Example
{ "name": "Sarah Turner", "email": "sarah.turner@example.co.uk", "message": "Is the Focus still available?", "consent": [ "marketing_email" ], "_tk_token": "m1abc.signature"}object
Example
{ "name": "Sarah Turner", "email": "sarah.turner@example.co.uk", "message": "Is the Focus still available?", "consent": [ "marketing_email" ], "_tk_token": "m1abc.signature"}Responses
Section titled “Responses”object
The thank-you message to show
Go here instead of showing the message
Example
{ "ok": true}A plain HTML form: the thank-you page, or the problem
Answers to change, by field (invalid_submission); or robot_check_required, with the reason as errors.form: the form asks for the robot check and the post had neither _tk_proof nor _tk_token
object
Stable machine-readable reason
Problems by field name (consent.<key> for tick boxes, form overall)
object
Example
{ "statusCode": 400, "code": "invalid_submission", "message": "Check the form: some answers need changing.", "errors": { "email": "Enter an email address like name@example.co.uk" }}Not from an allowed website
object
Stable machine-readable reason
With code invalid: every problem with the request, by field (message is the first)
object
Dotted path inside the item, e.g. attributes.price.amountMinor
Example
{ "statusCode": 403, "code": "forbidden", "message": "You do not have permission to do that.", "errors": [ { "message": "Enter the make" } ]}object
Stable machine-readable reason
With code invalid: every problem with the request, by field (message is the first)
object
Dotted path inside the item, e.g. attributes.price.amountMinor
Example
{ "statusCode": 403, "code": "forbidden", "message": "You do not have permission to do that.", "errors": [ { "message": "Enter the make" } ]}The form is archived
object
Stable machine-readable reason
With code invalid: every problem with the request, by field (message is the first)
object
Dotted path inside the item, e.g. attributes.price.amountMinor
Example
{ "statusCode": 403, "code": "forbidden", "message": "You do not have permission to do that.", "errors": [ { "message": "Enter the make" } ]}object
Stable machine-readable reason
Seconds until another request will be accepted
Example
{ "statusCode": 429, "code": "rate_limited", "message": "Too many requests. Each key can make 120 requests a minute; try again in 12 seconds.", "retryAfter": 12}