Repository navigation
Description
Problem
A subscriber today has email, name, and status. Nothing else. For real email marketing this is too thin — you cannot personalize beyond first name, you cannot segment by anything domain-specific (plan tier, country, signup source, birthday), and you cannot use CSV imports that bring more than two columns without losing data.
The subscribers.metadata JSONB column already exists in the schema (added in 20260416222552_create_subscribers_table.sql) but no query or handler reads or writes it. The storage is dormant — what is missing is the feature surface around it.
Proposal
A typed, project-scoped custom-fields system on top of the existing metadata column.
Data model
New table subscriber_field_definitions (project-scoped schema):
CREATE TABLE subscriber_field_definitions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
key VARCHAR(64) NOT NULL, -- e.g. "plan_tier", "birthday"
label VARCHAR(128) NOT NULL, -- human label for UI
field_type VARCHAR(20) NOT NULL, -- string | number | date | boolean | enum
options JSONB, -- for enum: ["free","pro","team"]
required BOOLEAN NOT NULL DEFAULT false,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(project_id, key)
);Subscriber values keep living in the existing subscribers.metadata JSONB, addressed by key:
{ "plan_tier": "pro", "birthday": "1990-05-12", "country": "CO" }Validation happens on write against the field definitions of the subscriber's project. Unknown keys are rejected (no schema drift).
API
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/projects/{id}/fields |
Create a field definition |
GET |
/api/v1/projects/{id}/fields |
List field definitions |
PATCH |
/api/v1/projects/{id}/fields/{fieldId} |
Update label / options / required |
DELETE |
/api/v1/projects/{id}/fields/{fieldId} |
Delete definition (keeps the data in metadata until the next subscriber write) |
Subscriber endpoints accept and return fields: {...} (alias of metadata filtered through the project's definitions). Bulk import (/subscribers/import) accepts a column mapping { "Plan": "plan_tier", "Country": "country" }.
UI
- New Custom Fields sub-tab in project Settings → CRUD for definitions, type picker, required toggle.
- Subscribers section: the table gets configurable columns from the project's fields; the add/edit modal renders the right input per type (text / number / date picker / dropdown for enum).
- CSV import wizard: when uploaded columns don't match a known field, prompt the user to map or create a new field inline.
Template integration
Template variables gain a custom.* namespace, available in Handlebars and pickable in the variables sidebar of the editor:
Hi {{first_name}}, your {{custom.plan_tier}} plan renews on {{custom.renewal_date}}.
When inserting a variable from the picker, the dropdown lists the project's defined fields with their human labels.
Interaction with #40 (tags + segments)
Custom fields unblock the typed-filter half of segments. With #40 alone, segments can filter by tags + status. With custom fields shipped, segments gain custom.plan = "pro", custom.signup_date > 30 days ago, etc. The two issues should ship in either order, but segments are weak without custom fields.
Acceptance criteria
- A project owner can create, edit, and delete custom field definitions
- Field types supported: string, number, date, boolean, enum (with options)
- Subscriber create / update / bulk-import endpoints validate values against the project's definitions; unknown keys rejected
- Subscriber list table shows custom field columns (toggleable)
- Subscriber detail modal renders the correct input per field type
- CSV import maps headers to fields, with inline creation for unmapped columns
- Template editor exposes
{{custom.*}}variables in the picker with their labels - API endpoints documented at docs.senddock.dev/api/subscribers (new "Custom fields" section)
Tier
Core — custom fields are table stakes for any subscriber-based platform, including the free tier. Gating them would make the free tier feel artificially crippled vs Mailchimp / EmailOctopus / Listmonk, all of which offer custom fields without a paywall.
Activity
JuansesDev commentedon Jul 6, 2026
Implemented in commit 7585f36 (
feat(subscribers): typed custom fields and tags, 2026-07-04). The commit didn't reference this issue, so it wasn't auto-closed.Summary of what was delivered, against the acceptance criteria:
subscriber_field_definitionstable — migration20260705000000_create_subscriber_field_definitions.sqlPOST/GET/PATCH/DELETE /api/v1/projects/{id}/fields(internal/handler/field_definition.go,internal/service/field_definition.go)fields: {...}(alias ofmetadata) —internal/handler/subscriber.go,internal/response/response.goservice.ValidateFields()SubscribersSection.vue+BulkImport()CustomFieldsSettings.vue), configurable columns in the subscribers table, per-type inputs in the modal (SubscriberFieldInputs.vue){{custom.*}}namespace in the variable picker and in rendering (email.go: replaceCustomVariables())Bonus: integration with the segment builder (
custom.*predicates), related to #40.Only minor pending item: public documentation at docs.senddock.dev/api/subscribers ("Custom fields" section). If we want to track it, better to open a separate docs issue than keep this epic open.