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

# Organize endpoints with groups and attributes

> Tag endpoints with a group and custom key-value attributes so you can find and filter them on the dashboard

In this tutorial, we'll name an endpoint `worker-7`, assign it to the `staging` group, and add region and app-version attributes. Then we'll update its metadata and find it on the Iroh Services dashboard.

Each endpoint can belong to one group and have a set of custom key-value attributes. Multiple endpoints can share a group.

> [!NOTE]
>
> This tutorial uses the `iroh-services` Rust crate. The Python, Swift, and Kotlin bindings in `iroh-ffi` do not expose groups or attributes yet.

## Prerequisites

Start with an endpoint connected to Iroh Services, as described in the [quickstart](https://docs.iroh.computer/iroh-services/quickstart.md). Keep that application's `endpoint` and replace its client construction with the code below.

Set `IROH_SERVICES_API_SECRET` to your [API key](https://docs.iroh.computer/iroh-services/access.md) in the environment where you run the application. Run the Rust snippets inside your application's async function.

## Set metadata at build time

First, set the name, group, and attributes on the client builder:

```rust theme={null}
use iroh_services::Client;

let client = Client::builder(&endpoint)
	.api_secret_from_env()?
	.name("worker-7")?
	.group("staging")?
	.attributes([("region", "us-west"), ("app-version", "1.4.2")])?
	.build()
	.await?;
```

Keep the application running and open your project's **Endpoints** page. Find `worker-7`, then open its detail page. After the client authenticates and sends its metadata, the page shows group `staging` and attributes `region: us-west` and `app-version: 1.4.2`.

The builder validates metadata locally. Names, groups, and attribute keys must contain 2 to 128 bytes of UTF-8. Attribute values may be empty, with a maximum of 128 bytes. An endpoint can have up to 128 attributes.

> [!NOTE]
>
> If the client cannot send metadata after authentication, it logs a warning. A successful `build()` does not confirm that the server received the metadata. Use the setters below when you need to handle update errors explicitly.

## Update metadata later

Next, move the endpoint to `production` and update its app version. Add these calls after client construction:

```rust theme={null}
client.set_group("production").await?;

// Replace the whole attribute map.
client
	.set_attributes([("region", "us-west"), ("app-version", "1.4.3")])
	.await?;

// Add or update one key while preserving the other attributes.
client.set_attribute("app-version", "1.4.4").await?;
```

Run the updated application. The endpoint now has group `production`, region `us-west`, and app version `1.4.4`.

`set_attributes` replaces the entire map. `set_attribute` merges one key into the client's cached attributes and sends the resulting map. Both methods return errors if validation or the update fails.

To clear all attributes, pass an empty iterator to `set_attributes`:

```rust theme={null}
client
	.set_attributes(std::iter::empty::<(String, String)>())
	.await?;
```

Leave this clearing step out if you want to find the endpoint by its attributes in the dashboard steps below.

## Read the name and group

Read the name and group from the local client:

```rust theme={null}
assert_eq!(client.name().await?.as_deref(), Some("worker-7"));
assert_eq!(client.group().await?.as_deref(), Some("production"));
```

Both methods are async and return `Result<Option<String>, Error>`. They read cached values from the builder or successful setter calls. They do not fetch server state or confirm that startup metadata reached the server.

There is no `attributes()` getter. Keep a copy in your application if you need to read the attribute map.

## See it on the dashboard

Find the updated endpoint on your project's **Endpoints** page:

1. Search for `worker-7`. The search box also matches endpoint IDs, groups, and attributes.
2. Select `production` in the **group** filter in the sidebar. The endpoint remains in the results.
3. Open **Columns** above the table and enable **Group** and **Attributes**. Both columns are hidden by default.
4. Open the endpoint's detail page to inspect its full group and attribute values.

The table shows up to two attributes per row. If an endpoint has more, hover over its attribute pills to see the full set.

## Full example

The [endpoint metadata example](https://github.com/n0-computer/iroh-services/blob/main/iroh-services/examples/endpoint_meta.rs) demonstrates builder configuration and runtime updates. To run it, clone the repository and run the example from its workspace root:

```bash theme={null}
git clone https://github.com/n0-computer/iroh-services.git
cd iroh-services
IROH_SERVICES_API_SECRET=YOUR_API_KEY cargo run --example endpoint_meta
```

## What's next

> [card] [Iroh Services quickstart](https://docs.iroh.computer/iroh-services/quickstart.md)
>
> Connect your first endpoint and see it on the dashboard.

> [card] [API keys](https://docs.iroh.computer/iroh-services/access.md)
>
> Understand what an API key authorizes and how to get one.

> [card] [Diagnose a connectivity issue](https://docs.iroh.computer/iroh-services/net-diagnostics/quickstart.md)
>
> Run remote diagnostic reports on your users' endpoints to find out why connections fail.


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