Resources and names
An account, a project, a website, a page, a block, a menu item, a media file, a setting: a persisted thing with an identity, addressed by a name that spells out where it sits.
The name is the handle to store — not the URL, which carries a host and a version that may
change, and not the display_name, which is a label a person edits. Given a name, the URL
it is served at is a prefix away, which is why a client that keeps names can walk the
hierarchy without a table of endpoints:
Code
5. Resources and resource names
A resource is a persisted thing with an identity. A collection is a set
of resources of one type, addressed by a plural snake_case id.
A resource name is the path from the root collection to the resource, with no leading slash and no version:
Code
Rules:
- Collection ids are plural,
snake_case, and identical to the path segment, thenamefield, and the List-response array field. One spelling. - Names alternate collection id and resource id, always starting with a collection id and ending with a resource id (a singleton ends with its singular collection id — §9).
- A resource id is opaque to clients. Ours are Mongo ObjectIds, except
settings, whose id is its dotted path, andviews, whose overlay id is the view it overlays. - Every resource MUST carry its own name in an output-only
namefield, and MUST also carryid— the final path segment, output-only.idis a documented convenience (D3);nameis the identity.
6. URL mapping
A resource name maps to a URL by prefixing the surface and the version:
Code
so websites/{w}/cms_pages/{p} is served at
/tenant-api/v1/websites/{w}/cms_pages/{p}, and a collection is the same URL
truncated after the collection id.
- Path parameters MUST be
snake_caseand MUST match the field they carry:{website_id}, never{websiteId}. - A URL MUST NOT contain a verb as a path segment. Verbs are custom methods and
use the
:separator (§10). - A URL MUST NOT contain a file extension.
- No trailing slash. A request with one gets
301to the canonical form.