> For the complete documentation index, see [llms.txt](https://docs.xyb.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xyb.co/xyb-platform-1/xyb-ledger/integrate-with-xyb-ledger/ledger-setup-and-configuration/editor.md).

# Working with Your Ledger Environment: Instances, Cohorts, Roles, and Agents

Now that your CLI is connected and authenticated, this guide walks you through the first operational steps in your Ledger environment: defining roles, creating agents, and understanding how to scope access using instances and cohorts.

***

#### What Is an Instance?

An instance is how your CLI connects to your assigned Ledger environment (e.g., your test or production setup). You’ll typically be given the base URL for your Ledger instance during onboarding.

Example:

```bash
./luca add-instance gtm-dev https://cac-ledger-svc.gtm-prod.euw1.aws.xyb.io
./luca configure default-instance gtm-dev
```

***

#### What Is a Cohort?

A cohort is a workspace or namespace inside the ledger. Your cohort is assigned during onboarding and defines the scope of your agents, roles, and operations.

Cohort paths follow the format `/application/<name>`

***

#### 1. Define a Role

A role defines what an agent is allowed to do. Each role includes:

* A name (e.g. `ADMIN`)
* A set of permissions:
  * `read` – View data
  * `write` – Modify data
  * `transition` – Move items between lifecycle states
  * `access` – Connect to services
  * `impersonate` – Allow one agent to act on behalf of another

Create a full-access role:

```bash
./luca write-role ADMIN "access+read+write+transition@/*/**"
```

***

#### 2. Create an Agent

An agent is an identity that interacts with the ledger via API, CLI, or automation. Agents are created **within a cohort**.&#x20;

Set your auth identity (i.e., who the CLI is acting as). This must match a registered agent in your cohort and is used for all requests in your current session.

```bash
./luca set-auth application/admin
```

Then create an agent:

```bash
./luca write-agent application/admin --r:ADMIN
```

> 💡 **Agent Naming Tip:**\
> Use `application/<name>` for your app or `employee/<user-id>` for individuals.\
> Example: `application/finance-app`, `employee/charlie.wei`

***

#### 3. View and Test Your Setup

List all agents in your cohort:

```bash
./luca list-agents
```

Example output:

```
application admin ADMIN
```

This means there’s an agent `admin` in the application cohort with `ADMIN` permissions.

***

#### 4. Common Customizations

Create a limited-access role:

```bash
./luca write-role CHART_MANAGER "read+write@/chart/UK/**"
```

Register an agent with that role:

```bash
./luca set-auth application/chart_manager
./luca write-agent application/chart_manager --r:CHART_MANAGER
```

***

#### 🛠 Troubleshooting

| Problem           | Fix                                                               |
| ----------------- | ----------------------------------------------------------------- |
| No agents found   | Ensure you've set the instance: `luca configure default-instance` |
| Invalid cohort    | Use `/application/<name>` instead of `/service/`                  |
| Permission denied | Check your role permissions and assigned roles                    |

***

Now that you have agents and roles configured, you're ready to:

* Start sending operations (e.g. charts, transactions)
* Configure messaging channels (Kafka or HTTP)
* Interact with the Ledger API using secure tokens


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xyb.co/xyb-platform-1/xyb-ledger/integrate-with-xyb-ledger/ledger-setup-and-configuration/editor.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
