Skip to content

feat(subscribers): slim listing, API warnings, and filter - #18

Merged
imjohnbo merged 1 commit into
catchup/04-broadcastsfrom
catchup/05-subscribers
Aug 20, 2026
Merged

feat(subscribers): slim listing, API warnings, and filter#18
imjohnbo merged 1 commit into
catchup/04-broadcastsfrom
catchup/05-subscribers

Conversation

@imjohnbo

@imjohnbo imjohnbo commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Part 5 of 8. Base: #17.

What this adds

Slim listing:

kit subscribers list --slim

Filter:

kit subscribers filter --json '[{"type":"subscriber_state","states":["active"]}]'
kit subscribers filter --file conditions.json --include tags,stats --stats-start 2026-05-01

Request body changes

The API now documents two things about POST /v4/subscribers and PUT /v4/subscribers/{id}.

  1. Custom field keys are the field key, not the label. Use last_name, not Last Name.
  2. The API ignores an unknown key and reports it in a warnings array.

Create and update now print those warnings. A typo in --fields no longer passes silently. The --state help text lists all five states that the API accepts, and the CLI validates the value. The list filter separately accepts all, which is not a real state.

Design notes

The filter body nests too deeply for one flag per condition. It therefore comes from a file or an inline string. The CLI wraps a bare conditions array in the all object that the API wants. --counting-mode, --include, and the stats date range get their own flags.

Two related fixes ride along:

  • subscribers create and subscribers update now take --format, like the rest of the CLI.
  • printSuccess stays quiet under --format json. Piping into jq now works. Call sites that pass no options behave as before.

Open question for the reviewer

The spec declares no query parameters on POST /v4/subscribers/filter. Its response returns pagination cursors. This branch therefore sends per_page, after, and before as query parameters. If Kit expects them in the body, the fix is one line in src/commands/subscribers.js.

Review notes

Tests: 264 before, 306 after.

Closes #8
Closes #9
Closes #13


The stack

Merge from the top down. Each part builds on the one above it.

PR Contents
1 #14 Client query support and shared helpers
2 #15 Sequence CRUD and sequence emails
3 #16 Posts and snippets
4 #17 Broadcast filters, account-wide stats, link clicks
5 #18 (this one) Subscriber slim listing, warnings, filter
6 #19 Tag rename, remove-by-email, bulk delete
7 #20 Account endpoints and purchase create
8 #21 Spec coverage map and its tests

Base branch: main for part 1, the previous part's branch for the rest.
GitHub retargets each base to main as the part below it merges.

…lter

Three spec changes.

Slim listing (issue #9):
  kit subscribers list --slim

Request body changes (issue #8). The API now documents that custom field keys
are the field key, not the label, and that unknown keys are ignored and reported
in a warnings array. Create and update print those warnings, so a typo in
--fields no longer passes silently. The --state help text now lists all five
states the API accepts, and the CLI validates it. The list filter separately
accepts all, which is not a real state.

Filter (issue #13):
  kit subscribers filter --json '[{"type":"subscriber_state","states":["active"]}]'
  kit subscribers filter --file conditions.json --include tags,stats

The filter body is too nested for one flag per condition, so it comes from a file
or an inline string. A bare conditions array is wrapped in the all object the API
wants. --counting-mode, --include, and the stats date range get their own flags.

Two related fixes:
- subscribers create and update now take --format, like the rest of the CLI.
- printSuccess stays quiet under --format json, so piping into a JSON parser
  works. Call sites that pass no options behave as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kit API spec update: 5 changed Kit API spec update: 1 changed Kit API spec update: 3 changed

1 participant