On this page
An API tutorial’s sample URLs often get copied into terminals, applications, and automated tests. Before publishing, replace accidental production or internal hosts with safe example URLs, and make it clear which parts readers must change.
Key Takeaways
- Use a documentation-reserved hostname such as
example.comwhen an example does not need to reach a real API. - Label the hostname, path, and query parameters separately. A reserved hostname does not make a URL a functioning API endpoint.
- Remove real credentials and internal service names from examples, including generated and downloadable files.
- Review the final published artifacts, not just the tutorial’s source Markdown.
Choose a safe example host
For a nonfunctional example, use a reserved documentation domain such as example.com rather than a made-up company domain or a real production API. A domain that merely looks fictional might be registered or become registered later.
https://example.com/api/v1/widgets?limit=10&sort=name
The hostname is a documentation example; the path and parameters illustrate a hypothetical API. Do not present this URL as an endpoint readers can successfully call. Even with a reserved hostname, avoid automatically sending requests to it: using an example name is not a network security control.
If the tutorial requires real responses, use an environment you control and are authorized to expose for that purpose. Explain how readers can obtain access, what the environment contains, and any usage limits. Keep demo data and credentials separate from production.
Research limitation: IANA’s special-use domain guidance and the relevant RFCs were not available for consultation for this article. Verify that guidance before prescribing other example hostnames, address ranges, or DNS behavior. This article does not recommend an IP address range for examples.
Advertisement
Separate the host, path, and query parameters
Use a concrete URL and annotate its parts instead of leaving readers to guess what to replace:
| Part | Example | Reader action |
|---|---|---|
| Scheme | https | Use the scheme required by the target API. |
| Host | example.com | Replace with the documented host for the reader’s authorized environment. |
| Path | /api/v1/widgets | Replace with the API’s actual endpoint path. |
| Query | limit=10&sort=name | Use parameters and values supported by that endpoint. |
In this example, limit and sort are illustrative, not claims about an existing API. Describe whether each parameter is optional, what values it accepts, and how it affects results when documenting a real endpoint.
When readers must insert their own values, label them outside the URL or use an unmistakable template:
https://<YOUR_API_HOST>/<YOUR_ENDPOINT_PATH>?<PARAMETER>=<VALUE>
This is a template, not a URL to run as written. In real requests, query values may need URL encoding; use a URL-building library rather than concatenating untrusted values into a string.
Remove production and internal details
Copying a real request can expose more than the endpoint:
- Production hosts and paths: These can send copied requests to live systems. A write request can change data if a reader has valid access.
- Private service names: Internal hostnames can reveal infrastructure naming and confuse readers whose networks resolve names differently.
- Credentials: API keys, bearer tokens, cookies, signed URLs, and passwords can grant access or disclose information. Query strings are particularly easy to propagate through logs and copied links.
- Sensitive data: Request and response bodies, headers, error messages, and screenshots may contain customer identifiers or other private information.
Replace sensitive values with clearly labeled placeholders, and use fictional data that cannot be mistaken for actual customer records. A placeholder token is not an authentication setup: tell readers how to obtain and store their own credentials through the API provider’s authorized process.
If a real credential has already been exposed, remove it from the material and follow your organization’s incident process, including revocation or rotation. Removing text from a page alone does not invalidate a credential or erase copies.
Advertisement
Run a pre-release review
Review both the source and the artifacts readers will actually receive:
- Inventory examples. Check code blocks, command-line snippets, configuration files, notebooks, screenshots, and sample requests and responses.
- Inspect downloadable material. Open archives and example projects; check bundled configuration, test fixtures, and comments as well as executable code.
- Build and inspect generated documentation. Review rendered pages, generated API examples, downloadable specifications, and any interactive request controls. A generator may pull a host or credential example from a separate configuration file.
- Search for leaks. Look for known production domains, internal hostname patterns, credential formats, authorization headers, cookies, and signed query parameters. Include encoded or generated content where applicable; automated searches can miss unfamiliar formats.
- Check behavior. Confirm that copyable commands identify the values readers must replace and do not silently target production. Review non-read-only requests especially carefully.
- Assign a final owner. Have someone with access to the API’s documentation and security requirements review exceptions, then repeat the checks after significant regeneration or release changes.
A text search is a useful backstop, not proof that an artifact is clean. Also inspect whether the generated documentation or downloadable examples contain data that was not present in the source tutorial.
Common Mistakes
- Treating an arbitrary fake-looking domain as reserved. Use a documentation-reserved domain or an appropriately controlled demo environment instead.
- Assuming an example URL is a working service. State explicitly whether readers should replace the host or provision a demo environment.
- Reviewing only visible code blocks. Generated pages, archives, and configuration files can retain old hosts or secrets.
- Replacing a token but leaving sensitive query parameters or response data. Review the whole request and response, not just the authorization header.
- Relying on an example hostname as a security boundary. Prevent unintended requests through application configuration, access controls, and appropriate network controls.
Best Practices
Keep a small, approved set of example conventions for your documentation team: a reserved host for nonfunctional examples, a separate process for live demos, and a consistent placeholder style. Add leak checks to the publishing workflow, but retain human review of generated artifacts and exceptions.
Conclusion
Safe example URLs make copying a tutorial less likely to expose data or target the wrong system. Use a reserved hostname for nonfunctional examples, label every part readers must customize, and review the final downloadable and generated materials before release.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.