call-cognite-function
Installation
SKILL.md
Call Cognite Function
Invoke any deployed Cognite CDF Function, poll until it completes, and return a typed, schema-validated result.
Overview
The CDF Functions API uses a three-step protocol:
- Session nonce — exchange the current user token for a short-lived nonce so the function can make authenticated API calls on the user's behalf.
- Invoke — POST to the function's
/callendpoint with your input data and the nonce. - Poll → fetch — GET the call status in a loop; once
"Completed", GET the/responseendpoint.
Every API response is validated with Zod, so schema drift surfaces as a clear ZodError at the call site instead of an undefined three layers down. The function's own output payload can also be validated against a caller-supplied schema — which doubles as the source of the return type.
Files
| File | Purpose |
|---|---|
code/cogniteFunctionService.ts |
Framework-agnostic async function with Zod validation. Zero React deps. Copy into src/services/. |
code/useCogniteFunction.ts |
React Query (useMutation) hook wrapping the service. Copy into src/hooks/. |