---
title: Test sign-in with test end users
description: Create test end users, sign one in through your app's own sign-in pages with no mailbox, test the signed-in routes, then remove them.
slug: /guides/test-sign-in-with-test-end-users
order: 18
visibility: public
redirects_from: []
---

# Test sign-in with test end users

Prompt:

> Test my app's signed-in pages without me signing in.

Also works:

- "Sign a test user in to the development environment and check the account page."
- "Run the native app's sign-in, refresh, and sign-out with no person."
- "My local run needs a signed-in session to test `/me`."

Start by choosing the [environment to test](#1-choose-the-environment). Use that same environment when you create the test end user and check the signed-in route.

A test end user is an end user your AI assistant creates on one of your application's [realms](/cloud/concepts/glossary/#realm), at an address at `synthetic.turnzero.ai`, which receives no mail. Your AI assistant reads its sign-in code through a management action instead of a mailbox. It can sign in through your application's test sign-in page and exercise routes that accept an ordinary session. A real provider callback, mailbox or workforce tenant identity needs a separate check.

Your AI assistant creates test end users with `tzcloud_add_test_end_users` and `labels` ([step 2](#2-create-the-test-end-users)), and reads their codes with `tzcloud_read_test_signin_code` ([step 3](#3-sign-one-in-with-curl)). It can instead run the line `tzcloud_sign_in_test_end_user` returns ([step 4](#4-sign-one-in-with-the-turnzero-command)).

That line needs an authorized command credential. On production, and under `workforce` in either environment, the token needs the `test_end_users` grant. It tests your signed-in routes. Test end users expire 48 hours after creation; `tzcloud_add_test_end_users` with `remove: true` removes them sooner ([step 9](#9-remove-them)).

If your minted deploy token lacks `test_end_users`, it can still run the test in existing development outside `workforce`. For production or `workforce`, use the app owner's AI connection signed in through the browser, or a token with the grant. See [step 1 (Choose the environment)](#1-choose-the-environment).

If you have neither, ask someone the application admits to sign in normally and check the route in their browser. A request without an end-user session checks only the signed-out behavior.

## What your AI does

- Reads the `add-sign-in` skill (`read_context`, id `skill:add-sign-in`) and follows its rule on test end users.
- Signs a test end user in with `curl`, from a browser, or with the command `tzcloud_sign_in_test_end_user` returns. It uses a separate cookie jar for each run, outside the app folder, and keeps cookie values out of output.
- Tests the signed-in routes you name. It cleans up any app records the test created, then removes the test end users it created in the same environment. It reports the result and deletes that run's cookie jar.
- Creates test end users, reads their codes, and signs them in with `tzcloud_request_route` under its own signed-in connection, in any environment, with no approval.
- Creates test end users and makes signed-in requests through its browser-signed-in connection. Before running the line from `tzcloud_sign_in_test_end_user` on production, asks you to mint a token with the `test_end_users` grant. Under `workforce`, it asks for that grant in development too. Outside `workforce`, it first offers existing development.
- Without such a token, signs in with the curl or browser route instead.
- For browser checks, uses development's `<application label>-dev.ai.host` where development is on. Applies its own rules before entering a sign-in code.

## What you need

- An application whose manifest declares the `accounts` service ([Add sign-in to your app](/cloud/guides/add-sign-in-to-your-app/)).
- For `tzcloud_sign_in_test_end_user`'s line on production, and in either environment under `workforce`, a token you minted with the `test_end_users` grant ([A token for test end users](/cloud/guides/mint-a-token/#a-token-for-test-end-users)). Your AI coding agent's signed-in connection needs none.

## Before your AI starts

**For the AI assistant:** Check the following before starting.

- A connected, signed-in AI assistant ([Connect your AI assistant](/cloud/getting-started/connect-your-tool/)), acting as the account that owns the application. No other account's credential reaches these actions.
- Whether the application has a development environment, from the environments `tzcloud_read_status` lists.
- For backend tests that need no live sign-in, the Account package's double first ([Test with the double](/cloud/backend-packages/account/#test-with-the-double)). Test end users let you check the live sign-in pages, session cookie, and session verification.

## Steps

### 1. Choose the environment

Your AI assistant can create test end users and read their codes in any environment through the connection you signed in to in your browser. That connection needs no approval. A connection you set up with a minted token uses the token's permissions. A refusal's `detail` names the credential the action read.

A job can use a minted token with the `test_end_users` grant to do the same ([A token for test end users](/cloud/guides/mint-a-token/#a-token-for-test-end-users)). A minted token without the grant is refused on production ([Test on production from a pipeline](#test-on-production-from-a-pipeline)). Under the `workforce` audience, either environment refuses a minted token without the grant. Each creation there records the application, environment, number of test end users created, and credential used.

The command from step 4 uses its own minted token. The same grant rules apply when the command runs. You can sign in with `curl`, in a browser, or with `tzcloud_request_route` through the browser-signed-in AI connection if the command's token lacks the grant.

You can test on development instead, once `tzcloud_create_environment` adds it ([Test in development, then promote](/cloud/guides/turn-on-development-and-promote/)). Outside the `workforce` audience, a minted token with access to that application can create test end users in development without `test_end_users`. Adding development removes no test end user from production, and your session still creates them there. Development stays enabled once added, and later deploys go there first. Add it only if the account owner wants a development environment, never only to run a test.

Under the `workforce` audience, a browser-signed-in AI connection or a minted token with the `test_end_users` grant can create test end users and read their codes in either environment with no approval. A job that uses a minted token needs the grant to sign in a test end user while nobody is present.

First configure the realm's [work-account method](/cloud/guides/add-work-account-or-apple-sign-in/#2-add-work-account-sign-in) to match the workforce audience. Use `entra` for its tenant ID or `oidc` for its exact issuer address. Until that method is available, test end users cannot sign in.

A test end user's address is at `synthetic.turnzero.ai` and has no `source` field marking it as a tenant address, so a route that accepts only tenant addresses refuses it. Test with a route that admits any signed-in user. Prove your code's check for tenant addresses offline, over the Account package's double, as [Test with the double](/cloud/backend-packages/account/#test-with-the-double) shows.

### 2. Create the test end users

Call `tzcloud_add_test_end_users` with `application`, `environment`, and one to twenty `labels`, such as `tester-one`. The [tzcloud_add_test_end_users](/cloud/reference/actions/add-test-end-users/) reference gives each label's form and every response member.

```json
{ "application": "<application id>", "environment": "production", "labels": ["tester-one"] }
```

Each label becomes the verified address `<label>@synthetic.turnzero.ai`. The answer gives `test_signin_page`, where step 3 signs in, and each test end user's `id`, which steps 4, 8, and 9 use.

Each test end user expires 48 hours after creation. The platform then prevents new sign-ins for that user and omits the user from the list, even if cleanup has yet to remove the record. A call naming `expires_in_days` is refused, because the lifetime is fixed.

Repeating the call is safe. A label an unexpired test end user already holds returns that user with `created: false` and creates nothing. A label whose test end user has expired is created again. Test end users are excluded from ordinary user limits, as [Each environment's realm](/cloud/guides/manage-end-users/#each-environment-s-realm) says.

### 3. Sign one in with curl

A tool with no browser signs in with `curl`, keeping the cookies in a jar file. The jar holds a live session, so it goes in the system's temporary folder, never in your project folder, where it could be committed or uploaded. Set `HOST` to the origin `test_signin_page` begins with: `https://<application label>.ai.host` on production or `https://<application label>-dev.ai.host` on development. `<application label>` is your application's hostname label, not the test end user's. Send that origin with each POST, because the sign-in pages accept same-origin requests alone.

Create a fresh jar for each run. Keep its path and use it only for that run. If your shell starts fresh for each call, set `HOST` and set `JAR` to the same saved path before continuing. If `curl --fail` reports an error, stop and check [Refusals](#refusals).

```bash
HOST='https://<application label>.ai.host'
JAR=$(mktemp "${TMPDIR:-/tmp}/turnzero-test-signin.XXXXXXXX") || exit 1
curl -sS --fail -o /dev/null -c "$JAR" -b "$JAR" -H "Origin: $HOST" \
  --data-urlencode "address=tester-one@synthetic.turnzero.ai" "$HOST/__account/email/start"
```

The platform holds the code instead of sending it. Read it with `tzcloud_read_test_signin_code`, which returns `codes`, newest first.

```json
{ "application": "<application id>", "environment": "production", "email": "tester-one@synthetic.turnzero.ai" }
```

In place of `email`, you can pass `end_user` with the test end user's id or its label, here `tester-one`. A value that is one user's id and another user's label is refused `invalid_request`; pass `email` then.

A code lasts ten minutes and allows five attempts. It confirms only with the cookies from the start that asked for it. When several codes are held for the user, calculate `binding` from this run's jar and include it in `tzcloud_read_test_signin_code`. This prints the binding without printing the cookie value.

```bash
JAR='<jar path from this run>'
awk '$6 == "__Host-turnzero_cloud_signin_code" { printf "%s", $7 }' "$JAR" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '='
```

Confirm the code for this start with the same jar, then call a route with the session.

```bash
HOST='https://<application label>.ai.host'
JAR='<jar path from this run>'
curl -sS --fail -o /dev/null -c "$JAR" -b "$JAR" -H "Origin: $HOST" \
  --data-urlencode "code=<code>" "$HOST/__account/email/verify"
curl -sS --fail -b "$JAR" "$HOST/__account/me"
```

The jar now holds the session cookie `__Host-turnzero_cloud_realm`, and `/__account/me` returns the test end user ([Show the user and sign out](/cloud/guides/add-sign-in-to-your-app/#4-show-the-user-and-sign-out)). Send later requests with `-b "$JAR"`. Never print the jar or the cookie's value.

On Windows, step 4's `command_windows` automates the sign-in when you can use that command. To do step 3 in PowerShell, including Windows PowerShell 5.1, create a fresh file in the system's temporary folder. Keep that path for this run. Use `curl.exe` and `NUL` for the sink ([Windows PowerShell](/cloud/getting-started/prerequisites/#windows-powershell)).

```powershell
$Origin = 'https://<application label>.ai.host'
$Jar = (New-TemporaryFile -ErrorAction Stop).FullName
curl.exe -sS --fail -o NUL -c $Jar -b $Jar -H "Origin: $Origin" --data-urlencode 'address=tester-one@synthetic.turnzero.ai' "$Origin/__account/email/start"
```

Include this binding when reading the code if the user has several held codes. Keep the cookie value out of output.

```powershell
$Jar = '<jar path from this run>'
$Value = ((Select-String -LiteralPath $Jar -Pattern "`t__Host-turnzero_cloud_signin_code`t" | Select-Object -First 1).Line -split "`t")[6]
$Hash = [System.Security.Cryptography.SHA256]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Value))
[Convert]::ToBase64String($Hash).TrimEnd('=').Replace('+', '-').Replace('/', '_')
```

```powershell
$Origin = 'https://<application label>.ai.host'
$Jar = '<jar path from this run>'
curl.exe -sS --fail -o NUL -c $Jar -b $Jar -H "Origin: $Origin" --data-urlencode 'code=<code>' "$Origin/__account/email/verify"
curl.exe -sS --fail -b $Jar "$Origin/__account/me"
```

### 4. Sign one in with the turnzero command

Use your AI assistant's browser-signed-in connection to request the command from `tzcloud_sign_in_test_end_user`. The command uses the computer's token or the minted token you supply. On production or in either `workforce` environment, set `TURNZERO_CLOUD_MINTED_TOKEN` to a token with the `test_end_users` grant. Outside `workforce`, a minted token can run the command on development without that grant. Use step 3 or step 5 if you lack the token the command needs.

This example uses development. Turn it on first if you chose to test there, and create `tester-one` in that environment as step 2 describes. Call `tzcloud_sign_in_test_end_user` with the application, the environment, and the test end user, by its `id` or by its label.

```json
{ "application": "<application id>", "environment": "development", "end_user": "tester-one" }
```

The response contains no session. It returns `command` and `command_windows` for an installed turnzero, plus `command_npx` and `command_npx_windows` to run it through npx. Your AI assistant first uses `command_npx`, or `command_npx_windows` on Windows, with or without a global installation.

Run the returned line once from your application's folder. Give `--out` a fresh path outside the app folder for this run. On Windows, choose a folder only you can read because the cookie jar inherits the folder's permissions. The command uses this computer's minted token or `TURNZERO_CLOUD_MINTED_TOKEN`. [Running and writing lines](/cloud/concepts/turnzero-command/#running-and-writing-lines) explains what to do if npx can't run here. The command writes the session cookie to that file in the form `curl -b` reads. Keep its value out of output.

```bash
turnzero session --origin https://dev.turnzero.ai --application <application id> --environment development --end-user tester-one --out '../turnzero-session-<run-id>.txt' --force
```

Replace `<run-id>` with a unique value for this run. The example stores the file in the folder above your app's folder. The command refuses a path inside the folder it runs in if that folder holds `package.json`. Send later requests with `curl -b` and the path you used, as in step 3.

The session lasts at most 1 hour after sign-in. It ends sooner if the test end user expires or the realm token's lifetime ends. The line's `--force` lets it run again for a new session. Delete the file when the tests end, as step 9 does for the jar.

```bash
HOST='https://<application label>-dev.ai.host'
curl -sS --fail -b '../turnzero-session-<run-id>.txt' "$HOST/__account/me"
```

In PowerShell, run `curl.exe -sS --fail -b '../turnzero-session-<run-id>.txt' "https://<application label>-dev.ai.host/__account/me"` using the same path.

If the command needs a token with the grant, the action's answer says so. When the command runs with a token that lacks the required grant, it returns `test_end_users_not_admitted`.

### 5. Sign one in from a browser

Open `test_signin_page`, which is `/__account/signin/test` on the environment's hostname. It shows the emailed-code form even where the realm offers only Google or other providers. Where the realm offers `email`, the ordinary sign-in page works too. The realm must offer at least one usable sign-in method, and test sign-in must be enabled.

Enter the test end user's address and use `tzcloud_read_test_signin_code` to read the code for that start. Keep one browser start open for that user at a time. If you need concurrent starts for the same user, use step 3 with a separate jar and binding for each start. Confirmation opens a real session. A test end user cannot register a passkey.

For your AI assistant's browser check, use development's `test_signin_page` when development is on. The tool still follows its own rules for entering codes. With production alone, use `tzcloud_request_route` or `tzcloud_write_route` with `test_end_user` as in step 8. Follow that step's limits on writes. Report browser checks not run. API checks do not run the page's scripts.

### 6. Sign one in from a native app

A native app's sign-in opens the authorization endpoint in the system's browser sheet, as [Sign in from a native app](/cloud/guides/sign-in-from-a-native-app/) describes. The endpoint redirects to `/__account/signin?authorization=<reference>`. On a realm without `email`, open `/__account/signin/test` with the same `authorization` query instead.

Sign in there as in step 5. The sheet then returns to the app's redirect URI with a code, and the app's own code exchange, refresh, and revocation run unchanged.

### 7. Test a local run

For a server app with `turnzero` 0.38.0 or later, you can sign in through a browser on your machine. First provision the local run as [Run your app on your computer](/cloud/guides/run-your-application-on-your-machine/) describes, then start:

```text
turnzero run --origin https://dev.turnzero.ai --port 3000 --sign-in <hostname>
```

Use `turnzero.cmd` in Windows PowerShell. Name the development hostname if development is on. Otherwise use the production hostname or a served custom domain. The command checks that the hostname belongs to the realm your local run verifies. Before opening the local sign-in page, confirm that the hosted test end user was created in that same environment.

Wait for the local application's health path to return 200 before testing its own routes. Until the application listens, the command's listener responds with 502.

Open `http://localhost:3000/__account/signin/test` and use a test end user created in that environment. Read its code with `tzcloud_read_test_signin_code`, as for the hosted browser route. Open the local application's signed-in page and check that its own user read succeeds.

The test page uses an emailed code and offers no passkey. Federated sign-in and passkeys complete on the hosted hostname, so they cannot complete this local sign-in. Browser sign-in on `localhost` has not been checked in Chromium-family browsers, Firefox, or Safari.

If your browser accepts the session cookie on `localhost`, it can send it to other localhost servers, including servers on different ports. Use the route only while you trust the other local projects running on this computer. The command's sign-in listener binds only to loopback and closes when the application ends.

If the local browser path is unavailable, sign in on the hosted realm that matches the local run. Use this fallback for scripts, an older command, or a run without `--sign-in`.

- With development on, use the development hostname, `<application label>-dev.ai.host`.
- With one environment, use the production hostname and a test end user your AI assistant's session created there (step 2). A local run of such an application verifies production's sessions.

Sign in with `curl` as in step 3, then hand the session from the jar to the local run as the request's `Cookie` header, or as a bearer where your backend reads one. [Tell which user sent a request](/cloud/guides/add-sign-in-to-your-app/#3-tell-which-user-sent-a-request) describes verification under the development credential the run already holds.

Keep tracing off and never echo `$SESSION`. Read it from the jar and pipe the header to `curl` without putting the value in its arguments.

```bash
JAR='<jar path from this run>'
SESSION=$(awk '$6 == "__Host-turnzero_cloud_realm" { print $7 }' "$JAR")
printf 'Cookie: __Host-turnzero_cloud_realm=%s\n' "$SESSION" | curl -sS -H '@-' "http://localhost:<port>/me"
```

In PowerShell, pipe the header to `curl.exe` too. Never print `$Session`.

```powershell
$Jar = '<jar path from this run>'
$Session = ((Select-String -Path $Jar -Pattern "`t__Host-turnzero_cloud_realm`t" | Select-Object -First 1).Line -split "`t")[6]
"Cookie: __Host-turnzero_cloud_realm=$Session" | curl.exe -sS -H '@-' "http://localhost:<port>/me"
```

### 8. Test the signed-in paths

Call your application's signed-in routes with the session.

Creating a test end user gives you a sign-in. Your app decides what that user can do.

If the route checks the owner's verified email address as in [Let only you reach an admin route](/cloud/guides/add-sign-in-to-your-app/#6-let-only-you-reach-an-admin-route), there is no role to grant. Keep `OWNER_EMAIL` set to the owner's address and check that the route refuses the test end user.

If the route checks an app role, use your app's own controls to give the test end user that role, then check the route. Changing a role is a write. If your app has no real users, you can grant the role and check the route in production when you verify the first deploy. If your app has real users, get the owner's confirmation before changing a role in production. Remove the role after the test. If your app provides no way to remove it, tell the owner which test user still has the role.

A tool with no shell calls a deployed route with `tzcloud_request_route` instead, or `tzcloud_write_route` for a route that writes. It passes the test end user's `id` or label as `test_end_user`, and always names the environment. Choose the action by method. Check whether the route writes, including GET routes, before testing it in production. The platform signs that test end user in for the call and tries to close the session when the call ends. If closing it fails, the session expires on its own.

`tzcloud_request_route` and `tzcloud_write_route` send the session as a cookie by default. For a route that reads a bearer token, also pass `session_as: "bearer"`. The platform sends `Authorization: Bearer` instead, including on same-host redirects, with no cookie.

To see the first redirect's status and `location`, pass `follow_redirects: false`. Put it inside the entry you want to check when you send a `routes` list. By default the tools follow up to five redirects to the same HTTPS hostname on port 443. The redirect can lead to a sign-in page.

Cloud masks the temporary session value when it appears as written in the answer's `url`, headers or body. It can miss an encoded copy, such as base64. Keep session values out of anything your app returns or logs.

Use your AI assistant's browser-signed-in connection to send a request as a test end user in any environment. A job using a minted token needs the `test_end_users` grant on production and in a `workforce` realm in either environment. Leave out the `cookie` header when asking the platform for a session. With `session_as: "bearer"`, leave out `authorization` too. The platform supplies it.

On production, a job without the grant can still check the gate. Call `tzcloud_request_route` without a session or `test_end_user`. Leave out an HTML `Accept` header. Under `invited` or `workforce`, expect 401 outside `session_free_paths`. Use existing development outside `workforce` for signed-in checks if available. Report each unrun signed-in check to the owner. To run it on production, use the browser-signed-in AI connection or [a minted token with the grant](/cloud/guides/mint-a-token/#a-token-for-test-end-users).

Each call is a new sign-in, and it counts against the same limit as the sign-ins of steps 3 and 4: by default, five code starts an hour for one address. A sixth sign-in within the hour is refused `signin_code_rate_limited`. Sign another test end user in, or raise `limits.code_sends_per_hour` with `tzcloud_configure_app_sign_in` ([The limits on emailed codes](/cloud/guides/manage-end-users/#the-limits-on-emailed-codes)).

To check up to five routes with one sign-in, pass a `routes` list. Each entry gives a `path` and can give an `expect` status from 100 to 599. With `tzcloud_write_route`, each entry also names its `method`. Send reads and writes in separate calls. The routes run in order and `results` has one result per route. Each response body can be up to 12 KiB. The requests share a 60-second time limit.

A network error on one route does not stop the next route. If the batch runs out of time, unsent routes also get timeout results. Read each result on its own. A timeout alone cannot tell you whether a write ran.

`failed` counts results refused with `route_unreachable`, results whose status differs from `expect`, and results with a status of 400 or more where no `expect` was given. A matching `expect: 404` confirms the result for that path and session. It does not count as a failed check. `invalid_request` refuses the whole call instead of appearing in `results`.

To check that a page redirects with 302, set `follow_redirects: false` and `expect: 302` in its `routes` entry. The result shows the redirect instead of following it.

Each result whose request names `expect` carries `expected`: `true` when its status matches and `false` otherwise, including a refused result.

To test what a suspended user sees, call `tzcloud_set_end_user_standing` with the test end user's `id` as `end_user` and `standing: suspended`, then with `standing: active` to restore it.

The rows your routes write for a test end user are your application's own data, and they stay after the user is removed.

When verifying the first deploy, create a temporary test end user and use it for signed-in reads or the app's AI chat. These checks need no further confirmation, even if the app stores that user's own chat turns. You need no further confirmation to use the app's own delete route to remove the data these checks wrote for that test user.

To connect directly to the production database, get the owner's approval in the browser. The test user expires after 48 hours. On an app with real users, ask the owner to confirm any other production write; a request to build, deploy, or test alone does not approve it.

On an app with no real users, test writes on development where available, otherwise freely on its live copy. Report the test rows you wrote so the person can remove them before launch. Email beyond the person's own test addresses and paid calls with stored keys still need their request for this run. [Check the release](/cloud/getting-started/deploy-an-application/#check-the-release) defines when an app has no real users.

Before deleting the test end user, remove the rows through the application's own route that deletes them. Call it with `tzcloud_write_route`, naming the same `test_end_user` and environment and the method the route takes. With a shell, you can instead call that route with `curl` and the signed-in jar from step 3.

If the application has no route to delete those rows, leave them and tell the owner which remain and where, using the test end user's label and the route that wrote them. The platform's `tzcloud_query_database` reads data but cannot remove it. The owner can [ask for a separate cleanup](/cloud/guides/connect-to-your-database/#remove-test-rows-when-the-app-has-no-delete-route).

The sign-in limits apply to test end users as to anyone, so a busy test suite can meet them. By default, one address gets five code starts an hour, and one source address thirty sign-in starts. Reuse a session across tests, create more test end users, or raise the realm's limits ([The limits on emailed codes](/cloud/guides/manage-end-users/#the-limits-on-emailed-codes)).

### 9. Remove them

First clean up any records your application created during the test. Then call `tzcloud_add_test_end_users` with `remove: true`, `application`, the original `environment`, and `end_users`. No approval is required.

For `end_users`, use the `id` from each `test_end_users[]` entry that returned `created: true` in this run. Labels work in the `end_user` field when you read a code or request the sign-in command. Removal takes IDs. On a shared realm, leave `all` unset so other runs keep their fixtures.

For the production curl or browser example, call `tzcloud_add_test_end_users` with `remove: true` on production:

```json
{ "remove": true, "application": "<application id>", "environment": "production", "end_users": ["<id created in this run>"] }
```

For step 4's development command example, call `tzcloud_add_test_end_users` with `remove: true` on development:

```json
{ "remove": true, "application": "<application id>", "environment": "development", "end_users": ["<id created in this run>"] }
```

Each removal ends the user's sessions in the accounts service. Each serving router refuses the sessions after it receives the updated revocation list. It deletes the user's held codes and ends the sign-ins they could still confirm. At `expires_at`, a test end user can no longer be used for a test sign-in and stops appearing in `tzcloud_list_end_users`. You can remove it by ID while the marked record still exists. The platform also removes the record:

- in a cleanup pass after `expires_at`. The platform starts a pass every ten minutes. If cleanup falls behind, the expired record can stay longer.
- with `tzcloud_delete_end_user`, or its own account deletion from the application;
- with its realm, when you delete the environment or the application.

Delete only the jar this run created, even if the tests failed or you keep the test end users. In a Bash script, set the trap immediately after creating the jar. In separate calls, use the exact path you saved for this run.

```bash
trap 'rm -f -- "$JAR"' EXIT
```

In PowerShell, put `Remove-Item -LiteralPath $Jar -Force -ErrorAction SilentlyContinue` in the script's `finally` block, or run it with this run's saved path after the checks.

For step 4, clean up the file you chose with `--out` the same way. Keep the cleanup in the script's `trap` or `finally` too.

### Test on production from a pipeline

A pipeline, a scheduled job, or an agent with no person present tests on production under a token minted with the `test_end_users` grant ([A token for test end users](/cloud/guides/mint-a-token/#a-token-for-test-end-users)). The person claims it with `token claim`, and the job runs under `TURNZERO_CLOUD_MINTED_TOKEN`. The token creates test end users, reads their codes, and signs them in, in either environment and under every audience, with no approval in the browser.

The token still works if you change the declared audience or the tenant for `workforce`. Revoke it with `revoke_token` to end its access. Its test end users remain until their expiry, or until `tzcloud_add_test_end_users` with `remove: true` removes them.

A call to `admit_test_end_users` answers 404 `unknown_action`, and no approval admits a token: mint one with the `test_end_users` grant.

## Expected result

`tzcloud_add_test_end_users` with `labels` returns `test_signin_page` and one entry per label. A new test end user has `created: true` and an `expires_at` 48 hours away. A repeat for a label held by an unexpired test end user returns that user with `created: false`. After confirmation, `GET /__account/me` returns the test end user, and `tzcloud_list_end_users` lists it with `test: true`. With `remove: true`, the call returns `removed`, the identifiers it removed.

An admitted `tzcloud_sign_in_test_end_user` call returns the command and its Windows and npx forms, with no session value. Running that command writes the cookie jar and prints its hostname, test end user, expiry, and file path. A request with that jar reaches the app as the test end user.

## Refusals

See the [refusals reference](/cloud/reference/refusals/) for other platform errors.

| Refusal | Status | Cause | Remedy |
| --- | --- | --- | --- |
| `test_end_users_not_admitted` | 409 | A token you minted without the `test_end_users` grant called on production, or in either environment under `workforce`. The `detail` names the credential it read and the remedy. | Mint a token with the `test_end_users` grant ([A token for test end users](/cloud/guides/mint-a-token/#a-token-for-test-end-users)) and call under it, or call from your AI coding agent's session. That session is an MCP connection signed in through the browser, not one set up with a token. Adding a development environment is no remedy: it lasts, and every later deploy goes through it. |
| `test_end_users_ceiling_reached` | 409 | The call would pass twenty unexpired test end users on the realm, or fifty created by the application's realms within the hour. Nothing is created. | At the active test-user limit, use fewer labels or remove unused test end users. At the hourly creation limit, wait for capacity in that window. Removing active fixtures leaves the hourly count in place. |
| `not_test_end_user` | 409 | A label's address belongs to a real end user, or a code read or sign-in names a user who is not an unexpired test end user of that realm. Removal is refused whole if any ID names no test end user of the realm. It can remove an expired test user whose record still exists. | Use an unexpired test end user of that realm. Find one marked test in `tzcloud_list_end_users`, or create a fixture under an unused label with `tzcloud_add_test_end_users`. For an ordinary session, sign out through its normal flow. Leave real user accounts in place. |
| `no_such_end_user` | 404 | `tzcloud_read_test_signin_code` named an `end_user`, by id or by label, that no user of that realm has. | Use the id or the label that `tzcloud_add_test_end_users` with `labels` returned for the same environment. |
| `route_not_enabled` | 400 | On a realm that does not offer `email`, an emailed-code start named an address outside `synthetic.turnzero.ai`. | Use a test end user's address ending in `synthetic.turnzero.ai`. To sign in with an email address outside that domain, add `email` to the realm's `sign_in_methods`. |
| `signin_code_rate_limited` | 429 | One address started more emailed-code sign-ins in the hour than the realm allows. | Reuse a session, create more test end users, or raise `limits.code_sends_per_hour`. |
| `signin_rate_limited` | 429 | One source address started more sign-ins in the hour than the realm allows. | Reuse a still-valid session if the test has one. Wait for the applicable hourly window or start sign-in from another network. You can raise the realm's per-source sign-in start limit with `limits.signin_starts_per_hour`. |
| `test_end_user_sign_in_unavailable` | 503 | The line of `tzcloud_sign_in_test_end_user`, or `tzcloud_request_route`'s `test_end_user`, reached a platform service that cannot sign a test end user in. No one is signed in. | Sign in as step 3 or step 5 does. |
| `command_too_old` | 426 | The command is older than the `minimum_version` the refusal names. No one is signed in. | Update the turnzero command, then call `tzcloud_sign_in_test_end_user` again and run its returned line. |
| `local_route_required` | 409 | A call to `tzcloud_sign_in_test_end_user` included `delivery` outside the HTTP action route. Nothing is signed in. | Omit `delivery` from the MCP call and run the returned `turnzero session --origin https://dev.turnzero.ai` line. The command writes the session to the cookie jar; keep that value out of the conversation. |

## Related

- [Manage end users](/cloud/guides/manage-end-users/) lists, suspends, and deletes end users, and lists every realm setting.
- [Add sign-in to your app](/cloud/guides/add-sign-in-to-your-app/) turns on the accounts service and chooses the sign-in methods.
- [Sign in from a native app](/cloud/guides/sign-in-from-a-native-app/) runs a native app's sign-in, refresh, and revocation.
- [Test your application locally](/cloud/guides/test-your-application-locally/) tests the backend offline on the Account package's double.
- [Tell which user sent a request](/cloud/guides/add-sign-in-to-your-app/#3-tell-which-user-sent-a-request) shows how a backend verifies the session.
- [tzcloud_add_test_end_users](/cloud/reference/actions/add-test-end-users/), [tzcloud_read_test_signin_code](/cloud/reference/actions/read-test-signin-code/), and [tzcloud_sign_in_test_end_user](/cloud/reference/actions/sign-in-test-end-user/) in the generated reference give each action's arguments and result.
