Skip to main content
After the Quickstart, this guide covers the full recording API: entity types, action types, inline attributions, standalone attributions, session linking, and batch recording.

Entities

The entity() method

publicKey is optional but required if you want to verify signed attributions. Use @provenancekit/sdk/signing to produce keypairs and sign attributions.

Entity deduplication

The API deduplicates entities by a hash of (role, name, publicKey). Calling entity() twice with identical fields returns the same ID — safe to call on every request.

Recording actions with file()

file() is the primary method for recording an action that produces a content-addressed output.

Action types

Action types are freeform strings. Recommended conventions:

Attributions

Inline attributions (with file())

Pass attributions in the file() call for the common case of recording who contributed to an action:

Standalone attributions

Use pk.attribution() when you need to add an attribution after the fact, or when attributing to a CID rather than an action:

Sessions

A sessionId groups related actions into a timeline — useful for conversations, pipeline runs, or creative sessions.
The ProvenanceTracker UI component from @provenancekit/ui renders a session timeline.

Querying

Gotchas

  • CIDs must be deterministic. Two different callers hashing the same content must produce the same CID for the provenance graph to link correctly. Use IPFS CIDs (ipfs add --cid-version 1) or sha256:<hex> as a simple fallback for testing.
  • performedBy is the primary actor. Use inline attributions for additional contributors. The performedBy entity is automatically given an attribution with role: "primary" by the API.
  • Session IDs are not validated. The API accepts any string. Use UUIDs or another random ID generation strategy to ensure uniqueness across sessions.
  • Extensions are stored as-is. The API does not validate extension content beyond JSON serialization. Use the Zod schemas from @provenancekit/extensions in your application code before calling pk.file().