Shrink API payloads without changing the response contract
Use field selection, pagination defaults, and compression on workspace, list, and detail endpoints. A screen asks for only the fields and rows it shows, a list returns one page at a time, and a response is compressed when the browser can read it. The envelope stays the same, so a client can read dates, missing values, empty lists, and identifiers in the same way on every endpoint. Measure what a list page transfers before you open a record, return only the fields a row needs, move full text to the detail view, and paginate every list at a fixed page size. This page audits workspace, answer, and source list and detail views, states the trimmed contract for each view, and shows byte savings per page in a worked example.
Measure a payload before you change it
Record the same request before and after the change, with the same college workspace, assistant, channel, filters, sort, limit, and offset. Change one thing at a time, so the byte change can be read from the record.
Step 1: Run the request with no compression and record the size
Send the list or detail request with an explicit limit and offset. Record the HTTP status, the Content-Length when the server sends it, and the size of the body as received. Record the number of rows returned and the fields present in each row.
Step 2: Run the same request with compression accepted
Send the same request with gzip or brotli accepted. Record the Content-Encoding when the server sends it and the size of the body as received on the wire. Compare the wire size with the size in Step 1. Do not compare a compressed size with an uncompressed size as if they were the same measure.
Step 3: Compute bytes per row and rows per request
Divide the body size by the number of rows returned. A list that returns many rows with full detail has a high bytes per row. A list that returns a small page with summary fields has a lower bytes per row and fewer rows. Both numbers must fall after the change, or the change does not shrink the payload.
Step 4: Confirm the contract after the change
Confirm a success response still has ok set to true with values in data, an error response still has ok set to false with a plain message in error, an empty list is an empty array and never null, a missing value is null, a zero count is 0, times are ISO 8601 in UTC, date only values are YYYY-MM-DD, and identifiers are strings passed back unchanged. Confirm the HTTP status for the endpoint did not change in the same release as the payload change.
Measurement record to keep for each endpoint
| Field | What to record |
|---|---|
| Endpoint and filters | Route, college workspace scope, assistant, channel, date range, sort, limit, offset, and fields requested |
| Rows returned | Number of rows in data items, plus data total, data limit, data offset, and data hasMore |
| Fields per row | Field names present in a list row, and field names present in a detail response |
| Body size and encoding | Body size as received, Content-Encoding when sent, and bytes per row |
| Contract check | Envelope shape, status code, null and empty list rules, date format, and identifier type, before and after |
Example only. The arithmetic in this guide uses example row counts to show the method. It does not state a measured size for a college workspace in production.
Field selection for list and detail endpoints
A list shows summary fields. A detail view shows full fields. A list must not return full question text, answer text, or passage text for every row when the screen shows only a title, a status, and a date.
List endpoints return summary fields by default
- Default list fields are the summary fields the screen shows, such as id, title, status, and updated time, as in the sample list in the app kit guide
- Full text fields stay out of a list response unless the screen renders that text in the list row
- A detail response for one record may return the full fields for that record, with the same envelope and the same status code as the list endpoint for that record
- Unknown field names in a fields request are ignored. They do not widen the college scope, add a record from another college, or change a status code
Fields request rule
- A screen may name fields with a fields parameter that lists field names from the allowlist for that endpoint
- The server returns only allowlisted fields that were requested, plus the fields the screen needs to page and to link, such as id, total, limit, offset, sort, and hasMore
- When no fields parameter is sent, the server returns the default summary fields for a list and the default fields for a detail response
- The applied field list is not added as a new top level field. The envelope stays ok, data, and error, with values inside data
Over-fetching checks
- Open a list screen and confirm the request returns one page of summary rows, not every row in the workspace and not full detail for every row
- Open a detail view and confirm full fields are requested only for that one record
- Search a list and confirm the request sends the search words, filters, sort, limit, and offset together, so the server filters and pages in one request instead of returning every row for the browser to filter
- Change a filter and confirm only one new list request is sent, after the short pause for typing, with the applied filters echoed in the response
Audit: where list views over-fetch
Each row names the view, the fields a row display needs, and the fields that belong only in the detail view. No new field, role, or permission is added by this page.
| View | Fields the row needs | Fields to move to detail only | Risk if the row keeps them |
|---|---|---|---|
| Answer list | Record id, title, college workspace, assistant, status, source title, source link, last checked date, created and updated dates, and counts for helpful and not helpful | Full question text, full answer text, each source body, history entries, rating comments, and handoff reference detail | Every row pays for full answer and source text, so page size grows with answer length instead of row count |
| Source list | Record id, source title, owner office, status, review date, linked assistant count, and updated date | Full source body, approval history, test notes, and linked question text | A source list pays for every source body, even for sources the reader never opens |
| Workspace list | Workspace id, college name, assistant count, open question count, and updated date | Member list, each member role detail, retention and access settings detail, and per assistant breakdown | A workspace list pays for member and settings detail for every college, and exposes detail the row never shows |
| Answer detail | Full question, full answer, each source title, source link, and last checked date, rating, discussion, and handoff in that record | Nothing in this row. This view is the one place full text belongs | None. Full text is correct here when the record is opened on demand |
| Source detail | Full source body, owner office, status, review date, approval record, and linked assistants | Nothing in this row. This view is the one place the full body belongs | None. Full body is correct here when the record is opened on demand |
Public guide lists follow the same rule: a guide list returns title, description, and link per guide, and full guide text loads only on the guide page. See Search scope for list scope labels.
Trimmed and paginated response contract, per view
Apply every rule in one change. A list response contains no body field. A detail response is requested only when a row is opened.
| View | List fields returned | Page size and order | Detail fields added on open |
|---|---|---|---|
| Answer list | Id, title, workspace, assistant, status, source title, source link, last checked date, dates, and rating counts. No answer body, no source body, no history | 50 per page by default, 200 as the stated maximum, newest updated first, with limit and offset for the next page, hasMore, and a total count from the server index | Full question, full answer, each source body reference, history, rating comments, discussion, and handoff in that one record |
| Source list | Id, title, owner office, status, review date, linked assistant count, and updated date. No source body, no approval history | 50 per page by default, 200 as the stated maximum, review date nearest first where that sort is chosen, otherwise newest updated first, with limit and offset and a total count | Full source body, approval record, test notes, and linked assistants for that one source |
| Workspace list | Id, college name, assistant count, open question count, and updated date. No member list, no settings detail | 50 per page by default, 200 as the stated maximum, college name in order, with limit and offset and a total count | Member list with roles, retention and access settings, and per assistant counts for that one workspace |
- One page size for every list, 50 by default and 200 as the stated maximum, so a page cost is predictable
- Limit and offset pagination only, with hasMore returned and a total count returned from the server index
- Server side sort and filter in one college workspace at a time, with the same workspace, assistant, channel, and date range filters on the list and on the count
- A detail request returns one record only, so opening one row adds one body, not a page of bodies
- An empty list returns a zero count, the filters as applied, and the empty state for that list, with no body field
Pagination defaults that shrink bytes per request
Use one default page size on every list endpoint. A smaller default page returns fewer rows per request, and the screen asks for the next page only when the person pages.
Defaults to ship
- Default limit is 50 rows per request
- Maximum limit is 200 rows per request, matching the documented sample maximum
- Default offset is 0, and offset at or past the total returns an empty items array with the total unchanged
- Every list response returns total, limit, offset, sort, filters, and hasMore inside data, so the screen can show the page position and the count shown
- Every sort ends with the record id in ascending order as a tie break, so a page boundary does not move a row between pages
Worked arithmetic, example only
Example only. One request at a limit of 50 returns at most 50 rows. One request at a limit of 200 returns at most 200 rows. With the same bytes per row, the 50 row request transfers about one quarter of the rows of the 200 row request.
Example only. When a list row drops full text fields and keeps summary fields, bytes per row falls as well. The total saving for a request is the saving from fewer rows multiplied by the saving from fewer bytes per row. Record both numbers from the measurement steps above.
- Do not state a saving for a college workspace until the same request has been measured before and after with the same filters
- Do not load every row to show a count. Return total with the page, and show the count from total
- Show a pager only when total is more than the applied limit, and keep the same filters on every page
Follow List pagination, sorting, and filtering for the full request and response contract, and Empty states for the empty list shown when total is zero.
Efficient encoding and nested-expansion ban
Ship these rules with the trimmed contract in the same release. Encoding shrinks the wire size, never the contract, and a nested expansion is never used to fetch a body the row does not show.
| Rule | Ship value | Contract preserved |
|---|---|---|
| Encoding preference | Send brotli when Accept-Encoding includes br, otherwise gzip when it includes gzip, otherwise identity. Never send an encoding the request did not accept. | Decoded JSON is identical, the envelope stays ok, data and error, and status codes do not change. |
| Threshold and Vary | Compress only bodies of 1024 bytes or more. Send Vary with Accept-Encoding on every compressible response. Do not compress 204, 304, already compressed, or smaller bodies. | A cache never serves a compressed body to a browser that did not accept it, and small responses do not grow. |
| Nested expansion ban | Do not accept expand, include, with or nested body parameters on a list endpoint. Use the allowlisted fields parameter and the detail endpoint for one record, for example a list request with fields equal to id, title, status and updated_at and limit 50. | Unknown fields are ignored, college scope never widens, and one detail request returns one body only. |
| Caching with encoding | Signed-in API responses stay private and no-store even when compressed. Content-hashed files under assets can be cached long, unhashed files use a short maximum age with revalidation. | A smaller wire size never reuses a signed-in response across people or colleges and never puts a long-lived cache on an unhashed file. |
Worked example: byte savings per page
Example only. Figures use the example record sizes in this table, not production measurements. Use the estimator below with measured sizes from your own network panel to replace them.
| View | Untrimmed bytes per record | Trimmed bytes per record | Saving per record | Saving per 25 row page |
|---|---|---|---|---|
| Answer list, example | 8400 | 620 | 7780 bytes, 92.6 percent | 210000 bytes down to 15500 bytes, saving 194500 bytes per page |
| Source list, example | 6200 | 480 | 5720 bytes, 92.3 percent | 155000 bytes down to 12000 bytes, saving 143000 bytes per page |
| Workspace list, example | 3100 | 340 | 2760 bytes, 89.0 percent | 77500 bytes down to 8500 bytes, saving 69000 bytes per page |
- Answer list, example record mix: answer text 2000 bytes, source body 4000 bytes, history 1200 bytes, question 500 bytes, other fields 700 bytes, total 8400 bytes. Trimmed row keeps id, title, workspace, assistant, status, source title, source link, last checked date, dates, and counts, total 620 bytes.
- Source list, example record mix: source body 4500 bytes, other fields 1700 bytes, total 6200 bytes. Trimmed row keeps title, owner office, status, review date, linked count, and updated date, total 480 bytes.
- Workspace list, example record mix: member and settings detail 2100 bytes, other fields 1000 bytes, total 3100 bytes. Trimmed row keeps college name, assistant count, open count, and updated date, total 340 bytes.
- Detail on demand, example: opening one answer detail adds 8400 bytes once. One trimmed page plus one detail is 23900 bytes, against 210000 bytes for the untrimmed page alone, saving 186100 bytes in that open flow.
- Public guide list, example: 26 guide titles with full text at 4000 bytes each is 104000 bytes. Cards at 300 bytes each is 7800 bytes. Saving is 96200 bytes when full text loads only on the guide page.
Estimate savings for your own page size
Enter a page size and example record sizes. Nothing entered here is sent to a server.
Choose a preset or enter your own sizes, then choose Estimate savings.
Compression and caching for API responses
Compress a JSON response only when the browser states it can read the encoding. Keep signed-in responses private and unstored, so a smaller payload never reuses a response across people or colleges.
Compression rules
- Send Content-Encoding with brotli preferred, otherwise gzip, only when the request accepts that encoding
- Send Vary with Accept-Encoding on a response that can be compressed, so a cache does not serve a compressed body to a browser that did not accept it
- Do not compress a body below 1024 bytes, that is already compressed, or a 204 or 304 response, where compression would add bytes instead of saving them
- Record the encoding and the wire size in the measurement record, so a compressed size is never read as an uncompressed size
Caching rules that stay in place
- Signed-in API responses use private, no-store, with no shared cache and no stale copy, even when compressed
- The public live check and the public form endpoint use private, no-store, with no ETag reuse
- Content-hashed files under assets can be cached for one year with immutable, and unhashed files such as site style and script files use a short maximum age with revalidation, as stated on the caching page
- Do not set a long lived cache on a signed-in API response to shrink bytes. Shrink the fields and the page size instead
Read Caching strategy for headers by resource class, and Status for the serialization convention that every response follows.
Client rules for workspace, list, and detail screens
A screen asks for one page of summary rows, then asks for one detail record when the person opens it. It does not fetch every row and every detail to render a list.
- Send limit and offset on every list request, and send the fields the screen renders in that list, with no nested expansion parameter
- Keep the page heading and filter controls visible when a list is empty, show one empty state per list, and announce the count shown and the total in a status region
- Use the short pause while typing, replace the page address while typing, and push a history entry only on a discrete change such as a filter, sort, clear, or pager choice, as stated in the pagination guide
- On a detail view, request one record by id, render its full fields, and do not refetch the list to show the detail
- Do not poll a list or a detail endpoint. A check runs on page load and only again when the person chooses to check again
Page payload rules for public pages
Keep the public site list and detail split the same way as the signed-in lists.
- Guide and terminology lists return title, description, and link per entry. Full guide text loads only on the guide page
- Scripts load with defer, styles load once per page with preload, and below fold sections use content visibility so a first paint does not parse every section at full cost
- No body field, search word, or question text is added to a list payload to make a row look richer. The row shows the fields in the contract table
- Detail pages keep their full text, source links, and last checked dates. Trimming a list never removes a field from the detail view that opened it
Checks before you ship a payload change
Run each check on phone and desktop, in one college workspace, before you publish.
- The same list request measured before and after shows fewer rows per request, fewer fields per list row, a smaller body size as received, and a lower bytes per row
- The envelope, status codes, date format, null and empty list rules, and identifier type are unchanged, and a legacy client reader still parses the new shape
- An invalid limit, offset, sort, or field name falls back as stated and echoes the applied value, and never widens the college scope
- A record from another college never appears in items or in total, and test sessions are excluded from items and total and labeled as excluded
- A compressed response is sent only when accepted, with brotli preferred, Vary is sent on a compressible response, no body below 1024 bytes is compressed, and signed-in responses remain private with no-store
- Page one and page two together hold every filtered row once, with no row repeated and no row skipped, and the total matches the count on screen on both pages
- A list page transfers the trimmed size in the contract table for its view, measured in the network panel, and no body field appears in the list payload
- Opening one row adds one detail payload only, and the detail shows full text with source title, source link, and last checked date
- Page 2 and later pages load with the next offset, keep the same filters and sort, and return the same total count
- An empty list shows one empty state with a count of zero, keeps filters visible, and focus stays on the filter control
- Each row keeps label, field order, and readable text at phone widths, with tap targets of at least 44 pixels
- Counts on the list and on the detail match, and no count is read without the workspace, assistant, channel, and date range beside it
Follow Read reports for counts by college and assistant, Configuration and safe defaults for shipped values, and Security and privacy for how material is kept.
Next guide
Use one list contract on every screen, from a public guide list to a signed-in source list. Read the numbers, then work the largest gap first.