Verify Responses Server-Side
How it works
Verify the token with our API
Your server needs to make a request to our verification endpoint to check if the token is valid.
API Details:
URL:
http://api.gotcha.land/api/siteverifyMethod: POST
Content-Type:
application/x-www-form-urlencoded
Required Parameters:
secret: Your private secret key (found in your GotCHA dashboard)response: The token you received from the frontendremoteip: (optional) The client that solved the captcha
Check the response
Our API will return a JSON response like this:
{
"success": true|false,
"challenge_ts": timestamp, // timestamp of the challenge load (ISO8601 format)
"hostname": string, // the hostname of the site where the captcha was solved
"error-codes": [string] // optional
}If success is true, the CAPTCHA is valid. If it's false, reject the form submission.
Error codes can be one or more of the following:
missing-input-secret: The secret parameter is missing.invalid-input-secret: The secret parameter is invalid or malformed.missing-input-response: The response parameter is missing.invalid-input-response: The response parameter is invalid or malformed.bad-request: The request is invalid or malformed.timeout-or-duplicate: The response is no longer valid: either is too old or has been used previously.
Code Examples
Javascript/Node.js
async function verifyCaptcha(token) {
const response = await fetch('http://api.gotcha.land/api/siteverify', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
secret: 'YOUR_SECRET_KEY', // ** Replace with your actual secret key **
response: token
})
});
const result = await response.json();
return result.success;
}
// Usage in an Express.js route
app.post('/submit-form', async (req, res) => {
const captchaToken = req.body['gotcha-response'];
const isValid = await verifyCaptcha(captchaToken);
if (isValid) {
// Process the form submission
res.json({ message: 'Form submitted successfully!' });
} else {
// Reject the submission
res.status(400).json({ error: 'Invalid CAPTCHA' });
}
});Rust
Last updated