Skip to content

Distributions API

Send a survey to contacts in a single API call. This endpoint handles the full workflow:

  1. Resolves/upserts contacts — by externalId, contactId, or email
  2. Creates a mailing list — auto-generated for this distribution
  3. Creates the distribution — with channel configuration, recipients, and personal links
  4. Sends immediately — or schedules for later if scheduledAt is provided

Endpoint: POST /api/surveys/{surveyId}/distributions/quick

A hospital HIS/EMR system sends a patient satisfaction survey after discharge:

Terminal window
curl -X POST "https://fikrr.diwakarmaurya.com/api/surveys/${SURVEY_ID}/distributions/quick" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"surveyId": "0195e3a1-0000-7000-8000-000000000001",
"contacts": [
{
"externalId": "PAT-12345",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"embeddedData": {
"department": "Cardiology",
"visitDate": "2026-03-05",
"attendingDoctor": "Dr. Smith",
"dischargeDate": "2026-03-05"
}
}
],
"channels": [
{
"channel": "email",
"providerId": "PROVIDER_UUID",
"templateId": "TEMPLATE_UUID"
}
],
"name": "Post-discharge CSAT - March 2026"
}'
FieldTypeRequiredDescription
surveyIdUUIDYesTarget survey (also in URL path)
contactsarrayYes1–1,000 contacts to survey
channelsarrayYesAt least one channel configuration
channelModestringNosingle (default) or multi
scheduledAtISO 8601 datetimeNoSchedule for future send; omit for immediate
settingsobjectNoDistribution settings (see below)
namestringNoDistribution name for reference (max 255 chars)
FieldTypeRequiredDescription
externalIdstringNo*External system identifier (max 255 chars)
contactIdUUIDNo*Existing contact ID
emailstringNo*Contact email
firstNamestringNoFirst name
lastNamestringNoLast name
phonestringNoPhone number
embeddedDataobjectNoCustom data accessible in survey via piped text ${contact:key}

*Each contact must have at least one of externalId, contactId, or email.

FieldTypeRequiredDescription
channelstringYesemail, sms, or whatsapp
providerIdUUIDYesChannel provider ID (must belong to your org)
templateIdUUIDYesMessage template ID (must match the channel)
prioritynumberNo1–10 (default: 1)
fromEmailstringNoSender email override (email channel only)
fromNamestringNoSender name override
replyToEmailstringNoReply-to email override
fallbackDelayMinutesnumberNoMinutes before trying the next channel (multi mode)

Contacts are resolved in this priority order:

  1. contactId — direct lookup by ID; returns 404 if not found
  2. externalId — upsert: creates a new contact if not found, updates if found (merges embeddedData)
  3. email — lookup by email within the org; creates if not found
{
"distributionId": "0195e3a1-0000-7000-8000-000000000010",
"mailingListId": "0195e3a1-0000-7000-8000-000000000011",
"recipientCount": 1,
"personalLinks": [
{
"externalId": "PAT-12345",
"contactId": "0195e3a1-0000-7000-8000-000000000002",
"email": "john.doe@example.com",
"personalLinkCode": "aBcDeFgH"
}
],
"status": "sending"
}
FieldTypeDescription
distributionIdUUIDThe created distribution ID
mailingListIdUUIDThe auto-created mailing list ID
recipientCountnumberNumber of eligible recipients
personalLinksarrayPer-recipient personal link codes
statusstringsending (immediate) or scheduled

The personalLinkCode can be used to construct a direct survey URL: https://your-domain/p/{personalLinkCode}

{
"settings": {
"excludeOptedOut": true,
"respectFrequencyRules": true,
"excludeRecentlyContacted": false,
"recentContactDays": 30
}
}
SettingDefaultDescription
excludeOptedOuttrueSkip contacts who have opted out
respectFrequencyRulestrueHonor minimum days between contacts
excludeRecentlyContactedfalseSkip contacts contacted within recentContactDays
recentContactDaysNumber of days to consider “recent” (1–365)