Guide · GitHub Actions

Waiting for an OTP in GitHub Actions

Wire a wait-for-OTP test into CI by storing your mailsocket key and inbox id as encrypted secrets and exporting them to your test run. The example calls the REST API directly; there is no GitHub Actions plugin to install.

Before you start

  • Create an inbox and an API key. Sign up, verify your email, and open the dashboard. Your first inbox is created automatically, and you can create an API key in one click. Or use the 60-second path with no signup.
  • Copy your inbox address. It is <routing_key>@in.inboxpipe.net. The inbox id (inbox_…) is not the routing key, so copy the full address from the dashboard.
  • Point your signup form at that address. Replace https://app.example.com/signup and the selectors below with your real form.

The flow

  1. Submit the signup form with the mailsocket inbox address.
  2. Call GET /api/v1/inboxes/{id}/messages/wait with require=otp. It returns the OTP as soon as it arrives, or 204 after 25 seconds; on 204, call again.
  3. Assert the OTP is present and has the expected shape (for example 4 to 8 digits).

Copy-paste example

Read your API key from the environment; never hardcode it. Set MAILSOCKET_API_KEY, MAILSOCKET_INBOX_ID and MAILSOCKET_INBOX_ADDRESS before running.

GitHub Actions
# .github/workflows/otp-test.yml
# Store MAILSOCKET_API_KEY, MAILSOCKET_INBOX_ID and MAILSOCKET_INBOX_ADDRESS
# as encrypted repository secrets (Settings -> Secrets and variables -> Actions).
name: otp-signup
on: [push]
jobs:
  otp:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install pytest requests
      # test_signup.py is the pytest guide's test file.
      - name: Wait for the signup OTP
        env:
          MAILSOCKET_API_KEY: ${{ secrets.MAILSOCKET_API_KEY }}
          MAILSOCKET_INBOX_ID: ${{ secrets.MAILSOCKET_INBOX_ID }}
          MAILSOCKET_INBOX_ADDRESS: ${{ secrets.MAILSOCKET_INBOX_ADDRESS }}
        run: pytest -q test_signup.py

Want the Playwright version too?

A ready-to-copy Playwright spec is at examples/playwright/otp-signup.spec.ts. All guides are listed in Guides.