Overview
A Measurement represents a privacy-preserving computation request from a MeasurementConsumer to one or more DataProviders. Measurements can compute:- Reach - Unique users who saw an ad
- Frequency - Distribution of ad impressions per user
- Impression Count - Total number of ad impressions
- Watch Duration - Total time users spent watching video content
- Population - Population counts for demographic analysis
Measurement Lifecycle
Measurements progress through the following states:AWAITING_REQUISITION_FULFILLMENT
AWAITING_REQUISITION_FULFILLMENT
The measurement is waiting for all linked Requisitions to be fulfilled by DataProviders.
COMPUTING
COMPUTING
All requisitions have been fulfilled and the computation is running.
SUCCEEDED
SUCCEEDED
The measurement completed successfully. Results are available. This is a terminal state.
FAILED
FAILED
The measurement failed. Check the
failure field for details. This is a terminal state.CANCELLED
CANCELLED
The MeasurementConsumer cancelled the measurement. This is a terminal state.
Creating a Measurement
Follow these steps to create a measurement:Prepare your certificate
Ensure you have a valid certificate for signing the measurement specification.See the Certificates guide for more information.
Define your measurement specification
Create a
MeasurementSpec that defines what you want to measure:Sign the measurement specification
Sign the serialized
MeasurementSpec using your certificate’s private key:- Serialize the
MeasurementSpecto protobuf binary format - Sign the serialized bytes with your private key
- Create a
SignedMessagecontaining the signature and serialized spec
Prepare DataProvider entries
For each DataProvider participating in the measurement, create an entry with:
- DataProvider’s certificate
- DataProvider’s public key for encryption
- Encrypted requisition specification
Create the measurement
Call the
CreateMeasurement API with all prepared data:The
measurementReferenceId is optional but recommended. Use it to reference the measurement in your external systems.Monitoring Measurement Progress
After creating a measurement, monitor its progress:Polling for Updates
Listing Measurements with Filters
filter.states- Filter by measurement statefilter.updatedAfter- Measurements updated after a timestampfilter.updatedBefore- Measurements updated before a timestampfilter.createdAfter- Measurements created after a timestampfilter.createdBefore- Measurements created before a timestamp
Batch Operations
- Batch Get
- Batch Create
Retrieve multiple measurements in a single request:
Maximum of 50 measurements per batch request.
Retrieving Results
When a measurement reaches theSUCCEEDED state, results are available:
Decrypt the result
Decrypt the encrypted result using your measurement private key:
- Extract the
encryptedResult.ciphertext - Decrypt using your private key (corresponding to the
measurementPublicKeyin your spec) - Deserialize the decrypted bytes to a
Measurement.Resultprotobuf message
Verify the signature
Verify the result signature:
- Get the certificate specified in
results[].certificate - Verify the signature on the signed message
- Ensure the certificate chains to a trusted root
Cancelling Measurements
You can cancel a measurement before it completes:Handling Failures
When a measurement fails, check thefailure field for details:
CERTIFICATE_REVOKED
CERTIFICATE_REVOKED
A certificate used in the measurement was revoked. Update to a valid certificate and create a new measurement.
REQUISITION_REFUSED
REQUISITION_REFUSED
A DataProvider refused to fulfill their requisition. Check the message for the specific justification. See the Requisitions guide for details.
COMPUTATION_PARTICIPANT_FAILED
COMPUTATION_PARTICIPANT_FAILED
A Duchy participating in the computation failed. This may be transient - retry the measurement.
Best Practices
Use Request IDs
Include a unique
requestId in CreateMeasurement calls for idempotency. This prevents duplicate measurements if you retry a request.Reference IDs
Always set
measurementReferenceId to link measurements to your internal campaign tracking.Monitor Privacy Budget
Work with DataProviders to understand privacy budget constraints. Failed measurements due to insufficient budget still consume budget.
Batch When Possible
Use batch operations for multiple measurements to reduce API calls and improve efficiency.
Next Steps
Requisitions
Learn how DataProviders fulfill requisitions
Panel Matching
Understand panel matching protocols
API Reference
View the complete API reference
