Auth guides
18 · Test mode

Test sign-in without an inbox.

Your CI and your coding agents need to sign in as a real user. Test mode gives them addresses that use a fixed code and never receive email.


1

Switch it on

In the console: Auth, your app, Settings, Test mode. Or one API call.

Turn on test mode
curl -X PATCH https://api.auth.productcraft.co/v1/apps/<app_id>/auth-config \
  -H "Authorization: Bearer $PRODUCTCRAFT_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{ "test_mode": { "enabled": true, "code": "424242" } }'

Use it on a staging or development app (Settings, Clone app). On a production app it is refused with 400 TEST_MODE_PRODUCTION_APP unless you also send "allow_in_production": true. Every switch is recorded as app.auth_config.test_mode_changed in the app's audit log, and the setup checklist flags test mode left on in production.


2

Use a test identity

Any address with +pc_test right before the @ is one, on any domain.

  • Email sign-in: start and verify with the fixed code. No email, no CAPTCHA, and no per-address or per-IP send limit, so a test suite can sign in as often as it needs.
  • Sign-up with a password: the email is verified on the spot and no verification email is sent.
  • Email two-step codes: the factor's code is the fixed code, and nothing is sent.
Sign in from CI
# 1. Start: no email is sent to a +pc_test address
curl -X POST https://api.auth.productcraft.co/<app-slug>/v1/auth/email/start \
  -H 'Content-Type: application/json' \
  -d '{ "email": "ci-run-42+pc_test@example.com" }'

# 2. Finish with the fixed code
curl -X POST https://api.auth.productcraft.co/<app-slug>/v1/auth/email/verify \
  -H 'Content-Type: application/json' \
  -d '{ "flow_id": "pwf_…", "code": "424242" }'

Each use is recorded as auth.test_identity.used with the flow (passwordless_start, signup, mfa_challenge, mfa_enroll or email_suppressed). Other addresses behave exactly as before, test mode or not.