Skip to content

Filter the API post list by status and content - #573

Merged
paulocastellano merged 2 commits into
mainfrom
api-posts-status-filter
Dec 3, 2026
Merged

paulocastellano merged 2 commits into
mainfrom
api-posts-status-filter

Conversation

@paulocastellano

Copy link
Copy Markdown
Contributor

What changes

GET /api/posts takes two new optional filters:

  • status: draft, scheduled, pending_approval, published or failed. Any other value returns a 422.
  • search: the posts whose text contains it, ignoring case.

They combine with the existing channels, labels and untagged filters.

Why

  • The MCP list-posts-tool already filtered by status and text, but the API did not. A parity test recorded the gap ("the api has no status filter while mcp filters by status").
  • The Zapier integration (ENG-20) needs these filters for its sample lists and its "Find Post" search.

How

  • Two new scopes, Post::withStatus() and Post::contentContains(). Each one does nothing when its value is empty.
  • ListPostsRequest validates the two fields and resolves status to the enum.
  • The API controller and the MCP tool use the same scopes. The MCP tool no longer keeps its own match.

Tests

  • The gap test is replaced by a parity test. Each status, the search and the search combined with a status return the same posts through the API and through MCP.
  • A second test checks that an unknown status is refused by both.
  • Both tests fail without the change.
  • PostsParityTest and PostApiTest pass on PostgreSQL. PostsParityTest also passes on MySQL.

Docs

  • The public API reference at docs.trypost.it needs the two new parameters on List posts.

Paulo Castellano added 2 commits December 3, 2026 16:20
GET /api/posts now takes status (draft, scheduled, pending_approval,
published, failed) and search, like the MCP list-posts tool already did.
Both go through the new Post::withStatus() and Post::contentContains()
scopes, so the two lists filter the same way.
Cover the list without filters, a publishing post no status selects,
and a status combined with a channel.
@paulocastellano
paulocastellano merged commit 71af9ad into main Dec 3, 2026
10 checks passed
@paulocastellano
paulocastellano deleted the api-posts-status-filter branch December 3, 2026 19:46
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.

1 participant