Intents tell the C2PA Builder what kind of manifest you are creating. They enable validation, add required default actions, and help prevent invalid operations.
You can use an intent for any asset type. Intents are about the operation (create/edit/update), not the asset type.
There are three types of intents:
- Create:
BuilderIntent::Create(DigitalSourceType) - Edit:
BuilderIntent::Edit - Update:
BuilderIntent::Update
Use BuilderIntent::Create(DigitalSourceType) for new digital creations without a parent ingredient. This intent:
- Requires a
DigitalSourceType(see below). - Must not have a parent ingredient.
- Automatically adds a
c2pa.createdaction if not provided.
For example:
let mut builder = Builder::from_shared_context(&context)
.with_definition(r#"{"title": "New Image"}"#)?;
builder.set_intent(BuilderIntent::Create(DigitalSourceType::Empty));Digital source types
The value of digitalSourceType is one of the enum values listed in the API documentation including the codes specified by the International Press Telecommunications Council (IPTC) NewsCodes Digital Source Type scheme. For example:
Empty- Blank canvas or zero-length contentDigitalCapture- Captured from real-life using digital deviceTrainedAlgorithmicMedia- AI-generated mediaTrainedAlgorithmicData- AI-generated data (non-media formats)CompositeCapture- HDR and multi-frame processing
Use BuilderIntent::Edit for editing an existing asset (most common case). This intent:
- Requires a parent ingredient.
- Automatically derives the parent ingredient from the source stream if not provided.
- Automatically adds a
c2pa.openedaction linked to the parent.
For example:
builder.set_intent(BuilderIntent::Edit);
builder.add_ingredient_from_stream(
json!({"title": "Original", "relationship": "parentOf", "label": "parent"}),
"image/jpeg",
&mut source_stream,
)?;Use BuilderIntent::Update for non-editorial (metadata-only) changes. It is a restricted version of the edit intent. This intent:
- Allows exactly one ingredient (the parent).
- Does not allow changes to the parent’s hashed content.
- Is more compact than an edit intent.
- Is suitable for metadata-only updates.
Example:
builder.set_intent(BuilderIntent::Update);Run the builder example:
cd sdk
cargo run --example builder_sample