Your code.
A new workflow.
Discover the proposed integration and prepare your application for the API.
Getting started
Integration has three steps: identify your application, create a task and follow its result. Explore the experience in the demo dashboard.
Authentication
The proposal uses a credential clientKey in server calls. Keep the key in environment variables, outside public code and the browser. Demo dashboard keys cannot access services.
Create a task
POST /createTaskSend the credential and required parameters for the selected type.
// Contrato proposto — configure a URL da API real no servidor
const response = await fetch(API_BASE_URL + "/createTask", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
clientKey: process.env.SOLUCAPTCHA_API_KEY,
task: {
type: "RecaptchaV2Task",
websiteURL: "https://sua-aplicacao.com",
websiteKey: "SUA_SITE_KEY"
}
})
});
if (!response.ok) throw new Error("Falha ao criar tarefa");
const task = await response.json();Expected response
{
"errorId": 0,
"taskId": "example-task-id"
}Retrieve the result
POST /getTaskResultUse the taskId to check the state. If it is processing, wait before checking again, respecting API-defined intervals and limits.
{
"clientKey": "SUA_CHAVE_NO_SERVIDOR",
"taskId": "example-task-id"
}States and errors
The task has a result available.
The task is still processing.
Check the returned error code and description.
Handle invalid credentials, insufficient balance, unexpected responses and timeouts. Final error names will be defined by the API.