Skip to content

Commit c4ecc6a

Browse files
authored
Merge branch 'main' into fern-bot/2026-02-27T20-35Z
2 parents 058ada2 + f8de36e commit c4ecc6a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,40 @@ client
340340
client.close();
341341
```
342342

343+
### Checking flags with entitlement details
344+
345+
If you need more detail about how a flag check was resolved, including any entitlement associated with the check, use `checkFlagWithEntitlement`. This returns a response object with the flag value, the reason for the evaluation result, and entitlement details such as usage, allocation, and credit balances when applicable.
346+
347+
```ts
348+
import { SchematicClient } from "@schematichq/schematic-typescript-node";
349+
350+
const apiKey = process.env.SCHEMATIC_API_KEY;
351+
const client = new SchematicClient({ apiKey });
352+
353+
const evaluationCtx = {
354+
company: { id: "your-company-id" },
355+
user: {
356+
email: "wcoyote@acme.net",
357+
userId: "your-user-id",
358+
},
359+
};
360+
361+
client
362+
.checkFlagWithEntitlement(evaluationCtx, "some-flag-key")
363+
.then((resp) => {
364+
console.log(`Flag: ${resp.flagKey}, Value: ${resp.value}, Reason: ${resp.reason}`);
365+
366+
if (resp.entitlement) {
367+
console.log(`Entitlement type: ${resp.entitlement.valueType}`);
368+
console.log(`Usage: ${resp.entitlement.usage}, Allocation: ${resp.entitlement.allocation}`);
369+
console.log(`Credit remaining: ${resp.entitlement.creditRemaining}`);
370+
}
371+
})
372+
.catch(console.error);
373+
374+
client.close();
375+
```
376+
343377
### Checking multiple flags
344378

345379
The `checkFlags` method allows you to efficiently check multiple feature flags in a single operation. When you provide specific flag keys, it will only return the flag values for those flags, leveraging intelligent caching to minimize API calls.

0 commit comments

Comments
 (0)