> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/project/settings/admin-portal.md).

# Admin Portal

Set up the Admin Portal of a project — its service user, API keys, the portal switch and the AI chat switch.

**Where:** Project → Settings → **Admin Portal** · `/projects/<project>/settings?tab=Admin%20Portal`

The [Admin Portal](/codemash/admin/admin.md) is the ready-made sign-in and self-service site for your end users. Its backend signs in as a **service user** of the project. This tab sets that user, issues API keys for a portal you host yourself, and turns the managed portal and its AI chat on or off.

## Before you start

* An account role that may update the project settings.
* **Users** (Membership) is on, and a service user with the role **Admin Portal Manager** exists: in [Membership → Users](/codemash/cloud/membership/users.md) create a "User as a service" with that role and copy its id (`usr_…`) or its contact id (`ct_…`).
* For the AI chat: an assistant on the [AI](/codemash/cloud/project/settings/ai.md) tab.

## Steps

1. Open **Settings → Admin Portal**. With no service user the badge says **Not set** and **Portal enabled** cannot be turned on.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-928a7d2f49dfa9cf986e68f9089f83cc73cdb174%2Fadmin-portal-1.png?alt=media" alt="Admin Portal tab: service user Not set, Portal enabled off, End-user AI chat Hidden, the link to the Access tab"><figcaption><p>A new project.</p></figcaption></figure>
2. Paste the id into **Service user id** and press **Assign service user**.

   | Field               | Required | What it does                                                             | Example                      |
   | ------------------- | -------- | ------------------------------------------------------------------------ | ---------------------------- |
   | Service user id     | yes      | The login id or contact id of a user with the Admin Portal Manager role. | `usr_3EU54GxVM7ddnEUDKmfmUc` |
   | Key name (optional) | no       | A name for an API key, for a portal you host yourself.                   | `Acme portal backend`        |

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-61eb9fe3c9f95609edf684f3b56356d4f331fe1b%2Fadmin-portal-2.png?alt=media" alt="Service user id filled with a usr_ id and the Assign service user button"><figcaption><p>Assigning the service user.</p></figcaption></figure>
3. (Self-hosted portal only) Under **API keys** type a **Key name** and press **Issue key**. Copy the key at once — *Copy this API key now. It will not be shown again.* — and put it into your portal's `API_KEY` setting. A service user can have two keys.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-65cae6b49bf8e73164104113ac63aa858749adc1%2Fadmin-portal-3.png?alt=media" alt="Assigned service user, the new key box (blanked) and the key Acme portal backend in the list"><figcaption><p>A key is issued (blanked here).</p></figcaption></figure>
4. Under **Admin Portal**, switch **Portal enabled** on.
5. (Optional) Under **End-user AI chat**, switch **Show AI chat** on. It needs at least one assistant with an LLM; the tab then says how many assistants are configured.

## Result

The service user badge says **Assigned**, the **Admin Portal** badge says **On**, and your users can sign in at the Admin portal URL shown on [Access](/codemash/cloud/project/settings/access.md). What the portal shows before sign-in is set on the Access tab (**Open the Access tab**).

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-4c75fbd26716acde07ec7c75cfa8eb60f018575f%2Fadmin-portal-4.png?alt=media" alt="Admin Portal On with Portal enabled switched on, Show AI chat off with 1 assistant configured"><figcaption><p>The portal is on.</p></figcaption></figure>

## Change or remove it later

* **Another service user** — paste its id into **Replace with another service user** and press **Reassign**.
* **Delete a key** — **Delete** on its row, then **Confirm**. A portal that still uses it stops working.
* **Portal off** — switch **Portal enabled** off; the managed portal shows "portal unavailable". A portal you host yourself keeps working while its key is valid.

## Do it from code

```ts
await norbix.hub.account.setAdminPortalEnabled({ projectId: 'pr_7FUKofhEBNMnISkqust2De', enabled: true });
```

```sh
norbix project admin-portal enable --project pr_7FUKofhEBNMnISkqust2De
```

The client setup is on the [Account page](/codemash/cloud/account.md#use-it-from-code). API: [Set Admin Portal Enabled](/codemash/api-reference/account/projects/set-admin-portal-enabled.md) · [Assign Admin Portal Service User](/codemash/api-reference/account/projects/assign-admin-portal-service-user.md) · [Get Admin Portal Structure](/codemash/api-reference/account/projects/get-admin-portal-structure.md)
