# Companies - build internal tools for a company with other developers

A company on Scava is the place for the tools of one organisation. You create it by its domain, for example `@company.com`. Everyone with an address there belongs to it, and you can add more people, such as a freelancer. The company has its own groups, its own house rules and its own developers. Every developer of the company can change all its apps. One developer can build for several companies, for example an agency for its clients.

Companies are created and changed on the Overview page at scava.ai, or by your agent with the same rights you have. When it adds people, invites a developer, joins a company or deletes one, you get an email.

## Create a company

On the Overview page, enter the domain of the company, like `company.com`, and optionally a name. You need a plan. Domains of public mailboxes such as `gmail.com` are refused. You become the **owner** of the company: it belongs to you, with its people, groups, roles and house rules.

Scava does not check that you work for the domain, so an agency can create a company for a client. The domain only decides who counts as inside the company for its house rules; it opens no app and shows nothing of anyone else. Two people who each create a company for the same domain have two separate companies and do not see each other's.

The company gets its own tab on the Overview page. It shows its apps, its people, its developers, its groups and its house rules. What is stored inside the apps is never shown there.

## People of the company

Everyone with an address at the company's domain belongs to the company. Under "People added to the company" you add single addresses besides that, for example `freelancer@mail.com`. They count as inside the company for the house rules, so a company that only shares inside itself can still share with them.

Adding people to the company does not open any app for them. Apps open for the people they are shared with, as always (see [Sharing](/docs/sharing)). To share an app with everyone at the domain, share it with `@company.com`.

"Remove" in the list of people takes a person out of all apps of the company at once, out of its groups and out of the people added to it. "Let in again" lifts that.

## Groups and roles

Groups of a company work like the groups of an account (see [House rules](/docs/house-rules#groups)): named lists of addresses, like `einkauf` for purchasing. The apps of the company use them in two ways: shared with `group:einkauf`, and in the rules of `scava.json`.

A member of a group can also have **roles** there, for example `lead`. Under the group on the Overview page, pick the member and enter their roles. The rules of an app ask for a role as `group:<group>:<role>`:

```json
{
  "company": "company.com",
  "data": {
    "orders": {
      "read": "group:einkauf",
      "write": "group:einkauf",
      "fields": { "status": { "write": "group:einkauf:lead" } }
    }
  }
}
```

Everyone in purchasing adds and changes orders, and only the purchasing leads set their status. Who is a lead is decided on the Overview page, without changing the app. A role counts at once on the next request. In the app, `scava.me()` returns the person's roles as `roles: ["einkauf:lead"]`. See [Permission rules](/docs/rules#roles).

Group and role names use small letters, digits, `-` and `_`. A member can have up to 5 roles in a group. Only the owner of the company changes groups and roles; its developers see them and use them, for example when they share an app.

## Developers

The owner invites other developers by their address. They get an email and join in the browser, on the Overview page or on their list of apps. To join, a developer needs a plan of the same level as the owner's plan or a higher one: if the owner has Team, a developer needs Team or Business. While a developer's plan is lower, they can do nothing in the company until it is high enough again.

Every developer of a company can change all its apps: publish new versions, put an earlier one back live, share them, answer requests for access and accept change requests. Each app stays the app of the developer who made it. It counts in their plan and their storage, and only they rename, pause or delete it, set its secrets and its own address, and download its data.

This is the only way to build an app together: people an app is shared with only use it and send change requests.

> Invite only developers you trust with all the data of the company's apps. The rules of an app apply to them like to everybody, but they can publish new rules and new server code, and with that reach all its data.

A change request is accepted by one person and goes to that person's agent: a developer who accepts one builds it with their own agent. If they can no longer build the app, it falls to the agent of the developer who made the app. See [Change requests](/docs/change-requests).

To work on an app of the company, a developer connects their agent with their own account (see [Connect your agent](/docs/agents)) and asks it, for example:

```text
Fetch the Scava app team-vacation-k3x9 with npx -y scava-ai pull, add half days, and publish it again with npx -y scava-ai setup.
```

`npx -y scava-ai pull` (the tool `pull_app`) writes the files of the live version into a folder and remembers the app, so publishing from that folder goes to the same app. People an app is shared with never get its files.

When a developer leaves the company or the owner removes them, nobody gets their apps: the apps they built in the company go back to their own account. Shares with groups of the company end, shares with addresses and domains stay.

| | Owner | Developer |
|---|---|---|
| Change all apps of the company | yes | yes |
| People, groups, roles, keeping people out | yes | no, they see them |
| Invite and remove developers | yes | no |
| Change the house rules | yes | no, they see them |
| Delete the company | yes | no |

The house rules of the company hold for its developers too: a developer from another domain needs to be inside the rules, or added to the company.

## Put an app into a company

Your agent creates the app in the company when its `scava.json` names the company's domain:

```json
{ "name": "Purchasing", "company": "company.com" }
```

The first publish puts the new app into that company. It needs someone who builds for the company. After that the app stays where it is: a later `scava.json` cannot move it. The owner of an app moves it on its page at scava.ai, into a company they build for or back to their own account. Shares with groups of the old place end when it moves; shares with addresses and domains stay.

Your agent sees the companies you build for with `npx -y scava-ai apps` or the tool `list_apps`, with the names of their groups and roles, never who is in them.

## Delete a company

Deleting a company takes its groups, roles, house rules, developers and added people with it. Its apps stay: each goes back to the account of whoever built it, without the shares with groups of the company. When the owner deletes their account, their companies go the same way.
