crm-email

Schedule a CRM email campaign

Admin-only endpoint that persists a scheduled CRM email campaign. The audience is stored as criteria (stato/motivo filters resolved at send time, or an inline recipient_emails list) — never as materialized recipient rows — so a campaign is a single row regardless of how many patients it targets. Sending is performed later by the scheduled batch dispatcher.

post/api/campaigns

Request body

scheduled_atstring date-time required

When to send the campaign (timezone-aware).

subjectstring required

Email subject.

notesstring nullable

Internal note on why the campaign is being sent; shown in the CRM only, never emailed.

email_htmlstring nullable

Composed HTML body (image placeholders already replaced by URLs).

template_pathstring nullable

Storage path of the uploaded template under public/email/templates/.

placeholder_imagesobject

Map of placeholder name -> image public URL used to compose email_html.

patient_statesstring[]

Stato paziente filters. Combined with registration_reasons per filter_match at send time.

patient_filtersstring[]

Deprecated alias of patient_states (kept for the current frontend payload).

registration_reasonsstring[]

Motivo iscrizione filters. Combined with patient_states per filter_match at send time.

filter_match'any' | 'all'

How stato and motivo filters combine at send time: 'any' (OR, default) unions them; 'all' (AND) keeps only patients matching both a selected stato and motivo.

recipient_emailsstring[]

Explicit recipient email addresses (e.g. from an uploaded CSV). When present the campaign audience is this list. Capped at 50000 addresses.

Response

Successful Response

idstring required

Campaign UUID.

statusstring required

scheduled | running | sent | failed | cancelled.

scheduled_atstring date-time nullable

When the campaign will be sent.

subjectstring required

Email subject.

notesstring nullable

Internal note on why the campaign was sent; CRM-only.

audience_typestring required

'filters' or 'csv'.

audience_sizeinteger nullable

Recipient count for a csv audience; null for a filter audience (resolved at send time).

created_atstring date-time required

When the campaign was created.

Changes

No recorded changes to this endpoint across all 1 revision of this API.