Skip to main content
A slice is a saved, reusable scope. You define a scope once, confirm what it matches, save it under a name, and reuse or compile it later.

Author a slice

Saving a slice returns the same matched + scope_warnings you get from a preview, so you confirm it resolves before you rely on it.
const slice = await pb.slices.create("Alpha cos since Jan", {
  filter: {
    types: ["Company"],
    properties: [{ path: "stage", operator: "eq", value: "alpha" }],
    after: "2026-01-01",
  },
});
// { id, name, matched: 18, scope_warnings: [], filter_definition: {...} }

List, read, promote

await pb.slices.list();            // slices in scope
await pb.slices.get(slice.id);     // includes a live, recomputed member count
await pb.slices.promote(slice.id); // make it a durable lens others reuse
await pb.slices.demote(slice.id);

Method reference

MethodRESTDescription
pb.slices.create(name, scope)POST /v1/slicesSave a scope; returns matched + warnings.
pb.slices.list(options?)GET /v1/slicesList slices in scope.
pb.slices.get(id)GET /v1/slices/{id}Read a slice (live member count).
pb.slices.update(id, input)PATCH /v1/slices/{id}Update a slice.
pb.slices.promote(id) / demote(id)POST /v1/slices/{id}/promotePromote to / demote from a durable lens.

Compile a slice

Pass a slice into pb.context.compile to turn it into context.
const compiled = await pb.context.compile({ slice_id: slice.id });

Context

The scope grammar, preview, and compile.

CQL

Write scopes as a terse string.