DocsOpen Moon AI
Browse the docs

Labels

Create key and value labels, put them on members, groups or resources, and mark a resource as sensitive, all through the admin API.

On this page

A label is a key = value pair, for example site = Lyon or classe = 3A. A member label describes a person: it adds them to dynamic groups and can give them roles. A sensitivity label goes on a resource (knowledge base, agent, MCP server, file) to restrict access to it.

All routes are under https://chat.realmoon.ai/api/v1/orgs/{org_id}. Scopes: labels:read to read, labels:write to write.

The label objectLink to the The label object section

JSON
{
  "id": "9b8a7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "org_id": "8c1f2a4e-5b6d-4e7f-9a0b-1c2d3e4f5a6b",
  "key": "classe",
  "value": "3A",
  "color": "blue",
  "kind": "member",
  "source": "manual",
  "created_at": 1793836800
}
FieldDescription
keyLowercased, repeated spaces collapsed; letters, digits, spaces, _, . and -, up to 64 characters.
valueRepeated spaces collapsed, case kept, up to 128 characters, no |.
colorgray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink or rose.
kindmember or sensitivity.
sourcemanual, or directory for a label that came from the directory.

Two labels cannot have the same key and the same value (case-insensitive). In lists, each label also carries member_count and assignment_count.

List labelsLink to the List labels section

GET /labels · labels:read

ParameterTypeDescription
qstringSearches the key or the value.
kindstringmember or sensitivity.
keystringOnly this key.
page, limitintegerPagination. Sorted by key, then value.

The response also includes colors, the list of allowed colors.

Create a labelLink to the Create a label section

POST /labels · labels:write

FieldTypeRequiredDescription
keystringyes1 to 64 characters.
valuestringyes1 to 128 characters.
colorstringnogray by default.
kindstringnomember (default) or sensitivity.

An organization can have up to 5,000 labels. A label that already exists returns 409 invalid_request with the message Cette étiquette existe déjà. (this label already exists).

Update a labelLink to the Update a label section

PATCH /labels/{label_id} · labels:write

Optional fields key, value, color and kind. Labeled members and resources follow the new key or value. A label named in a dynamic group’s rule cannot change its key or value: 409 label_in_use, with groups, the names of the groups involved. Change their rule first.

Delete a labelLink to the Delete a label section

DELETE /labels/{label_id} · labels:write

Removes the label from every member, group and resource, and removes the roles it gave. Response: {"success": true}. Refused (409 label_in_use) as long as a dynamic group names it.

Assign a labelLink to the Assign a label section

POST /labels/{label_id}/assignments · labels:write

FieldTypeRequiredDescription
subject_typestringyesuser (members), group or resource.
subject_idslistyes1 to 1,000 IDs.
resource_typestringfor resourceknowledge, agent, mcp_server or library (a file in the workspace library).
cURL
curl https://chat.realmoon.ai/api/v1/orgs/$ORG_ID/labels/$LABEL_ID/assignments \
  -H "Authorization: Bearer $MOONAI_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject_type": "user", "subject_ids": ["<member id>", "<member id>"]}'
Python
import os
import requests

BASE = f"https://chat.realmoon.ai/api/v1/orgs/{os.environ['ORG_ID']}"
HEADERS = {"Authorization": f"Bearer {os.environ['MOONAI_ADMIN_KEY']}"}

r = requests.post(
    f"{BASE}/labels/{os.environ['LABEL_ID']}/assignments",
    headers=HEADERS,
    json={"subject_type": "user", "subject_ids": ["<member id>", "<member id>"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["added"])
JavaScript
const BASE = `https://chat.realmoon.ai/api/v1/orgs/${process.env.ORG_ID}`;
const r = await fetch(`${BASE}/labels/${process.env.LABEL_ID}/assignments`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.MOONAI_ADMIN_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ subject_type: 'user', subject_ids: ['<member id>', '<member id>'] }),
});
if (!r.ok) throw new Error(await r.text());
console.log((await r.json()).added);

Response: {"success": true, "added": 2}. Subjects that already have the label are skipped. Putting a label on members can add them to dynamic groups and give them roles, right away.

StatuscodeCause
400invalid_requestSensitivity label on members; resource_type missing for a resource, or present for a member or a group.
403forbiddenLabeling the key’s creator without the permission to set groups; a label that puts members into groups subject to rules or that assigns a license, when the key only acts on managed groups.
403role_escalationThe label would give roles the key does not have.
403license_change_forbiddenThe change would move members to another license pool; it requires licenses:write.
404not_foundMembers, group or resource not found.

Putting a label on a group or a resource requires the permission to manage labels; on members, the permission to assign them.

Remove a labelLink to the Remove a label section

DELETE /labels/{label_id}/assignments · labels:write

Same body as assigning (resource_type is ignored). Response: {"success": true, "removed": 2}. Subjects without the label are skipped. Members can leave dynamic groups and lose roles.

See alsoLink to the See also section

Moon AI

Moon AI in action

0:00

Explore

Screenshots of chat.realmoon.ai taken on October 29, 2026, with fictional data.

Moon AI

Your preferences

Visits counted without cookies.

Our server counts visits without cookies or trackers. Your theme and your answer about ad measurement are remembered on this device.

Ad measurement

With your consent, our ad networks’ trackers (Google) measure our ads, from the visit to the sign-up and then to the first subscription and its amount, and may show you our ads. Your answer is valid for 13 months; you can change it here at any time.

No answer saved on this device.

After you decline, no tag is loaded anymore and the site deletes the cookies they had set on realmoon.ai. Those on the ad networks’ own domains are managed with them or in your browser.

The Moon AI app has its own privacy settings.