Skip to content

lt.personas

lt.personas manages personas: named bundles of roles, each linked at a relationship scope. Assigning a persona adds the user to each linked role at that scope. The memberships stay ordinary role memberships; the persona records why they exist. See Identity and the HTTP reference.

Relationships map onto member scope:

relationship read_scope write_scope
write-all all all
write-self all self
read-all all none

write-none is accepted as a synonym for read-all.

const result = await lt.personas.list();

List every persona with its role links and holder count.

Parameters: none.

Returns: LTApiResult<{ personas: LTPersonaRecord[] }>

const result = await lt.personas.get({ key: 'production-lead' });

Get one persona with its role links and assignees.

Parameters

Field Type Required Description
key string Yes Persona key

Returns: LTApiResult<LTPersonaRecord & { assignees }>. 404 when the key is unknown.

const result = await lt.personas.create({
key: 'production-lead',
title: 'Production Lead',
description: 'Works review and assembly, watches shipping.',
});

Create a persona. The key is trimmed, lowercased and validated against ^[a-z][a-z0-9_-]*$.

Parameters

Field Type Required Description
key string Yes Stable identifier
title string No Display title
description string No Description

Returns: LTApiResult<LTPersonaRecord> with status 201. 409 when the key exists.

const result = await lt.personas.update({ key: 'production-lead', title: 'Line Lead' });

Update a persona’s title and description. Omitted fields keep their values; null clears.

Parameters

Field Type Required Description
key string Yes Persona key
title string | null No Display title
description string | null No Description

Returns: LTApiResult<LTPersonaRecord>. 404 when the key is unknown.

const result = await lt.personas.delete({ key: 'production-lead' });

Delete a persona. Memberships it sustains are removed, or re-homed to another persona the user still holds. Direct grants stay as they are.

Parameters

Field Type Required Description
key string Yes Persona key

Returns: LTApiResult<{ deleted: true, recompute }>. 404 when the key is unknown.

const result = await lt.personas.linkRole({
key: 'production-lead',
role: 'review',
relationship: 'write-all',
});

Link a role to a persona, or change the link’s relationship. Every current holder’s memberships are reconciled in the same transaction.

Parameters

Field Type Required Description
key string Yes Persona key
role string Yes Role to link
relationship string Yes write-all, write-self or read-all (write-none is read as read-all)

Returns: LTApiResult<{ role, relationship, recompute }> with status 201. 404 when the persona is unknown.

const result = await lt.personas.unlinkRole({ key: 'production-lead', role: 'review' });

Unlink a role from a persona and reconcile every holder’s memberships.

Parameters

Field Type Required Description
key string Yes Persona key
role string Yes Role to unlink

Returns: LTApiResult<{ unlinked: true, recompute }>. 404 when the link is unknown.

const result = await lt.personas.assign({ id: 'user-uuid', key: 'production-lead' });

Assign a persona to a user: the user joins each linked role at the linked scope. Idempotent; re-assigning applies the persona’s current links. Direct grants are only ever raised.

Parameters

Field Type Required Description
id string Yes User ID
key string Yes Persona key

Returns: LTApiResult<{ assigned: true, recompute }>. 404 when the user or persona is unknown.

const result = await lt.personas.unassign({ id: 'user-uuid', key: 'production-lead' });

Unassign a persona from a user. Only the memberships the persona sustains are removed; memberships another held persona grants are re-homed to it, and direct grants stay as they are.

Parameters

Field Type Required Description
id string Yes User ID
key string Yes Persona key

Returns: LTApiResult<{ unassigned: true, recompute }>. 404 when the assignment is unknown.

const result = await lt.personas.forUser({ id: 'user-uuid' });

The personas a user holds, plus the role and scope map their memberships form. Each role row names the persona that sustains it, or null for a direct grant.

Parameters

Field Type Required Description
id string Yes User ID

Returns: LTApiResult<{ personas, roles }>

const result = await lt.personas.seed([
{
key: 'production-lead',
title: 'Production Lead',
roles: [
{ role: 'review', relationship: 'write-all' },
{ role: 'shipping', relationship: 'read-all' },
],
},
]);

Declarative, idempotent seeding. Takes the persona array directly. Each spec is authoritative for its persona: title and description are applied, role links are synced (links absent from the spec are removed), linked roles are created when missing, and every holder is reconciled, so re-running the seed re-applies edits. See Code-owned config.

Parameters

Field Type Required Description
personas LTPersonaSpec[] Yes [{ key, title?, description?, roles: [{ role, relationship }] }], passed as the only argument

Returns: LTApiResult<{ personas, links, recompute }>