Skip to content

Input Data

Capturing input data

User input can be collected within a creative using the TextInput flow component. When added to a creative's flow, it renders a text field where users can enter information such as email addresses, names, or other free-text responses.

Multiple TextInput components can be used in the same flow, each configured with its own label and target endpoint.

Input data is sent immediately when the user submits each field.

WARNING

It is recommended to always ask for consent, and in many jurisdictions it is required by law (e.g. GDPR).

Leads API

The Leads API sends captured text input data directly to a specified external endpoint. The API URL is configured per TextInput component in the flow builder.

WARNING

Text input data is sent directly from the creative to the specified endpoint. Cavai never sees or stores the data.

Listening to Leads API

Your endpoint must accept POST requests with a JSON body. Example listener:

javascript
const express = require('express');
const cors = require('cors');

const app = express();

app.use(cors());
app.use(express.json());

const port = 3000;

app.post('/', (req, res) => {
  console.log(JSON.stringify(req.body));
  res.send('OK');
});

app.listen(port, () => {
  console.log(`Server listening at http://127.0.0.1:${port}`);
});

Data structure

Data is sent as a JSON POST request:

json
{
  "leadId": "3e031dca-46ba-46be-92b9-5cc1cefedb1d",
  "Enter your email": "test@test.com"
}
  • leadId — Unique identifier for the submission (camelCase)
  • The remaining key is the label text of the TextInput component, with the user's input as the value

If a creative contains multiple TextInput components, each sends its own individual request (one per input field). Each component can target a different endpoint.