# Quickstart
Source: https://sovaria.in/docs/quickstart

Create a project, make a table that each user only sees their own rows of, and sign users up and query it from your app.

You will build the backend for a small notes app: a `notes` table where **every signed-in user only sees and changes their own notes**, and a few lines of code that sign a user up, add a note and list notes. Everything on this page was run against a real project before it was published.

## 1. Create your account and project

1. **Sign up** — Go to [console.sovaria.in](https://console.sovaria.in) and create an account. With email and password we send a confirmation link first — you need it before you can create an organization. **Sign in with GitHub** skips this, because GitHub has already verified your email.
2. **Create an organization** — An organization holds your team and billing. Use your company or personal name; you can rename it later.
3. **Create a project** — Pick a name and the **region** closest to your users (it can't be changed later). While the database is set up, the project home shows each step (creating the database, applying the base schema, connecting auth and storage) with the time left, and pages such as Table Editor say *Setting up…*; it usually takes 10–30 seconds, and the dashboard fills in on its own when it is done. If it fails, the home page says why, with **Retry**.

## 2. Copy your project URL and anon key

Click **Connect** in the top bar. The **API** tab shows the two values your app needs:

- **Project URL** — `https://<project-ref>.sovarias.in`. Every request goes here.
- **Anon key** — starts with `svr_`. It is safe in a browser or mobile app: it only does what your policies allow anonymous visitors to do.

> **Warning:** Never put the **service role key** (Project settings → API keys) in an app. It bypasses every policy. Use it only on your own servers — see [API keys](https://sovaria.in/docs/api-keys).

## 3. Create the table and its row rules

Open **SQL Editor**, paste this and press **Run** (⌘/Ctrl + Enter):

SQL:
```sql
create table notes (
  id bigint generated always as identity primary key,
  owner_id uuid not null default auth.uid(),
  body text not null check (length(body) between 1 and 2000),
  created_at timestamptz not null default now()
);

-- Each signed-in user only sees and changes their own notes.
alter table notes enable row level security;
alter table notes force row level security;

create policy "own notes" on notes
  for all using (owner_id = auth.uid()) with check (owner_id = auth.uid());
```

- `auth.uid()` is the id of the app user making the request (empty for anonymous visitors), so `owner_id` fills itself in.
- `enable` **and** `force` row level security are both needed. With RLS forced, Sovaria lets your Postgres policies decide who sees which rows. Without it, app users get `403 … NO_POLICY_DEFINED` until you add an access policy for the table — see [Row-level security and access](https://sovaria.in/docs/row-level-security).
- The SQL editor records schema changes as migrations automatically (**Database → Migrations**).

> **Tip:** Prefer clicking? **Table Editor → New table** creates the same table, and its **Owner only** preset sets up these row rules for you.

## 4. Install the SDK

JavaScript:
```bash
npm install @sovaria/sdk
```

Python:
```bash
pip install sovaria-sdk
```

## 5. Sign a user up and use the table

Values go in a separate list (`$1`, `$2`, …) and the database binds them, so user input can never change your SQL.

JavaScript:
```js
import { createClient } from '@sovaria/sdk'

const sovaria = createClient('https://<project-ref>.sovarias.in', '<anon-key>')

// Passwords need 8+ characters with an uppercase letter, a digit and a symbol (configurable).
await sovaria.auth.signUp('ada@example.com', 'Correct-Horse-9!', 'Ada')

await sovaria.data.sql('insert into notes (body) values ($1)', ['My first note'])

const { rows } = await sovaria.data.sql('select id, body, created_at from notes order by id desc')
console.log(rows) // only Ada's notes

await sovaria.auth.logout() // ends the session; the client continues as an anonymous visitor
```

Python:
```python
import asyncio
from sovaria import create_client

async def main():
    async with create_client("https://<project-ref>.sovarias.in", "<anon-key>") as sovaria:
        await sovaria.sign_up("ada@example.com", "Correct-Horse-9!", "Ada")
        await sovaria.sql_query("insert into notes (body) values ($1)", params=["From Python"])
        result = await sovaria.sql_query("select id, body from notes order by id desc")
        print(result["rows"])

asyncio.run(main())
```

cURL:
```bash
URL=https://<project-ref>.sovarias.in
KEY=<anon-key>

# Create the user, then sign in to get an access token
curl -s $URL/api/v1/auth/register -H 'Content-Type: application/json' \
  -d '{"email":"ada@example.com","password":"Correct-Horse-9!","name":"Ada"}'
TOKEN=$(curl -s $URL/api/v1/auth/project/login -H 'Content-Type: application/json' \
  -d '{"email":"ada@example.com","password":"Correct-Horse-9!"}' | jq -r .access_token)

# Run SQL as Ada
curl -s $URL/api/v1/sql/query -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"sql":"select id, body from notes where id = $1","params":[1]}'
```

## 6. Check that it is private

Sign up a second user and run the same `select`: it returns no rows. An `update notes set body = …` from that user changes **0 rows**. Requests with only the anon key (nobody signed in) see no notes either, because `auth.uid()` is empty for them.

## What next

- [Connect your app](https://sovaria.in/docs/connect-your-app): Sessions, React and Next.js setup, servers and environment variables.
- [Database](https://sovaria.in/docs/database): Tables, SQL, migrations and every way to query.
- [Authentication](https://sovaria.in/docs/auth-overview): Magic links, social sign-in, MFA and email templates.
