> ## Documentation Index
> Fetch the complete documentation index at: https://www.sapientpriors.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 0. Set up your organization

> From sign-up to a working production key - create a project, add your team, create a service account, and check its key.

This walkthrough takes an organization from sign-up to a service-account key your servers can call Priors with. Do it once per product. Steps 1 to 5 happen in the Priors app; steps 6 and 7 are API calls.

| Step | Where | Who | Result |
| - | - | - | - |
| 1 | Sign up | You | An organization, with you as Org admin |
| 2 | **Projects** page | Org admin | A project for your product |
| 3 | Project **Members** page | Org admin or Project admin | Your team, each with a role |
| 4 | Project **API keys** page | Org admin or Project admin | A service account with a role, and its key (`spk_...`) |
| 5 | Project **API keys** page | Each engineer | A personal key for testing |
| 6 | [GET`/v2/me`](https://www.sapientpriors.com/docs/api-reference/v2/users/get-me) | Your server | Proof the key works |
| 7 | [POST`/v2/agents`](https://www.sapientpriors.com/docs/api-reference/v2/agents/create-agent) | Your server | Your first agent in the project |

## Step 1: sign up

Sign up at [app.sapientpriors.com](https://app.sapientpriors.com). Priors approves new organizations, and then you can sign in. The first person in an organization is its **Org admin**.

## Step 2: create a project

Create one project per product, for example `Meeting notes` and `Knowledge base`. Open **Projects** and choose **New project**. Give it a name, and pick at least one Project admin. You are picked by default.

Every organization also has a **Default project**. You can leave it empty.

## Step 3: add your team

Open the project's **Members** page and choose **Add people**. Enter each person's email and pick a role:

* **Project admin** for the engineers who build the product. They can create agents, service accounts, and keys in this project.
* **Agent admin** for people who teach a few chosen agents. Pick the agents in the same dialog.
* **Contributor** for everyone else. They can chat with every public agent in the project.

An email outside your organization gets an invitation. The person joins the organization and the project when they accept it. See [Roles and permissions](https://www.sapientpriors.com/docs/access/roles.md).

## Step 4: create a service account and its key

A service account runs your product in production. Its keys keep working when people leave. On the project's **API keys** page, choose **Create key**:

1. Name the key, for example `notes-prod`, and pick how long it lasts. 365 days is the default.
2. Tick **Mark as service account key**, and pick its role:
   * **Project admin** if your code creates and deletes agents, uploads and deletes files, and deletes memories. Most products need this.
   * **Agent admin** or **Contributor** if your code only uses agents that someone creates by hand.
3. Choose **Generate key**, and copy the key.

* **The secret is shown once.** Put it straight into your secret manager.
* Note the expiry date and plan the rotation. An expired key returns `401` with no advance warning.
* Create one service-account key for each environment, for example one for production and one for staging.

See [Service accounts](https://www.sapientpriors.com/docs/access/service-accounts.md).

## Step 5: give engineers their own keys

Engineers who test from their own machine create a **personal key** on the same page: **Create key**, leave **Mark as service account key** unticked, and confirm **For building and testing, not production**. A personal key cannot act for your customers. See [Authentication](https://www.sapientpriors.com/docs/authentication.md).

## Step 6: check the key

```bash theme={null}
curl https://app.sapientpriors.com/api/v2/me \
  -H "Authorization: Bearer $SP_API_KEY"
```

**Success:** status `200`. `api_key.acts_as.type` is `service_account`, and `api_key.project_id` is the project you created.

```json theme={null}
{
  "user": {
    "user_id": "sa_01J...",
    "email": "",
    "display_name": "service account"
  },
  "organization": {
    "organization_id": "org_01J...",
    "name": "Acme"
  },
  "api_key": {
    "key_id": "7Kq2mN4pXr8wLz1c",
    "project_id": "proj_01J...",
    "acts_as": { "type": "service_account", "id": "sa_01J..." }
  }
}
```

**If it fails:** `401 unauthorized` means the key is wrong, revoked, or expired. `400 invalid_request` means the request carried `Sec-Fetch-Site`: call Priors from your server, never from a browser.

## Step 7: create your first agent

```bash theme={null}
curl -X POST https://app.sapientpriors.com/api/v2/agents \
  -H "Authorization: Bearer $SP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_config": {
      "role": "Meeting notetaker for Ada",
      "objective": "Remember what was discussed, decided, and assigned in Ada'\''s meetings, who said it, and when."
    }
  }'
```

**Success:** status `202`, with `status: "initializing"`. The agent lives in the key's project and is public, so it shows on the project's **Agents** page. Poll [GET`/v2/agents/{agent_id}`](https://www.sapientpriors.com/docs/api-reference/v2/agents/get-agent) every second until `status` is `ready`.

**If it fails:** `403 forbidden` means the service account's role cannot create agents: give it the Project admin role. `409 agent_quota_exceeded` means the organization holds its maximum of live agents.

## Next

* [Your first agent, from start to finish](https://www.sapientpriors.com/docs/walkthroughs/first-conversation.md): open a thread, teach the agent, and ask it a question.
* [Call Priors from your own backend](https://www.sapientpriors.com/docs/walkthroughs/call-from-your-backend.md): one agent per customer, with `X-SP-End-User`.
* [A meeting notetaker](https://www.sapientpriors.com/docs/how-to-use/meeting-notetaker.md) and [A team knowledge base](https://www.sapientpriors.com/docs/how-to-use/team-knowledge-base.md): two complete product designs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.