# Organisations and moving Decisions

Organisations own Decisions, members and credentials, and a Decision can move between them.

## Your personal space and organisations

Everyone has a **personal space**, named by their username: `@tom`, with Decisions such as
`@tom/refunds`. You choose the username the first time you sign in, and can change it on the
**Account** page from your menu. Your personal space is on the Free plan for as long as you like:
build, test and deploy to Test there, on your own.

An **organisation** is where a team publishes and runs Decisions in production. It has its own name
and identifier (the `acme` in `acme/refunds`), its own members and its own plan.

To make one, open the organisation switcher at the top of the sidebar and choose **New
organisation** (or **Create an organisation** on your personal space's Billing page). Give it a name,
check its identifier, choose Founder or Scale and continue to payment. Founder starts with a 14-day
trial if you haven't had one. You become the owner, and you can own up to ten.

Once the payment is confirmed, the organisation's **Welcome** page lets you choose Decisions from
your personal space to bring across (see [Moving a Decision](#moving-a-decision)). If you leave the
payment unfinished, the organisation waits on that page, marked **Payment not finished** in the
switcher, where you can pay or discard it. Nothing is charged until you pay, and an unpaid
organisation is removed after a day.

## Names

Settings → **General** holds the organisation's name, which owners and admins can change, and its
identifier, which owners can change. A changed identifier keeps working: links, keys and agents
that use the old one are sent to the new one.

A name has one owner. Your username and the identifiers of organisations you own can share a name
(`@acme` and `acme`), but nobody else can take it or one that reads the same, such as `acme`,
`ac-me` or `acrne`. A name you stop using stays yours rather than passing to someone else. Some
well-known names are held for their owners. If someone holds a name that's yours by right, such as
your company's name or trademark, write to us (see the [Terms](https://typefuse.dev/terms#names)).

## Members and roles

Settings → **Members** lists who belongs to the organisation. There are four roles:

- **Owners** manage everything, including other owners and the plan.
- **Admins** manage members, environments, Applications and deploy tokens, and approve deployments.
- **Members** build, test, run, publish and deploy Decisions.
- **Viewers** read everything: Decisions, drafts, versions, Test sets, Evaluations, Comparisons,
  Insights, the Decision log, the audit trail, deployments, approvals and members. They can't create,
  edit or run anything, publish, deploy, manage keys or tokens, or change settings or billing. Where
  an environment names a viewer as an approver, they approve and reject its deployment requests (see
  [Who approves](https://typefuse.dev/guides/deployments#who-approves)). A viewer's agents and connected apps only
  read in that organisation, whatever access they were given. Viewers count as members for your
  plan.

An organisation always keeps at least one owner. Anyone else can leave from the Members page.

Teams, for grouping members and sharing approvals, are coming later.

## Inviting people

Everyone joins an organisation by invite, whether or not they already use TypeFuse. Owners and
admins invite people from Settings → **Members**: enter their email and role under **Invite
someone**. Only an owner can invite another owner. How many members you can have depends on your
plan and its extra seats (see [Extra seats](https://typefuse.dev/guides/plans#extra-seats)), and waiting invites count
towards it.

Each invite has a link, shown as soon as you invite someone and again from **Copy link** on the
waiting invite. TypeFuse also emails the link once its email is switched on, which it isn't yet, so
for now copy the link and send it yourself.

Opening the link shows which organisation and role the invite is for. The invited person signs up
with the invited email address, or logs in if they already have an account, and joins straight
away. Someone new to TypeFuse also gets a personal space of their own, but they land in the
organisation that invited them. When they join, whoever invited them is notified.

An invite link:

- works only for the email address it was sent to. Someone signed in with a different account is
  told so and isn't joined; they can log out and continue with the invited email.
- works once. After it has been accepted, the link no longer does anything.
- lasts 14 days. An expired invite is marked on the Members page; **Resend** sends it again and
  gives the same link another 14 days.

**Cancel** withdraws a waiting invite, and its link stops working at once. Inviting, resending,
cancelling and accepting are all recorded in the organisation's Audit.

When you open TypeFuse without choosing an organisation, it opens the one you last used, or the one
you just joined.

## Keys and tokens

**API keys** in the sidebar holds the organisation's credentials, a tab for each:

- **Runtime keys** call deployed Decisions in one environment; see [Calling a Decision](https://typefuse.dev/guides/calling).
- **Applications** name the systems that call your Decisions, so the
  [Decision log](https://typefuse.dev/guides/decision-log) shows which one made each call. Every organisation has a
  **Default** Application.
- **Deploy tokens** let CI deploy; see [Deploying from CI](https://typefuse.dev/guides/deployments#deploying-from-ci).

Personal access tokens and connected apps belong to you rather than the organisation. Find them under
**Connect an agent**, then **Manage**. Owners and admins can also see and revoke members' connected
apps on the Members page.

## Moving a Decision

A Decision can move to another organisation, for example from your personal space to your
company's. A new organisation's Welcome page offers this for your personal Decisions; at any other
time, open the Decision's **Settings**, then **Move…** under **Move to another organisation**.
You need to be an owner or admin of both organisations, and the one it moves to needs a paid plan.

**What moves:** the Decision with its source, README, versions, Examples, Test sets, Test runs,
Evaluations, Datasets, Comparisons and deployment history. Environments it needs are created in the
new organisation.

**What stays:** recorded calls and the audit trail, usage and billing history, and the old
organisation's runtime keys, Applications and deploy tokens. The Decision's own pages still show all
its calls.

A move waits while a deployment is waiting for approval or a set time, or while a Comparison is
running. The dialog lists anything that stops it.

**Callers don't need to change anything.** The old identifier keeps working: it forwards
permanently, and its name stays reserved in the old organisation. The old organisation's runtime
keys keep working at the old identifier, and answers carry a `TypeFuse-Moved-To` header so you know
to update. The new organisation's keys work at either identifier, and calls count towards the new
organisation's plan.

Once your callers have moved to new keys, an owner or admin of the new organisation can choose **Stop
accepting keys** for the old identifier in the Decision's **Settings**; after that, old keys are refused with
`403 OLD_KEYS_STOPPED`.

There is no undo, but you can move a Decision back the same way.

## Deleting an organisation

An owner can delete an organisation at the bottom of Settings → **General**, by typing its
identifier. Its runtime keys stop working at once and everyone can only read it. After 7 days it is
deleted for good, with its Decisions, versions, recorded calls, test evidence, keys and audit trail.
Until then an owner can restore it from the same place.

An organisation can't be deleted while it has a paid subscription, while a Decision is live or
waiting to go live in one of its environments, or while another organisation runs one of its
Decisions as a companion. The page says which.

**Decisions that moved out keep working.** If a Decision moved from this organisation to another,
callers of its old identifier are still forwarded to it after the deletion, with the new
organisation's keys. The deleted organisation's own keys stop, like all its keys. Nobody can take
the deleted organisation's identifier while any such forward exists.

**Decisions that moved in are deleted with it.** Their old identifiers in the organisations they
came from stop answering. The delete dialog lists those identifiers and the keys that called them in
the last 30 days, and you confirm that you understand before it goes ahead.

## Deleting your account

Choose **Account** in your menu, then **Delete account** and type `DELETE`. Your personal space,
and every organisation where you are the only member, is deleted with your account: locked at once,
and deleted for good after 7 days. You leave every other organisation. Until then you can sign in
and restore your account from the same page, which restores those organisations too.

If you are the only owner of an organisation that has other members, make one of them an owner on
its Members page, or delete the organisation, before deleting your account.
