Repository navigation
docs: document Templates search and the search query language - #598
Draft
danielfsousa wants to merge 4 commits into
Draft
danielfsousa wants to merge 4 commits into
danielfsousa wants to merge 4 commits into
Conversation
The API Blueprint parser accepts a fixed list of HTTP methods, and QUERY is not on it. It drops an action heading such as `### Search Templates [QUERY /v1/templates]` with an "unexpected header block" warning, and merges that action's requests into the action above. parseApiBlueprint now swaps QUERY for MKCOL in action headings before parsing, and renames MKCOL back to QUERY on every parsed request. No page uses MKCOL, and a page that does fails the build.
Add a Search page to the Introduction category. It covers the request body, the query language, limits, consistency, pagination, the response envelope, errors, and the Templates field table with its Default fields. Add the Search Templates action, QUERY /v1/templates, after List all Templates, which now points to it for accounts past 50,000 templates. Refs SparkPost/email-monorepo#964
:= is now the exact match and = is ordinary text. Fragments of any length match, so the three-character minimum and its name:ab example are gone. The body cap is 64 KB, include adds total_count, Templates sort by last_update_time or created_at only, and last_updated is an alias. The examples and error positions come from the search service. Refs SparkPost/email-monorepo#964
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs SparkPost/email-monorepo#964. Refs SparkPost/email-monorepo#956, the query grammar. Refs SparkPost/email-monorepo#948, the epic.
Important
Do not merge before the production phase 3 Soak ends. Merging this PR is Publication: it makes the search API public and starts the freeze on searchable field types in ADR search-api-query-grammar. It stays a draft until then, so reviewers can read the deploy preview from production phase 1.
Summary
List all Templates returns at most a customer's first 50,000 templates, and the API reference offers no way past that cap. This PR documents the Templates search endpoint,
QUERY /api/v1/templates, and the query language that every searchable resource will share. It also fixes the parser so that aQUERYaction renders at all.Changes
content/api/search.apibis a new Search page in the Introduction category. It covers the request body, the query language with its grammar, the limits, consistency, cursor pagination, the response envelope with the optionaltotal_count, the errors with their positions, and the Templates field table with its Default fields and aliases.content/api/templates.apibgains the Search Templates action after List all Templates. It has the body fields, one worked request, a 200 with two rows, a 400 with a position, and a request that follows the cursor. List all Templates gains one sentence that points to it.content/api/table-of-contents.jsonlists the Search page after Overview.plugins/gatsby-transformer-api-blueprint/parse-api-blueprint.jslets an action useQUERY. The API Blueprint parser accepts a fixed list of methods, andQUERYis not on it. Without the fix, the parser drops the heading with an "unexpected header block" warning and merges Search Templates into List all Templates. The parser now readsQUERYasMKCOL, which no page uses, and renames it back on every request. A page that usesMKCOLfails the build.What changed since the first draft
The grammar changed after the first draft of this PR on 2026-09-25, and the pages now follow what the service ships:
=matches the whole value:=matches the whole value, and=is ordinary text:fragment needs three characters, andname:abwas the 400 examplewelcome status:nopeat 15name,id,statusor a datelast_update_timeorcreated_atinclude: ["total_count"]addstotal_count, counted up to 10,000last_updatedlast_updatedis an alias oflast_update_timeChoices worth knowing
docs-devsiteskill. The examples match the OpenAPI document in SparkPost/email-monorepo#1462, which lists every valid query on the Search page, so the service's CI parses each one.sortandincludemembers are described in each attribute's text. The site's Data Structure renderer drops the members of anarray[object], and aDefaulton one fails server rendering.QUERYrenders in the default text colour.Transition.jscolours onlyGET,POST,PUT, andDELETE.welcome status:nope. CONTRIBUTING.md caps an action at two requests, and the second one follows the cursor.Proof
Run locally on 2026-11-09 at commit
e2093a9b, withnpm run docson Node 16.14.0.query.Parseinsearch-apiwith the Templates fieldssearch-apihandler,QUERY /api/v1/templates400 {"errors":[{"code":"invalid_search_query","message":"status is one of draft, published, published_with_draft","position":15}]}templates.apibQUERY Search Templatessits betweenGET List all TemplatesandPOST Create an RFC 822 Template. One "already defined" warning more thanmain, which every action on/v1/templatestriggers/api/search//api/templates/templates-query-search-templatesresolves, and the method renders asQUERY /api/v1/templates/api/...#...target exists on its pageVerification
The Search page lists every section. Its Templates field table names the Default fields and the
subaccountandlast_updatedaliases, and marks only the two date fields sortable.Search Templates sits after List all Templates with the method
QUERY. It has two requests, a 200 and a 400 on the first, and a 200 on the second.The parser reads the action as
QUERYand keeps its heading. Run it fromplugins/gatsby-transformer-api-blueprintafternpm run bootstrap.node -e "require('./parse-api-blueprint')(require('fs').readFileSync('../../content/api/templates.apib','utf8')).then(r=>{r.api.resourceGroups.forEach(g=>g.resources.forEach(x=>x.transitions.forEach(t=>console.log(t.method.toValue(),t.title.toValue()))));console.log(r.annotations.toValue())})"