# Examples

Use these end-to-end recipes to verify a new environment, instrument an application, or connect an agent. Replace placeholder credentials and catalog names before running a command.

## Upload a CSV and query it

**You need:** lakehouse credentials, a writable catalog, and a local `users.csv` file.

### 1. Upload the file

```bash
curl "https://api.altertable.ai/upload?catalog=my_catalog&schema=main&table=users&mode=create" \
  -H "Authorization: Basic $ALTERTABLE_BASIC_AUTH_TOKEN" \
  --data-binary @users.csv
```

### 2. Verify the rows

```bash
curl https://api.altertable.ai/query \
  -H "Authorization: Basic $ALTERTABLE_BASIC_AUTH_TOKEN" \
  -d '{"statement":"SELECT count(*) AS row_count FROM my_catalog.main.users"}'
```

The JSONL response should contain a `row_count` value matching the CSV. See the [upload guide](/docs/ingest-data/http-api.md) for overwrite and append modes.

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

## Track and verify a product event

**You need:** Product Analytics enabled and a public API key.

### 1. Send an event

```bash
curl https://api.altertable.ai/track \
  -H "X-API-Key: $ALTERTABLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "environment":"production",
    "event":"Purchase Completed",
    "distinct_id":"user_123",
    "properties":{"amount":99.99,"currency":"USD"}
  }'
```

### 2. Verify ingestion

```sql
SELECT event, distinct_id, properties
FROM product_analytics.main.events
WHERE event = 'Purchase Completed'
ORDER BY timestamp DESC
LIMIT 10;
```

The newest row should contain `user_123` and the purchase properties. Continue with the [funnel guide](/docs/query-data/product-analytics/funnel.md) when the event is flowing.

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

## Run a first CLI query

**You need:** a browser for sign-in and access to an Altertable environment.

### 1. Install and authenticate

```bash
curl -fsSL https://install.altertable.ai | sh
altertable login
```

### 2. Verify the profile

```bash
altertable query "SELECT 42 AS answer"
```

The result should contain one `answer` column with the value `42`. Next, list available catalogs and run a query against your own data:

```bash
altertable catalogs list
altertable query "SELECT * FROM my_catalog.main.my_table LIMIT 10"
```

See the [CLI guide](/docs/developer-tooling/cli.md) for profiles, structured output, and file ingestion.

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

## Connect Codex through MCP

**You need:** Codex with MCP support and access to an Altertable organization.

### 1. Add the hosted server

Follow the [Codex setup guide](/docs/agent-setup/codex.md) and use this endpoint:

```text
https://mcp.altertable.ai/mcp
```

### 2. Verify tools and access

Ask Codex:

```text
Use Altertable to list my available catalogs, then describe the tables in the catalog I select.
```

Codex should request authorization, discover the Altertable tools, and return catalogs from the environment selected during sign-in. See the [MCP tools reference](/docs/api-references/mcp-tools.md) for every available operation.

**Continue in Altertable:** [Configure MCP server](/app)

## Need a different path?

Browse [ingestion guides](/docs/ingest-data.md), [query clients](/docs/query-data.md), or [agent setup](/docs/agent-setup.md) for a workflow that matches your stack.