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:| Type | When to use |
|---|---|
file.create | Any AI-generated or human-created content |
file.edit | A modification to an existing CID |
model.infer | A model inference call (without a persistent output CID) |
remix | Derivative work from one or more source CIDs |
review | A human review or approval action |
publish | Content was published or made public |
Attributions
Inline attributions (with file())
Pass attributions in the file() call for the common case of recording who contributed to an action:
Standalone attributions
Usepk.attribution() when you need to add an attribution after the fact, or when attributing to a CID rather than an action:
Sessions
AsessionId groups related actions into a timeline — useful for conversations, pipeline runs, or creative sessions.
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) orsha256:<hex>as a simple fallback for testing. performedByis the primary actor. Use inlineattributionsfor additional contributors. TheperformedByentity is automatically given an attribution withrole: "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/extensionsin your application code before callingpk.file().