# See who signed up: your users, without a production query

> List the users of your app on thelastapi by reading your project database with a read-only key or exporting your data, without risking production writes.

**To list the users of your app on thelastapi, query your project database with a read-only key or export your data, because all user records are stored directly in your own Postgres database rather than trapped in a closed authentication dashboard.** When you enable sign-in, the platform provisions a dedicated database inside your project and stores accounts, credentials, and sessions right alongside your application data. You can inspect who has signed up without using elevated credentials or risking accidental modifications to live records.

This guide explains how sign-in stores user records, how to use scoped permissions to inspect user tables safely, and how development environments keep test accounts away from real users.

## Where your app's users actually live

Many authentication systems keep user records inside an external vendor console. If you want to see who signed up, you have to log into their dashboard, search their interface, or sync records back into your application via webhooks.

On thelastapi, adding sign-in (`auth`) automatically adds a Postgres database (`database`) to the project. Your users, their sessions, their email addresses, and their connected accounts live in standard database tables inside that database.

```bash
# Adding auth automatically includes your project database
vibiz init my-app --resources auth
```

Because your authentication system shares your project's database, you do not need a custom sync pipeline or an isolated user registry. Every sign-up creates a row in your database. You can read those records using standard Postgres queries over the internet with your `DATABASE_URL`.

If you are setting up authentication for the first time, you can read more about setting up OAuth in [add Google sign-in to your app without your own OAuth app](https://thelastapi.dev/blog/add-google-sign-in) and passwordless logins in [magic link sign-in without building it yourself](https://thelastapi.dev/blog/magic-link-sign-in). For a complete walkthrough of an application setup, see [how to add sign-in to a Next.js app](https://thelastapi.dev/blog/add-sign-in-nextjs-app).

## Why querying production directly with owner keys is risky

When you need to see who signed up or pull a quick count of active users, reaching for the production database connection string is tempting. But using your full-access credentials carries operational risks:

- **Accidental writes or drops.** Running manual SQL queries in a production console can lead to accidental mutations or table locks.
- **Leaked secrets.** Full-access keys (`vz_sk_...` with `access: owner`) can deploy code, change billing settings, rotate keys, and move live money. Passing these keys to team members or reporting scripts gives away too much authority.
- **Unintended schema drift.** Ad-hoc maintenance scripts might inadvertently run migrations or alter session constraints.

Instead of handing out full administrative control to inspect users, thelastapi provides role-based permission scopes and environment isolation.

## Read user data safely with a scoped key

To inspect user records without giving away write access or administrative authority, you can create a key scoped strictly for reading data.

Keys on thelastapi come in two core modes: Full access and Limited. A Limited key defaults to the development environment and cannot touch production secrets. However, an account owner can grant specific read permissions to a key without giving it write access.

### Creating a read-only reporting key

You can create an API key dedicated to reporting by using the `read_all` preset:

```bash
vibiz keys create reporter --read-all
```

The `read_all` preset allows the key to read production data (including the database, environment variable names, live payment details, and exports) while preventing any changes to live services.

### Granting granular database read access

If you want an even narrower scope, you can assign single permissions (`grants`) to a Limited key. For viewing user tables, the relevant permission is `database.production:read`:

```bash
# Create a limited key
vibiz keys create analyst --limited

# Grant only database read access
vibiz keys access key_123 allow database.production:read
```

You can also update key permissions directly over the HTTP API using your owner key:

```bash
curl -X PATCH https://thelastapi.dev/v1/api-keys/key_123 \
  -H "Authorization: Bearer $OWNER_KEY" \
  -H 'content-type: application/json' \
  -d '{"grants":["database.production:read"]}'
```

Here is how permissions relevant to user management and database inspection break down:

| Permission | Group | What it allows |
| --- | --- | --- |
| `database.production:read` | Database | Read the production database and user data |
| `app_users:write` | Database | Invalidate a session or sign out an application user |
| `exports.production:read` | Production settings | Export production data snapshots |
| `auth.production:write` | Production settings | Change production sign-in settings |

When a script or an agent holding a Limited key attempts an operation outside its assigned grants, the API returns `403 forbidden` with `details.reason: "owner_only"` and includes a `details.grant_url` where the account owner can review and approve the permission. More details on key scopes are available in the [Keys and environments documentation](https://thelastapi.dev/docs/keys).

## Pulling connection strings and environment variables

Once you have the appropriate permissions, you can pull your environment variables to connect your database client or SQL tool.

For production credentials, an account owner can pull variables using the CLI:

```bash
vibiz env pull --format dotenv -o .env.production
```

If your application code runs on external infrastructure outside thelastapi hosting, you do not need to copy and paste individual connection strings into your hosting provider. You can provide a single application key (`VIBIZ_APP_KEY`) and load environment variables dynamically at boot:

```ts
import { vibiz } from '@vibiz/app';

// Injects DATABASE_URL and auth variables into process.env
await vibiz.loadEnv();
```

To use sign-in from an external domain, add your domain to the project using `vibiz domains add app.example.com --elsewhere`. For apps not hosted on thelastapi, sign-in trusts the external origin once its verification TXT record is confirmed. Review [Use one service](https://thelastapi.dev/docs/use-one) for instructions on running authentication independently of hosting.

## Inspecting development users without touching production

When testing sign-in flows or writing queries that summarize user accounts, you should test against isolated data. thelastapi isolates production from development across all services.

When you run `vibiz dev`, the platform provisions a local development copy:

```bash
vibiz dev
```

This command branches your Postgres database. The development database contains your exact production schema and tables, but **zero production rows**. 

| Environment | Database | Sign-in Service |
| --- | --- | --- |
| **production** | Live database with real user records | Live users; trusts verified live domains |
| **development** | Branch with identical tables and **no rows** | Test users; trusts `http://localhost:3000` only |

Because the sign-in service in development maintains its own independent user pool, you can create test users, trigger verification emails, and test password resets without mixing mock data into your live user metrics.

If your local database state becomes cluttered during testing, you can wipe it clean and re-branch from production in one step:

```bash
vibiz dev --reset
```

The next time you run `vibiz dev`, a fresh database branch with an empty user table is created.

## Checking users inside your application

If you need to display user information inside your web application—such as rendering an account page or checking identity in a server route—you can retrieve the active session directly.

When using the starter template (`vibiz init --template nextjs-saas`), user session resolution is handled out of the box in `lib/auth/server.ts`:

```ts
import { currentUser } from '@/lib/auth/server';

export default async function ProfilePage() {
  const user = await currentUser();

  if (!user) {
    return <p>Please sign in to view this page.</p>;
  }

  return (
    <div>
      <p>Signed in as: {user.email}</p>
      <p>User ID: {user.id}</p>
    </div>
  );
}
```

The underlying service uses `VIBIZ_AUTH_BASE_URL` and `VIBIZ_AUTH_COOKIE_SECRET` to verify cookies and sign-in tokens. For custom services or external microservices that need to verify identity tokens without hitting the database, the environment also provides `VIBIZ_AUTH_JWKS_URL` and `VIBIZ_AUTH_PROJECT_ID`.

To learn how to manage sign-in settings, configure email verification methods, or restrict access by email domain, consult the full [Sign-in documentation](https://thelastapi.dev/docs/sign-in).

## Next steps

To safely inspect your users today, generate a read-scoped key using `vibiz keys create reporter --read-all` or assign `database.production:read` to your existing agent keys. You can connect your preferred SQL client using `DATABASE_URL` knowing that live writes and administrative settings remain protected.

## Frequently asked questions

### Where are my application's user accounts stored?

User accounts and session records are stored directly in your project's serverless Postgres database, which is automatically added whenever you enable the `auth` resource.

### Can an AI agent or automated script read production user records?

Yes, but only if the key has been granted the `database.production:read` permission or uses the `read_all` key preset; standard Limited keys cannot access production data by default.

### How do I test sign-up flows without adding test accounts to my live database?

Run `vibiz dev` to spin up a local development environment, which creates a branched database containing your exact schema with no production rows and an isolated sign-in service.

### How can an administrator force a user to sign out?

You can invalidate user sessions if your key has the `app_users:write` permission, which specifically allows signing out application users without requiring full owner access.

---

Published 2026-11-15 · https://thelastapi.dev/blog/see-who-signed-up
