Send leads to Realtime API with prescreen questions. The main endpoint automatically chains all steps together - each step's response becomes the input for the next step, accumulating all data through the flow.
Automatically chains all steps: sends your data to Step 2, Step 2's response to Step 3, and so on. Returns final combined result.
POST /api/realtime/with-prescreenReceives data from Step 1, fetches API key from Activepieces, appends it to the data, and returns everything.
/api/realtime/with-prescreen/get-api-keyReceives Step 2's response, checks if email exists in RT using the API key, appends email check result, and returns everything.
/api/realtime/with-prescreen/check-emailReceives Step 3's response, formats phone (XXX-XXX-XXXX), DOB (YYYY-MM-DD), sex (M/F), and question answers (Yes→1, No→0, null→2), and returns formatted data.
/api/realtime/with-prescreen/format-dataReceives Step 4's response, transforms question fields (q{question_id} → questions[{question_id}]), sends formatted data to RT V1 API (only if email doesn't exist), appends RT response with PatientID, and returns everything.
/api/realtime/with-prescreen/send-to-rtReceives Step 5's response, extracts PatientID, sends formatted comments to RT V2 API, appends RT V2 response, and returns final combined result.
/api/realtime/with-prescreen/send-commentsPOST /api/realtime/with-prescreen
Automatically chains all steps: Step 1 → Step 2 → Step 3 → Step 4 → Step 6. Each step's response becomes the input for the next, accumulating all data.
Input (Initial Payload):
{
"StudyID": 12,
"ReferrerID": 25,
"instanceName": "erg-oct",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"phone": "555-123-4567",
"dob": "1990-01-15",
"sex": "M",
"zipCode": "12345",
"weight": "180",
"height": "72",
"ethnicity": "Hispanic",
"race": "White",
"condition": "Bunions",
"protocol": "1A2B3C",
"recruitmentStatus": "Qualified For Screening",
"photoUpload": "https://example.com/",
// Prescreening questions: Use format q{question_id} with values "Yes", "No", or null
"q123": "Yes",
"q456": "No",
"q789": null
}Output (Final Combined Result):
{
// All original input data
"StudyID": 12,
"ReferrerID": 25,
"instanceName": "erg-oct",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"phone": "555-123-4567",
"dob": "1990-01-15",
"sex": "M",
// Step 2: API Key added
"key": "eyJhbGciOiJSUzI1NiIs...",
"created": "Mon, 24 Nov 2025 08:00:16 GMT",
// Step 3: Email check result added
"data": [],
"emailCheckResult": {...},
"emailExists": false,
// Step 5: RT V1 response added
"rtRequestPayload": {...},
"rtResponse": {
"status": 0,
"PatientID": 25414,
"message": "Referral has been added to study."
},
// Step 6: RT V2 response added
"rtV2Response": {
"data": {
"subjectId": 25414,
"comment": "(11/24/2025 - Bunions - 1A2B3C)..."
}
}
}POST /api/realtime/with-prescreen/get-api-key
Receives data from previous step, fetches API key from Activepieces, appends key to the data, and returns everything.
Input (from Step 1 or direct call):
{
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"instanceName": "erg-oct",
// ... any other fields
}Output (input + API key):
{
// All input data preserved
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"instanceName": "erg-oct",
// API key appended
"key": "eyJhbGciOiJSUzI1NiIs...",
"created": "Wed, 19 Nov 2025 08:00:18 GMT"
}POST /api/realtime/with-prescreen/check-email
Receives Step 2's response, checks email in RT using the API key, appends email check result, and returns everything.
Input (from Step 2):
{
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"instanceName": "erg-oct",
"key": "eyJhbGciOiJSUzI1NiIs...",
"created": "Wed, 19 Nov 2025 08:00:18 GMT",
// ... all previous data
}Output (input + email check):
{
// All previous data preserved
"firstName": "John",
"email": "john.doe@example.com",
"key": "eyJhbGciOiJSUzI1NiIs...",
// Email check result appended
"data": [],
"error": {},
"meta": {
"totalItems": 0
},
"emailExists": false
}POST /api/realtime/with-prescreen/format-data
Receives Step 3's response, formats phone (XXX-XXX-XXXX), DOB (YYYY-MM-DD), sex (M/F), and question answers (Yes→1, No→0, null→2), and returns formatted data.
Input (from Step 3):
{
"firstName": "John",
"phone": "5551234567",
"dob": "01/15/1990",
"sex": "Male",
// Question answers: "Yes", "No", or null
"q123": "Yes",
"q456": "No",
"q789": null,
"key": "eyJhbGciOiJSUzI1NiIs...",
"emailExists": false,
// ... all previous data
}Output (formatted fields):
{
// All previous data preserved
"firstName": "John",
"key": "eyJhbGciOiJSUzI1NiIs...",
"emailExists": false,
// Fields formatted
"phone": "555-123-4567",
"dob": "1990-01-15",
"sex": "M",
// Question answers formatted: Yes→1, No→0, null→2
"q123": 1,
"q456": 0,
"q789": 2
}POST /api/realtime/with-prescreen/send-to-rt
Receives Step 4's response, transforms question fields (q{question_id} → questions[{question_id}]), sends formatted data to RT V1 API (only if email doesn't exist), appends RT response with PatientID, and returns everything.
Input (from Step 4):
{
"StudyID": 12,
"ReferrerID": 25,
"instanceName": "erg-oct",
"firstName": "John",
"phone": "555-123-4567",
// Formatted question answers: 1 (Yes), 0 (No), 2 (null)
"q123": 1,
"q456": 0,
"q789": 2,
"key": "eyJhbGciOiJSUzI1NiIs...",
"emailExists": false,
// ... all previous data
}Output (input + RT V1 response):
{
// All previous data preserved
"StudyID": 12,
"firstName": "John",
"key": "eyJhbGciOiJSUzI1NiIs...",
"emailExists": false,
// RT request payload (what was sent)
"rtRequestPayload": {
"StudyID": 12,
"Phone": "555-123-4567",
// Questions transformed: q{question_id} → questions[{question_id}]
// Example: "q123" → "questions[123]", "q456" → "questions[456]"
"questions[123]": 1,
"questions[456]": 0,
"questions[789]": 2,
...
},
// RT V1 response appended
"rtResponse": {
"status": 0,
"PatientID": 25414,
"message": "Referral has been added to study."
}
}POST /api/realtime/with-prescreen/send-comments
Receives Step 5's response, extracts PatientID from rtResponse, sends formatted comments to RT V2 API, appends RT V2 response, and returns final result.
Input (from Step 5):
{
"instanceName": "erg-oct",
"condition": "Bunions",
"protocol": "1A2B3C",
"recruitmentStatus": "Qualified For Screening",
"photoUpload": "https://example.com/",
"key": "eyJhbGciOiJSUzI1NiIs...",
"rtResponse": {
"PatientID": 25414
},
// ... all previous data
}Output (input + RT V2 response):
{
// All previous data preserved
"instanceName": "erg-oct",
"key": "eyJhbGciOiJSUzI1NiIs...",
"rtResponse": {
"PatientID": 25414
},
// RT V2 response appended
"rtV2Response": {
"data": {
"subjectId": 25414,
"comment": "(11/24/2025 - Bunions - 1A2B3C)..."
},
"error": {},
"links": {}
}
}curl -X POST http://localhost:3001/api/realtime/with-prescreen \
-H "Content-Type: application/json" \
-d '{
"account": "ERG",
"StudyID": 12,
"ReferrerID": 25,
"instanceName": "erg-oct",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"phone": "555-123-4567",
"dob": "1990-01-15",
"sex": "M",
"zipCode": "12345",
"weight": "180",
"height": "72",
"ethnicity": "Hispanic",
"race": "White",
"condition": "Bunions",
"protocol": "1A2B3C",
"recruitmentStatus": "Qualified For Screening",
"photoUpload": "https://example.com/",
"q123": "Yes",
"q456": "No",
"q789": null
}'
// Account: "ERG" or "Futuro" (optional, defaults to "ERG")
// Prescreening questions format: q{question_id} with values "Yes", "No", or null
// Replace the question ID numbers (123, 456, 789) with your actual question IDs