🧩 The Setup Habits Challenge – $150 prize | 24 Hours Only

My tiny “Clean Slate” button (one click before I start)

I keep a pinned request at the top of every collection called Clean Slate. I hit it once when I open Postman and it does three boring things that save me from silly mistakes:

  • Blocks prod unless I’ve explicitly allowed it

  • Creates a short run_id and an idempotency_key for today’s work

  • Sets a couple of sane JSON defaults so I don’t retype headers

// Clean Slate — run once when you open the collection
const base = pm.environment.get("base_url") || "";
const isProd = /prod|live|production/i.test(base);
if (isProd && pm.environment.get("ALLOW_PROD") !== "true") {
  postman.setNextRequest(null);
  throw new Error("Prod blocked. Set ALLOW_PROD=true if you really mean it.");
}

pm.collectionVariables.set("run_id", pm.guid().slice(0, 8));
pm.collectionVariables.set("idempotency_key", Date.now().toString());

pm.collectionVariables.set("accept", "application/json");
pm.collectionVariables.set("content_type", "application/json");

How I actually use it

  • {{base_url}} lives in my environment (dev/stage/prod).

  • I only set ALLOW_PROD=true when I intend to touch prod.

  • For writes, I add Idempotency-Key: {{idempotency_key}} to avoid duplicate creates/charges.

  • I log with X-Run-Id: {{run_id}} so hunting failures takes seconds.

Nothing fancy—just one click that keeps me out of prod by accident and stops me from retyping the same stuff all day.

Auto-Trace Every Request With Zero Extra Work

For my setup habit, I have added a single pre-request script at the Collection level that will automatically attaches three helpful trace headers to every request that I send:

  • X-Request-Id → uniquely identifies this exact request
  • X-Client-Run → identifies my entire testing session
  • Idempotency-Key → ensures safe replays/retries in POST workflows

So now, I don’t have to manually create trace IDs anymore. Whenever I’m debugging, I just grab the X-Request-Id and use it to search the logs or trace the request across services. It makes tracking what happened a lot simpler.

I used to waste time guessing timestamps and digging through logs just to reproduce bugs or check backend behavior. Now, I just send a request, copy the X-Request-Id, paste it into my logs or monitoring tools, and jump straight to the exact execution. Debugging becomes quick and clean.

Here’s the Collection-Level Pre-request Script:


(function () {
  const uuid = () => `${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;

  if (!pm.collectionVariables.get("run_id")) {
    pm.collectionVariables.set("run_id", uuid());
  }

  pm.variables.set("request_id", uuid());
  pm.variables.set("idempotency_key", uuid());

  const requestId = pm.variables.get("request_id");
  const idempotencyKey = pm.variables.get("idempotency_key");
  const runId = pm.collectionVariables.get("run_id");

  const setHeader = (k, v) => pm.request.headers.upsert({ key: k, value: v });
  setHeader("X-Request-Id", requestId);
  setHeader("Idempotency-Key", idempotencyKey);
  setHeader("X-Client-Run", runId);

  console.log(JSON.stringify({
    trace: { request_id: requestId, run_id: runId, idempotency_key: idempotencyKey },
    method: pm.request.method,
    url: pm.request.url.toString(),
    timestamp: new Date().toISOString()
  }, null, 2));
})();

How to see it in action

  • Open Postman Console (Ctrl+Alt+C) (Windows)
  • Send any request
  • Look for the structured trace log
  • Or check the Response Headers to see the same request ID reflected

This habit takes almost zero effort to set up once, and then it works automatically for every request in the collection. It consistently saves time by making debugging faster and more exact and it requires no additional tools beyond Postman.

Thanks everyone for the great ideas. Excited to refine my workflow even more!

1 Like

One more tiny habit from me: prefix variables by where they live

I name variables by scope, so I never have to guess which drawer they come from.

{{g_base_url}}     // global
{{env_api_token}}  // environment
{{col_user_id}}    // collection
{{req_payload}}    // request-only
{{tmp_token}}      // short-lived / throwaway

Why it helps

  • I spot scope mistakes at a glance (env_ vs col_).

  • No more silent overrides when a collection var shadows a global.

  • Teammates immediately know where to edit the value.

Tiny check I add in Tests (catches missing env quickly):

["env_base_url","env_api_token"].forEach(v => {
  pm.test(`has {{${v}}}`, () => pm.expect(pm.variables.get(v)).to.exist);
});

I also keep type hints at the end so names stay clear:
env_timeout_ms, col_callback_url, req_user_id.

Two seconds to name it right, and I spend less time chasing “why isn’t this picking up?”—especially when flipping between dev/stage/prod.

That’s a wrap!

This week’s challenge is officially closed. Thanks to everyone who jumped in.

While you wait, drop a :heart: on your favorite replies to help us pick a winner.

Winner announced Friday.

4 Likes

Challenge Winner!
Huge thanks to everyone who joined this week’s Setup Habits Challenge.

We received a lot of excellent submissions this week. Congrats to @dotaadarsh for sharing a helpful debugging tip using trace headers with pre-request scripts. This is a very clever debugging approach in Postman that I personally learned from and would use in my workflows moving on!

Next challenge lands Wednesday, stay tuned!

3 Likes