Cloudflare Docs
Workers
Edit this page on GitHub
Set theme to dark (⇧+D)

Version metadata binding

Beta

The version metadata binding can be used to access metadata associated with a version from inside the Workers runtime.

Worker version ID and version tag are available through the version metadata binding. They can be used in events sent to Workers Analytics Engine or to any third-party analytics/metrics service in order to aggregate by Worker version.

To use the version metadata binding, update your Worker’s wrangler.toml file:

wrangler.toml
[version_metadata]
binding = "CF_VERSION_METADATA"

​​ Interface

An example of how to access the version ID and version tag from within a Worker to send events to Workers Analytics Engine:

export default {
async fetch(request, env, ctx) {
const { id: versionId, tag: versionTag } = env.CF_VERSION_METADATA;
env.WAE.writeDataPoint({
indexes: [versionId],
blobs: [versionTag],
//...
});
//...
},
};
interface Environment {
CF_VERSION_METADATA: WorkerVersionMetadata;
WAE: AnalyticsEngineDataset;
}
export default {
async fetch(request: Request, env: Environment, ctx: ExecutionContext) {
const { id: versionId, tag: versionTag } = env.CF_VERSION_METADATA;
env.WAE.writeDataPoint({
indexes: [versionId],
blobs: [versionTag],
//...
});
//...
},
};