Skip to content

Developer tools

Test the Qelka API in Bruno

Import the Qelka OpenAPI document into Bruno, keep keys in a .env file read through process.env, set Bearer auth once and run the tests in CI with bru.

Updated 2026-11-26

This guide sets up Bruno to explore and test the Qelka API: a collection generated from the OpenAPI document, keys kept out of git, Bearer auth set once on the collection, and tests you run in the app and in CI with the bru CLI. There is no Qelka integration to install in Bruno: everything comes from the public OpenAPI document at https://api.qelka.com/v1/openapi.json.

Bruno stores collections as plain files, YAML in the OpenCollection format since Bruno 3 or classic .bru files, so the collection can live in your repository next to the code it tests.

What you need

  • The Bruno app, and Node.js with the Bruno CLI for command-line runs: npm install -g @usebruno/cli.
  • A Qelka test key and, when you are ready, a live key. A sk_test_ key returns simulated, fixed answers and never spends credits: see Test mode.
  • For the live environment, consider a restricted key with only the endpoints you test. See restricted keys.

Steps

1. Import the OpenAPI document

In the app, click +, choose Import Collection, select OpenAPI and give it the URL https://api.qelka.com/v1/openapi.json. Keep the folder arrangement on Tags for one folder per product, and turn on Set authentication at collection level so the document's bearer scheme lands on the collection instead of every request.

The CLI does the same, which suits a script or a first commit:

Terminal
bru import openapi \
  --source https://api.qelka.com/v1/openapi.json \
  --output ./api-tests \
  --collection-name "Qelka API"

The CLI writes OpenCollection YAML by default: opencollection.yml at the root and one .yml file per request. Add --collection-format=bru for classic .bru files. Test and live keys call the same base URL, so the requests need no change between environments.

2. Keep the keys in a .env file

Bruno loads a .env file at the root of the collection and exposes its values as process.env. Create it next to opencollection.yml:

.env
QELKA_API_KEY_TEST=sk_test_your_key
QELKA_API_KEY_LIVE=sk_live_your_key

Add .env to .gitignore, and commit a .env.sample with empty values so teammates know what to fill in.

3. Create a test and a live environment

Create two environments from the environment selector at the top right, or as files. Each one sets api-key from the .env file:

environments/test.yml
name: test
variables:
  - name: api-key
    value: '{{process.env.QELKA_API_KEY_TEST}}'
environments/live.yml
name: live
variables:
  - name: api-key
    value: '{{process.env.QELKA_API_KEY_LIVE}}'

These files hold references, not keys, so they are safe to commit. If you prefer not to use a .env file, mark api-key as a secret in the environment instead: Bruno keeps the value in its local encrypted store and writes only the name to the file.

4. Set Bearer auth on the collection

Open the collection settings, then Auth, choose Bearer Token and set the token to {{api-key}}. Bruno sends Authorization: Bearer followed by the key of the selected environment. Requests set to inherit their auth, auth: inherit in the files, pick it up. If the importer already set Bearer auth with its own variable, replace that variable with api-key.

5. Add a request with tests

Tests are JavaScript with Chai's expect. This request checks a disposable address in test mode, where its answer is fixed:

email/verify-disposable.yml
info:
  name: Verify a disposable address
  type: http
  seq: 1
http:
  method: POST
  url: https://api.qelka.com/v1/email
  body:
    type: json
    data: |-
      {
        "email": "disposable@example.com",
        "mode": "fast"
      }
  auth: inherit
runtime:
  scripts:
    - type: tests
      code: |-
        const body = res.getBody();
        if (body.error) console.log(`${body.error.type}: ${body.error.message}`);

        test("answers 200", function () {
          expect(res.getStatus()).to.equal(200);
        });

        test("flags the address as disposable without spending credits", function () {
          expect(body.status).to.equal("risky");
          expect(body.reason).to.equal("disposable");
          expect(body.credits_used).to.equal(0);
        });
settings:
  encodeUrl: true

mode: "fast" runs the syntax, DNS and list checks and skips the mailbox check, so it answers faster; use full when you need to know whether the mailbox exists. Other fixed test inputs: undeliverable@example.com in full mode, (415) 555-0123 with country: "US" on POST /phone, which becomes +14155550123, and 198.51.100.200 on POST /ip, flagged as Tor. Test mode lists them all.

6. Run the collection with the bru CLI

From the collection root, run every request with the test environment:

Terminal
bru run --env test

In CI, there is no .env file. Pass the key with --env-var, which overrides the environment's value for the run, and write a JUnit report:

.github/workflows/api-tests.yml
name: API tests

on: [push]

jobs:
  bruno:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
      - run: npm install -g @usebruno/cli
      - name: Run the collection in test mode
        working-directory: api-tests
        env:
          QELKA_API_KEY: ${{ secrets.QELKA_API_KEY_TEST }}
        run: bru run --env test --env-var "api-key=$QELKA_API_KEY" --reporter-junit results.xml --reporter-skip-all-headers

--reporter-skip-all-headers keeps the Authorization header out of the report, which matters if you publish it as a build artifact. Add --bail to stop at the first failed test. More on secrets and workflows in the GitHub Actions integration.

Read the results

Endpoint status What to do in your app
POST /email deliverable Accept the address
POST /email undeliverable Reject it, and show did_you_mean when there is one
POST /email risky Disposable, catch-all or full mailbox: flag or review it
POST /email unknown Not conclusive: accept it and check again later
POST /phone valid Store e164
POST /phone invalid Ask for the number again
POST /phone unknown Send it again with country

Each field is described in the email reference, the phone reference and the IP reference.

Handle errors and rate limits

Every error has the same body, { "error": { "type", "message", "docs" } }, and nothing is billed on errors. The test script above logs the error type, which bru run prints in the terminal.

HTTP status error.type In Bruno, it usually means
401 invalid_api_key No environment selected, a missing .env value, or a secret not passed to the CLI
403 forbidden A restricted key calling an endpoint outside its list, or a test key on POST /bulk
400 invalid_request The body is not valid JSON, or a field is missing
422 unprocessable_input The value cannot be checked, such as a private IP address
429 rate_limited Too many requests: wait the seconds in Retry-After

A key allows 200 requests per 10 seconds, and test keys count toward the same organization window as your live traffic. bru run sends requests one after another by default; avoid --parallel on large collections, or add --delay in milliseconds between requests. See Errors and Rate limits.

Frequently asked questions

Can I commit the Bruno collection to git?
Yes, that is how Bruno is meant to be used: requests and environments are plain files. The environments in this guide only hold a reference such as process.env.QELKA_API_KEY_TEST, and the keys live in a .env file that you add to .gitignore. Secret variables are also safe to commit, since Bruno writes only their name to the file.
Why does bru run send an empty key in CI?
Values of variables marked as secret stay in the Bruno app's local encrypted store and are not available to the CLI. Pass the key at run time with --env-var api-key=..., read from your CI secret store. The same flag also overrides a value that comes from a .env file.
Do my Bruno test runs cost credits?
Not with a sk_test_ key: answers are simulated and fixed, and credits_used is 0. With a live key, each request costs the same as from your code, for example 1 credit per email check. Errors are never billed, and GET /account is free.

More in Developer tools

All integrations

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.

  • 100 free credits a month
  • No card
  • Test keys spend nothing
  • Cancel any time