Skip to content

Signing up for Discord? Some of our domains are accepted there. See which ones on the Domains page.

CyberTemp
All posts

Add a Pre-Flight Check to Your CI Email Test Suite

CyberTemp6 min read

Need a disposable inbox right now?

Spin up a temporary email address in seconds — no signup, no spam, no trace.

Get a free inbox

A CI run that fails on a rate limit looks exactly like a CI run that fails on a real bug, until someone wastes twenty minutes reading logs to tell the difference. If your signup or OTP tests hit CyberTemp's API, you can catch that failure mode before a single test runs, instead of after.

The wrong kind of red build

Most teams wire a disposable inbox into their signup tests, get it working, and stop thinking about it. The suite reads mail, extracts a code, asserts on it. Fine, until the day a shared CI runner burns through your plan's inbox quota in the first ten minutes, or the API has a rough five minutes and a health probe would have caught it instantly.

When that happens, the failure doesn't say "rate limited" in a way anyone notices at a glance. It shows up as a timeout inside whichever test happened to be running when the quota ran out. Someone opens the log, sees a failed assertion on an OTP field, and starts debugging the signup flow. The actual problem — a plan limit or an outage, not a code regression — gets found forty minutes later, after a round of "did we break something?" in the team channel.

A pre-flight check fixes this by answering one question before the suite starts: is now a good time to run these tests at all? If the answer is no, the suite should say so in the first ten seconds, not the last ten minutes.

What /health and /getPlan actually tell you

CyberTemp's API exposes two endpoints that most integrations never call directly, because they're not part of the read-mail loop. They're exactly the right shape for a pre-flight check:

  • GET /health — a public probe, no auth required. If this doesn't return cleanly, nothing downstream will either. Call it first and fail fast if it's down.

  • GET /getPlan — current plan info for your API key: tier, limits, usage. This is the one that actually prevents the confusing failure. If you're at or near your inbox or request quota before the suite even starts, you already know why the first few tests are going to 429.

Neither endpoint is meant to replace the error handling inside your actual test logic — you still want retries and backoff for the 429s that happen mid-run. This is a layer in front of that: a single check that decides whether the run is worth starting.

Building the check

The script is short on purpose. It should run in a few seconds, before anything that creates inboxes or polls for mail.

import httpx
import sys

API_KEY = "tk_..."
HEADERS = {"X-API-Key": API_KEY}
BASE = "https://api.cybertemp.xyz"

USAGE_THRESHOLD = 0.9  # bail if we're at 90% of quota


def preflight():
    try:
        health = httpx.get(f"{BASE}/health", timeout=5)
    except httpx.RequestError as e:
        print(f"preflight: API unreachable ({e}), skipping suite")
        sys.exit(1)

    if health.status_code != 200:
        print(f"preflight: /health returned {health.status_code}, skipping suite")
        sys.exit(1)

    plan = httpx.get(f"{BASE}/getPlan", headers=HEADERS, timeout=5)
    if plan.status_code != 200:
        print(f"preflight: /getPlan returned {plan.status_code}, skipping suite")
        sys.exit(1)

    data = plan.json()
    used = data.get("requestsUsed", 0)
    limit = data.get("requestLimit", 1)

    if limit and used / limit >= USAGE_THRESHOLD:
        print(
            f"preflight: {used}/{limit} requests used this period, "
            f"too close to the limit to start a new suite"
        )
        sys.exit(1)

    print(f"preflight: ok ({used}/{limit} requests used)")


if __name__ == "__main__":
    preflight()

The exact field names in the /getPlan response depend on your tier, so print the raw JSON once and adjust the keys you read. The shape of the check doesn't change: probe health, pull usage, compare against a threshold you set deliberately rather than discover by accident.

Wiring it into CI

The point of a pre-flight step is that it runs as its own stage, with its own exit code, before the test job starts. In a GitHub Actions workflow that's a separate step ahead of the test command:

- name: Pre-flight check
  run: python preflight.py

- name: Run signup email tests
  run: pytest tests/signup/

If preflight.py exits non-zero, the job stops there and the failure reads as exactly what it is — "preflight: 94/100 requests used" — instead of a stack trace three layers deep in a test that has nothing to do with the real problem. That one line in the log saves the debugging session entirely.

For a scheduled nightly run, it's worth going a step further and treating a pre-flight failure as a signal on its own, not just a reason to skip. A suite that keeps hitting its quota in the first few minutes isn't a flaky test problem, it's a sign you've outgrown the plan you're on — see the plan tier breakdown if you're not sure which one actually fits your CI volume.

What to do when the check fails

A pre-flight failure has two honest responses, and they're different problems:

  • The API is down or degraded. Skip the suite, retry later, and alert if it happens more than once. Don't fall back to running the tests anyway — a suite that runs against a degraded API just produces noisy, unreliable results that look like regressions.

  • You're out of quota. This is a capacity problem, not an outage. Clean up stale test inboxes with DELETE /inbox?email=... if your suite isn't already tearing them down between runs — a surprising number of quota issues are just old inboxes nobody deleted. If cleanup doesn't buy enough headroom, that's your signal to move up a tier before your real CI volume, not after it starts failing nightly.

Either way, the pre-flight check turns a mystery into a one-line diagnosis. That's the entire value of it — not preventing the limit, just making sure you find out about it in the first ten seconds instead of the last ten minutes.

Bottom line

If your CI pipeline reads real mail through CyberTemp, a two-call pre-flight script costs you almost nothing and removes an entire category of confusing, misleading test failures. It's a smaller version of the same instinct behind proper rate-limit handling inside your tests — check before you commit to the run, not just while you're already in it.


If you're scripting against signups — testing pipelines, multi-account workflows, automated QA, scrape-then-verify flows — the paid tiers are where per-key request limits stop being the bottleneck and where the OTP-extraction helpers in the Go SDK start paying for themselves. Sign up if that's you.

Share
    Add a Pre-Flight Check to Your CI Email Test Suite | CyberTemp Blog