# Organizations, members and roles
Source: https://sovaria.in/docs/organizations

What an organization holds, inviting people, the Owner, Admin, Member and Viewer roles, custom roles with fine-grained permissions, removing members and deleting an organization.

An **organization** is your team's account on Sovaria. It owns projects, holds the plan and the invoice, and lists the people who may work on its projects. Everyone who uses the console belongs to at least one organization.

(Diagram: What an organization contains)

> **Members are not app users:** **Members** are your colleagues who build and run projects in the console. **App users** sign up to the apps you build ([Authentication overview](https://sovaria.in/docs/auth-overview)); they never see the console, and an app role you give them (`ADMIN`, `STAFF`…) grants nothing here.

## Create an organization

Every account **owns one organization**, on every plan: you create it when you sign up (or from **New organization** if you have none), and its plan pays for it. You can be a **member of any number** of other organizations — joining one never uses your own. Need more projects? Add them to your organization ($10/month each on Pro and Ultra, see [Billing, invoices and overage](https://sovaria.in/docs/billing)). Need several organizations for clients? Contact sales.

**Transfer ownership** (owner only, **Team** › a member's menu): hand the organization to another of its admins, for example when a founder leaves. Billing moves to the new owner's account and the organization takes their plan; the new owner must not already own an organization. You stay an owner member and can then leave. API: `POST /api/v1/org/{org_id}/transfer-ownership` with `{"new_owner_id": "<user id>"}`; `409 ONE_OWNED_ORG` when they already own one.

The owner who pays (marked **Owner · pays** under Team) can't be removed or lose admin rights; deleting the organization frees their slot.

## Built-in roles

| Role | Can | Can't |
|---|---|---|
| **Owner** | Everything, including billing, API keys, project settings, members and deleting the organization. Only an owner can make someone an owner or remove one. | — |
| **Admin** | Everything an owner can, except granting or taking away the owner role. | Make or remove owners. |
| **Member** | Build and run everything: tables and SQL, storage, functions, auth users, realtime, policies, secrets, logs, Sovariq. | Change billing, manage API keys or change project settings. |
| **Viewer** | See everything (tables, files, functions, settings, logs, billing) and ask Sovariq questions. | Change anything. |

Only owners and admins can create projects, invite or remove members and delete projects. Every console request is checked on the server against the member's permissions — a URL alone never grants access.

## Custom roles

Under **Organization › Roles**, owners and admins can create up to 50 custom roles from the permissions below, and assign them to a member for the whole organization or for one project. A member's permissions are their built-in role's plus every custom role assigned to them.

| Area | Permissions |
|---|---|
| Database | `database.read` (view tables, rows, schemas) · `database.write` (change rows, run SQL, change schemas) · `database.admin` (backups, restore, compute, database settings) · `database.backup.read` (download backups and exports — a full copy of the data; not in Viewer) |
| Storage | `storage.read` · `storage.write` (upload, move, delete files) · `storage.admin` (buckets and storage policies) |
| Functions | `functions.read` (code and logs) · `functions.invoke` (run from the console) · `functions.deploy` (create, deploy, roll back, delete) |
| Authentication | `auth.read` · `auth.manage` (app users, providers, app roles, auth settings; auth hooks and the JWT hook need `auth.manage` even to view) |
| Realtime | `realtime.read` · `realtime.manage` |
| Policies | `policies.read` · `policies.write` |
| Secrets and keys | `secrets.manage` (project secrets and environment variables) · `keys.read` · `keys.manage` (create, rotate, revoke API keys) |
| Observability | `logs.read` (logs, metrics, traces, audit trail) |
| Project | `settings.manage` (project settings, custom domains, webhooks, integrations) |
| Billing | `billing.read` · `billing.manage` (plan, payment method, add-ons) |
| Sovariq | `ai.use` (ask, read-only) · `ai.apply` (let Sovariq make changes after you confirm; also needed to run, continue or retry a project agent) |

> **Tip:** A read-only SQL statement only needs `database.read`; anything that writes, or more than one statement, needs `database.write`.

An organization can also narrow what Sovariq may do when it acts for a member (AI permissions); that can only remove permissions, never add them.

## Invite people

1. **Open Organization › Team** — Choose **Invite**, enter an email and a role.
2. **They get an email** — The invitation link works for **7 days**. Inviting the same email again sends a fresh link.
3. **They accept** — They sign in (or sign up) with that email address and verify it, then accept. Nobody is added to an organization without accepting.

JavaScript:
```js
await sovaria.api.org.createOrgInvite({ email: 'ada@example.com', role: 'MEMBER' })
const members = await sovaria.api.org.listOrgMembers()
```

cURL:
```bash
curl -s -X POST "https://api.sovaria.in/api/v1/org/<org-id>/invites" \
  -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"email":"ada@example.com","role":"MEMBER"}'
```

Routes and parameters: [HTTP API: organizations, projects and keys](https://sovaria.in/docs/rest-organizations).

## Change roles and remove members

- Owners and admins change roles and remove members under **Team**. You can't change your own role — ask another owner.
- Only an owner can give or take away the owner role, and an organization always keeps at least one owner (the last owner can't be demoted or removed).
- Removing someone takes effect within seconds: their console session and CLI token stop working for this organization.

### When someone leaves

1. **Remove them from Team** — Their access ends at once.
2. **Rotate what they could see** — If they could read API keys or secrets (`keys.read`, `secrets.manage`), rotate the service role key and any secrets they saw ([Keys, tokens and credentials](https://sovaria.in/docs/credentials)).
3. **Check the audit log** — Review what they changed recently in **Logs & Audit** ([Audit log](https://sovaria.in/docs/audit-logs)).

## Security settings

Owners and admins set these under **Organization → Settings → Security**. Each change is written to the organization's audit log, and owners and admins get an email when one of them changes.

| Setting | What it does | Plans |
|---|---|---|
| Require MFA | Members without an authenticator app, passkey or phone factor lose access to the organization's projects until they add one. You need MFA on your own account to turn it on. | Every plan |
| Sign out after inactivity | A member who hasn't used the console for this long (15 minutes to 24 hours) is signed out at the next session refresh. | Pro and higher |
| Longest session | Members sign in again after this long (8 hours to 30 days), however active they are. | Pro and higher |

### Session timeouts

- They apply to every console member (and `sov login` sessions) of the organization. A member of several organizations gets the strictest value of all of them.
- Sessions are checked when they refresh, so a sign-out can come up to one access-token lifetime after the limit.
- With [HIPAA mode](https://sovaria.in/docs/hipaa) on, HIPAA's limits (15 minutes idle, 12 hours in total) stack on top: the stricter value of each wins.
- On Free you can't set or tighten a timeout (`403 PLAN_FEATURE_REQUIRED`). If an organization moves down to Free, the timeouts it already set stay, and you can loosen or turn them off: a downgrade never weakens your security on its own.

HTTP:
```http
PUT /api/v1/org/<org-id>
{ "settings": { "session_idle_minutes": 30, "session_max_minutes": 720 } }   // 0 turns one off
```

## Delete an organization

> **Warning:** Deleting an organization deletes **every project in it** — databases, files, functions, apps, users — and cancels its subscription. Only owners and admins can do it (Organization › Settings › Delete).

What happens, in order:

1. **At once** — The organization, its projects, environments and memberships disappear from the console, the API and every search. API keys, sign-in and project URLs stop working, S3 keys are revoked and the subscription is canceled, so nothing is charged again.
2. **During the retention window** — The data waits for the platform's retention window (30 days unless Sovaria set another), so a mistaken delete can still be recovered by Sovaria support. Nothing in it is reachable by anyone.
3. **Then it is purged everywhere** — Every service deletes the organization's data: databases with their containers, backups and point-in-time recovery archive; stored files and buckets; functions, apps, hosted sites and custom domains; Sovariq conversations and agents; realtime keys; version history; analytics, crash reports, traces and the organization's audit log; access policies; usage and AI allowances; API keys, settings, invites, messaging and the apps' end users. A service that is briefly unavailable is retried until it confirms.

### What is kept, and why

| Record | Kept for | Why |
|---|---|---|
| Invoices, receipts and payment records | 8 years | Indian tax law |
| Subscriber record: the organization's name, owner and contact, members, period of service | 5 years after deletion | CERT-In Directions (2022) for cloud service providers |
| Sovaria staff audit log (what staff did, including this deletion) | 7 years or more | Security and compliance audits; it holds no project data |
| The organization's own audit log, if it was in HIPAA mode | 6 years | HIPAA §164.316(b)(2) |
| Security logs (sign-ins, network access) | 400 days, then deleted | CERT-In (180 days) and DPDP Rules (1 year) |
| A deletion record: ids, dates and counts — no content | With the records above | Proof the data was deleted |

Nothing else is kept. Backups taken before the deletion are deleted with the organization; the platform's own disaster-recovery copies of Sovaria's control database age out within 35 days.

## A suspended organization

Sovaria can suspend an organization — for an unpaid invoice, or abuse of the [acceptable use rules](/terms#use) — until the cause is sorted out. Every page of the console then says so. Nothing is deleted, and reactivating turns everything back on within seconds.

| While suspended |  |
|---|---|
| Apps, hosted sites, API keys (anon and server), app users' sign-in | Refused with `403 ORG_SUSPENDED` |
| Functions (HTTP and public), cron schedules, queues, triggers and workflows | Skipped; schedules and triggers keep their settings |
| Database, storage, realtime, Sovariq | Refused |
| Members signing in to the console and looking around | Allowed |
| Billing: paying an invoice, changing the payment method | Allowed |
| Changes in the console (tables, functions, settings, deploys) | Paused until reactivated |
