Skip to content

Scope is enforced in SQL

The queue as a marketHTTPSDKCLIDashboardMCPread_scopewrite_scopelistlistAvailable

A member's read and write scope are ANDed into the query itself, so totals, pages and claims all respect it and nothing is filtered after the fact.

The situation

Some members work the whole queue. Others, such as a contractor, should see only the rows assigned to them. A list that fetches a page and then hides rows gets its counts and paging wrong.

The recipe

services/my-queue.ts
const lt = createClient({ auth: { userId } });
const res = await lt.escalations.list({
status: 'pending',
facets: { orderId: 'ORD-9' },
orderBy: [{ field: 'created_at', direction: 'asc' }],
limit: 50,
offset: 0,
});
// res.data: { escalations, total }
Caller Sees
superadmin, or admin of admin every role’s queue
read_scope: all on a role the whole queue for that role
read_scope: self on a role only rows assigned to them

write_scope (none, self, all) sets which of those rows the member may claim, resolve or cancel.

The guarantee

The read-scope predicate is ANDed with the facets in one WHERE, and the page total is computed by the same WHERE. A caller may narrow with role or roles but never widen: a role they do not hold matches nothing. See Identity.