GET /api/docsites/by-slug/:slug
Summary
Retrieves a doc site by its URL slug, with optional preview token support for non-public sites.
Intent
Allows clients to fetch a doc site’s data using a human-readable slug identifier, enabling public access to published doc sites and gated preview access to private ones via a token.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| slug | string | Yes | The URL slug uniquely identifying the doc site. |
| token | string | No | A preview token required to access non-public doc sites. Must match the site’s previewToken. |
Request example
curl -X GET "https://maps.google.com/api/docsites/by-slug/my-api-docs" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json"Response example
{ "docSite": { "id": "ds_abc123", "slug": "my-api-docs", "isPublic": true, "previewToken": null, "name": "My API Documentation" }}Error cases
404— No doc site exists with the given slug.404— The doc site exists but is not public and no token was provided, or the provided token does not match the site’s previewToken.
Gotchas
- Non-public doc sites return a 404 (not a 401 or 403) when accessed without a valid token — this is intentional to avoid leaking the existence of private sites.
- The preview token must be passed as a query parameter named ‘token’, not in the Authorization header.
- A missing doc site and an unauthorized access to a private doc site return identical 404 responses, making it impossible to distinguish the two cases from the client side.