# Authentication

Altertable automatically generates lakehouse username and lakehouse password credentials for each environment in your account.

## Goal

Retrieve environment-specific lakehouse credentials and verify them against the HTTP query endpoint.

## Prerequisites

- Access to the Altertable organization and environment you want to connect to.
- Permission to view its **Credentials** section.

## Steps

### 1. Copy the credentials

Open the **Credentials** section of the dashboard menu. Copy the lakehouse username and lakehouse password generated for the environment.

### 2. Choose a client interface

These credentials work across all client interfaces for connecting to the lakehouse. Note that authentication methods may vary by interface—refer to the specific documentation for each client interface for details.

- [HTTP API](/docs/api-references/lakehouse.md): send the credentials with HTTP Basic Auth.
- [Arrow Flight SQL](/docs/query-data/adapters/arrow-flight-sql.md): pass the username and password to a compatible client over TLS.
- [Postgres adapter](/docs/query-data/adapters/postgres.md): use the credentials in a TLS-enabled Postgres connection.
- [Altertable CLI](/docs/developer-tooling/cli.md): store credentials in a local profile with `altertable login`.

### 3. Configure the client

Follow the selected interface guide. Keep the username and password paired with the environment where Altertable generated them.

## Verification

For the HTTP API, base64-encode the credentials and run a small query:

```bash
export ALTERTABLE_BASIC_AUTH_TOKEN=$(printf '%s' "$LAKEHOUSE_USERNAME:$LAKEHOUSE_PASSWORD" | base64)

curl https://api.altertable.ai/query \
  -H "Authorization: Basic $ALTERTABLE_BASIC_AUTH_TOKEN" \
  -d '{"statement":"SELECT 1"}'
```

A valid connection returns a JSONL response for `SELECT 1`.

## Troubleshooting

- **Authentication fails:** copy both credentials again and make sure neither value includes surrounding whitespace.
- **Credentials work in another environment:** return to the intended environment before opening **Credentials**.
- **A database client cannot connect:** confirm that the hostname, port, and TLS settings match the selected interface guide.
- **A CLI profile expired:** run `altertable login` again for that profile.

**Continue in Altertable:** [Open credentials](/app)

## Next steps

- [Query with HTTP API](/docs/query-data/http-api.md)
- [Connect with Arrow Flight SQL](/docs/query-data/adapters/arrow-flight-sql.md)
- [Connect with the Postgres adapter](/docs/query-data/adapters/postgres.md)
- [Install the Altertable CLI](/docs/developer-tooling/cli.md)