Manage Users & Groups
This use case covers user and group management via the LHC Core API. It is intended for IT teams automating user provisioning or managing access control programmatically.
Role requirement
All endpoints in this guide require Admin role.
Users
List Users
curl -s "$LHC_CORE/api/v1/lhc/users" \
-H "Authorization: Bearer $LHC_TOKEN"
users = requests.get(f"{CORE}/api/v1/lhc/users", headers=HEADERS).json()
for u in users:
print(u["id"], u["name"], u["email"], u["role"])
Get a Specific User
user_info = requests.get(
f"{CORE}/api/v1/lhc/users/user/info",
headers=HEADERS,
params={"user_id": "<user-id>"},
).json()
Update a User's Role
Valid roles: user, builder, admin.
curl -X POST "$LHC_CORE/api/v1/lhc/users/update/role" \
-H "Authorization: Bearer $LHC_TOKEN" \
-H "Content-Type: application/json" \
-d '{"user_id": "<user-id>", "role": "builder"}'
requests.post(
f"{CORE}/api/v1/lhc/users/update/role",
headers=HEADERS,
json={"user_id": "<user-id>", "role": "builder"},
)
Search Users
results = requests.get(
f"{CORE}/api/v1/lhc/users/search",
headers=HEADERS,
params={"query": "anna"},
).json()
Groups
Groups control shared access to models, datasources, charts, and dashboards. Members of a group inherit its access permissions.
List Groups
curl -s "$LHC_CORE/api/v1/lhc/groups" \
-H "Authorization: Bearer $LHC_TOKEN"
groups = requests.get(f"{CORE}/api/v1/lhc/groups", headers=HEADERS).json()
for g in groups:
print(g["id"], g["name"])
Create a Group
curl -X POST "$LHC_CORE/api/v1/lhc/groups" \
-H "Authorization: Bearer $LHC_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Analytics Team", "description": "Access to all analytics models"}'
group = requests.post(
f"{CORE}/api/v1/lhc/groups",
headers=HEADERS,
json={"name": "Analytics Team", "description": "Access to all analytics models"},
).json()
group_id = group["id"]
Add a User to a Group
curl -X POST "$LHC_CORE/api/v1/lhc/usergroups" \
-H "Authorization: Bearer $LHC_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"user_id\": \"<user-id>\", \"group_id\": \"$GROUP_ID\"}"
requests.post(
f"{CORE}/api/v1/lhc/usergroups",
headers=HEADERS,
json={"user_id": "<user-id>", "group_id": group_id},
)
Remove a User from a Group
requests.delete(
f"{CORE}/api/v1/lhc/usergroups",
headers=HEADERS,
json={"user_id": "<user-id>", "group_id": group_id},
)
Update a Group
requests.post(
f"{CORE}/api/v1/lhc/groups/id/{group_id}/update",
headers=HEADERS,
json={"name": "BI Team", "description": "Updated description"},
)
Delete a Group
requests.delete(
f"{CORE}/api/v1/lhc/groups/id/{group_id}/delete",
headers=HEADERS,
)
Granting Group Access to Resources
Once a group exists, models, datasources, charts, and dashboards can be shared with it through the respective service APIs. This is covered in the Sharing guide.