Technical
Write Integration Tutorials with Clear Prerequisites
Build tutorials that work from a clean starting state, with explicit runtime, permissions, configuration, expected results, failure handling and teardown.
By Mohammad Alshaikhusain
Published
Sources checked
A reliable integration tutorial states the starting environment, required permissions, configuration and expected result before asking the reader to run code. Test it from a clean folder with only the documented files and tools. Include a meaningful failure case and teardown so success does not depend on hidden state left by the author.
The local exercise below demonstrates that standard. It uses a small teaching API and client to submit an event and verify an acceptance receipt. It does not contact a commercial service, use real credentials or demonstrate downstream delivery. Its value is an inspectable setup-to-result path you can apply to real documentation.
The clean-start test passed five checks on Node 24.19.0 on September 17, 2026. That is execution evidence for the supplied files, not a promise that every runtime or operating system behaves identically.
State the result before the prerequisites
The reader should know what they will have accomplished. For this exercise: a client submits one local event, receives a 202 acceptance receipt, retrieves that receipt and verifies the two bodies agree. A successful client process prints the event identifier and accepted state.
That result is deliberately narrower than a production event pipeline. The teaching server stores data in memory, uses a known fake token and has no delivery worker. Stopping it removes the records. Do not deploy it or use it with real customer data.
For a real integration, write an equally precise goal. “Connect our API” is too broad. “Create one sandbox resource, verify its status and remove it” defines a result the reader and reviewer can check.
Make the starting state explicit
| Prerequisite | This local exercise | What a real tutorial must establish |
|---|---|---|
| Runtime | Node with the built-in APIs used by the files; tested on 24.19.0 | Supported runtime and package versions |
| Working directory | A new folder containing only the downloaded files | Repository state and exact file locations |
| Network | Loopback access to 127.0.0.1 | Required hosts, proxies and sandbox restrictions |
| Identity | A fixed fake token inside the teaching client | Credential issuer, scope and authorized resources |
| External account | None | Account role, plan and resource setup if required |
| Dependencies | Node built-ins only | Exact install commands and dependency versions |
| Persistence | In-memory receipts, lost on shutdown | Retention, cleanup and side effects |
Choose a currently supported Node LTS release using the official release page; do not install an obsolete release merely because an old tutorial once used it. The tested version above records what was actually checked. Node release guidance
The client uses built-in fetch and request timeouts. Their documentation explains the runtime APIs; the exercise's test establishes the behavior of this particular example. Node global APIs
Download and inspect the files
Save these files together in a new folder:
- Teaching server: local-events-server.mjs
- Client: accept-event.mjs
- Optional automated check: clean-start.test.mjs
Read them before running. The server binds only to loopback. The client rejects non-loopback destinations and redirects, uses a fake token and does not request external resources. No package installation or .env file is required.
Open two terminals in the folder. Confirm Node is available:
node --version
If the command is unavailable, install an appropriate supported runtime through your normal trusted process before proceeding. Do not work around a missing runtime by pasting the server into a browser console or changing the example to use a remote service.
The files use the .mjs extension, so they run as JavaScript modules without a package manifest. Preserve the filenames because the automated check locates the other files by name.
Start the server and verify readiness
In the first terminal, run:
node local-events-server.mjs
The expected readiness line is:
Local teaching API: http://127.0.0.1:4319
Leave this process running. If it exits or reports that the port is in use, do not move on to the client and interpret its failure as an authentication problem. Fix the prerequisite that failed.
To use another available local port, pass it explicitly:
node local-events-server.mjs 4320
Use the same address when invoking the client. A port change is configuration for this local exercise, not a change to the API contract. Avoid terminating an unrelated process just to claim the default port.
The server's console output is readiness evidence only. It does not establish that the request contract is correct; the next step exercises that behavior.
Run the client and inspect the result
In the second terminal, from the same folder, run:
node accept-event.mjs
For an alternate port:
node accept-event.mjs http://127.0.0.1:4320
On a fresh server, the successful output is:
{
"checked": "accepted receipt, not downstream delivery",
"event_id": "evt_1",
"status": "accepted"
}
The file prints this as one JSON line. Formatting above is expanded for readability. If other events were submitted earlier in the same server process, the identifier can differ; the client verifies its shape and reads back the returned identifier rather than assuming it is always evt_1.
Inspect what the client actually checks: the POST returns 202, the body has a valid identifier and accepted state, the readback returns 200, and the stored receipt matches. It exits with an error if those assertions fail.
HTTP acceptance is not completion of an asynchronous business task. A real integration may require a status endpoint, webhook or another completion check. This fixture intentionally stops at acceptance. RFC 9110, HTTP semantics
Explain the request rather than hiding it
The client's body is a small application event:
{
"name": "workspace.created",
"properties": {
"workspace_id": "ws_example_001"
}
}
The fixed local idempotency key is tutorial-workspace-001. The fake bearer token is local-demo-only. These values are part of a teaching fixture, not secrets or a production credential design. The example includes no actual person's data.
For a real tutorial, replace this explanation with the real credential origin, minimum permissions, resource identifiers and expected side effects. Do not simply write “add your token.” A reader needs to know which token, who can create it, where it belongs and what it authorizes.
GitHub's getting-started guide is a primary example of making request components and setup explicit. Its particular headers and authentication options apply to GitHub, not every API.
Rerun safely under the declared contract
Run the unchanged client again while the same server process is running. The fixture should return the same receipt because its idempotency rule matches the same key and exact request-body text.
Do not generalize that behavior to other services. In this fixture, changing the body while reusing the key returns a conflict. Restarting the server discards the stored key and receipt because they live only in memory. There is no durable or cross-process idempotency guarantee.
A real tutorial should explain the service's key scope, retention, conflict behavior and retry rules. A timeout can leave the side effect uncertain, so blindly repeating a write may be unsafe. The error-recovery guide shows how to document the decision more precisely.
For this exercise, leave the client unchanged for the repeat test. If you experiment with new payloads, treat them as a different operation and use a different key. Record what changed so a later failure remains interpretable.
Test a failure and teardown
Stop the first terminal's server with Ctrl+C. Then rerun the client in the second terminal. It should fail rather than print a successful receipt. This confirms the tutorial is not presenting cached output as a completed request.
No remote resource needs deletion. The in-memory receipts disappear when the server stops. Keep or remove the downloaded tutorial files according to your preference; do not use a broad cleanup command against a directory containing unrelated work.
If you started the server on another port, stop that process as well. A real integration tutorial should similarly name the exact resources created and how to clean them up. Teardown is part of the task when an exercise creates billable, persistent or security-sensitive state.
Run the automated clean-start check
With all three downloaded files in the folder, run:
node clean-start.test.mjs
The check copies the server and client into a fresh temporary directory, starts an isolated loopback server on an available port, runs the client, verifies the relevant outcomes and removes its temporary files afterward. It does not depend on a manually running server at port 4319.
The retained verification on Node 24.19.0 passed these five checks:
- The client succeeds from the clean directory without installed dependencies.
- A second identical client run retains the receipt identifier.
- A remote destination is rejected by the client.
- A request without the fake credential is rejected by the server.
- A stopped server does not produce a successful client result.
These checks support the specific local tutorial. They do not establish production security, high-load behavior, compatibility across every operating system or a citation advantage for the article. Keep the distinction between tested behavior and a broader promise visible in your own documentation.
Troubleshoot the prerequisite that actually failed
| Symptom | Likely area to inspect | Appropriate response |
|---|---|---|
node command unavailable | Runtime installation | Install a supported runtime through a trusted method |
| Address already in use | Port configuration | Choose another available local port and pass it to both commands |
| Connection refused | Server process or address | Confirm the server is running at the address supplied |
| Unauthorized response | Credential/header mismatch | Restore the fixture's fake local header; never substitute a real token |
| Conflict after editing the body | Idempotency contract | Treat changed content as a new operation with a new key |
| Assertion failure | Response differs from expected contract | Inspect the response and changed files before calling the task complete |
Avoid advice such as “retry until it works” when the cause is a permission or contract mismatch. A useful troubleshooting section identifies what evidence differentiates the cases.
Apply the same standard to production tutorials
For a real API, expand the prerequisite table to cover account role, plan availability, allowed environment, credential setup, SDK version, network access and resource creation. Link the exact reference sections rather than an undifferentiated documentation homepage.
Test from the documented start state with someone who did not write the instructions. Record every missing step, assumption and manually repaired error. If the tester needs an undocumented permission or a hidden file from the author's machine, the tutorial has not passed its clean-start test.
Separate claims about what was tested from recommendations about supported environments. A tutorial can truthfully say it passed on one runtime while advising users to choose a maintained release and verify the example there. Update execution evidence when the files or their dependencies change.
The page-type guide helps keep a tutorial focused on its bounded result. The authentication documentation guide covers the credential details that this fake-token exercise deliberately does not implement.
Sources and review date
Sources and local exercise checked September 17, 2026. The recorded supported-LTS execution used Node 24.19.0; choose supported runtimes using current official guidance rather than treating one tested patch as the only valid version.
- Node release guidance: supported release selection.
- Node global APIs: built-in fetch and timeout interfaces.
- RFC 9110, published June 2022: HTTP response and method semantics.
- GitHub REST getting started: primary example of explicit setup, requests and responses.
Continue reading
Explore GEO with Jam
See how Jam approaches AI visibility research and content improvements for developer-tool teams.
Explore Jam for GEO