Diagnostic Submissions

If you run a diagnostic form (quiz, assessment, self-test) that delivers a result to the lead, this API logs every submission attempt in Sendeasy: who filled it in, the result, and whether the WhatsApp delivery and the ActiveCampaign contact creation succeeded.

The history shows up under Leads → Diagnostic Submissions, with search and CSV export.

Before you start

  1. Register the project. Under Leads → Diagnostic Submissions, open Allowed projects and register an identifier for your diagnostic (e.g. mydiagnostic). While the list is empty, no submission is recorded.
  2. Generate an API Token for the project (Settings → API).

The identifier you send must exactly match one of the registered ones. This validation is intentional: it prevents a typo from silently creating a new project.

Log a submission

MethodEndpointAuth
POST/api/v1/diagnostic-submissionsAPI Token

Request body

FieldTypeRequiredDescription
projectstringYesDiagnostic identifier, matching the one registered under "Allowed projects".
namestringNoName of the person who filled it in.
emailstringNoEmail of the person who filled it in.
phonestringNoPhone with country and area code (e.g. 5511999999999).
resultobjectNoAnswers, scores and dimensions of the diagnostic. Free-form.
whatsappStatusstringNosuccess, failed or skipped.
whatsappErrorstringNoError message when the delivery fails.
activeCampaignStatusstringNosuccess, failed or skipped.
activeCampaignErrorstringNoError message when the integration fails.
sourcestringNoLead source (campaign, page, ad).

Send the status fields after attempting delivery, with the real outcome of each step. That is what lets you find failed deliveries later.

Example

curl --location 'https://backend.sendeasy.app/api/v1/diagnostic-submissions' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --data '{
    "project": "mydiagnostic",
    "name": "Maria Souza",
    "email": "maria@example.com",
    "phone": "5511999999999",
    "result": { "average": 7.5, "categories": { "process": 8, "people": 7 } },
    "whatsappStatus": "success",
    "activeCampaignStatus": "failed",
    "activeCampaignError": "API timeout",
    "source": "instagram-campaign"
  }'

Response

{
  "id": 42
}

Errors

HTTPerrorWhat to do
400PROJECT_REQUIREDSend the project field.
400NO_PROJECTS_CONFIGUREDNo project registered yet: open "Allowed projects" on the screen and register the identifier.
400PROJECT_NOT_ALLOWEDThe identifier is not on the list. The response includes allowedProjects with the accepted values — compare them with what your form sends.
401ERR_API_TOKEN_NOT_PROVIDEDMissing the Authorization: Bearer <api_token> header.
401ERR_API_TOKEN_INVALIDInvalid or disabled token.

Both project errors include the accepted list:

{
  "error": "PROJECT_NOT_ALLOWED",
  "allowedProjects": ["mydiagnostic"]
}

Best practices

  • Log failures too. A submission with whatsappStatus: "failed" is exactly what you want to see later.
  • Don't block the user. Call this API in the background: if logging fails, the lead should still see their result.
  • Keep the token on the server. The API Token grants access to the project — never expose it in the browser.

Essa informação foi útil?