Convex.Deployment reference
CanonicalUrl
Section titled “CanonicalUrl”Source:
packages/convex/src/CanonicalUrl.ts
The canonical URL of a Convex deployment, usually a custom domain. Removing this resource restores the default.
CanonicalUrl: Setting a Canonical URL
Section titled “CanonicalUrl: Setting a Canonical URL”yield* Convex.CanonicalUrl("Site", { deployment, requestDestination: "convexSite", url: "https://site.example.com",});CustomDomain
Section titled “CustomDomain”Source:
packages/convex/src/CustomDomain.ts
A custom domain on a Convex deployment.
CustomDomain: Adding a Domain
Section titled “CustomDomain: Adding a Domain”yield* Convex.CustomDomain("Api", { deployment, domain: "api.example.com", requestDestination: "convexCloud",});DataSync
Section titled “DataSync”Source:
packages/convex/src/DataSync.ts
Export a Convex deployment’s data from a Worker, Lambda or other host, a page at a time.
The host gets a deploy key that can only do deployment:data:view on this
deployment, which reads every table.
The Deployment API accepts only Convex’s own keys, so there is no host
identity to federate.
DataSync: Exporting Data
Section titled “DataSync: Exporting Data”Effect.gen(function* () { const data = yield* Convex.DataSync(Backend); return { fetch: Effect.gen(function* () { const page = yield* data.sync({}); return yield* HttpServerResponse.json(page); }), };}).pipe(Effect.provide(Convex.DataSyncHttp));Deployment
Section titled “Deployment”Source:
packages/convex/src/Deployment.ts
A Convex deployment: one database and set of functions in a project.
Deployment: Safety
Section titled “Deployment: Safety”Prod deployments have deletionProtection on, so alchemy destroy fails
rather than deleting their data.
Changing project transfers the deployment, so it keeps its data, name and
URL. Changing region replaces it.
Previews expire on Convex’s side. The next deploy notices and creates a new one, which has a new name and URL and no data.
Deployment: Creating a deployment
Section titled “Deployment: Creating a deployment”Default production deployment
const prod = yield* Convex.Deployment("Prod", { project, type: "prod" });One preview per stage, removed by alchemy destroy
const preview = yield* Convex.Deployment("Preview", { project, type: "preview" });A dev deployment with its own reference
const dev = yield* Convex.Deployment("Dev", { project, type: "dev", reference: "dev/sam",});Deployment: Choosing a Region and Class
Section titled “Deployment: Choosing a Region and Class”Changing region replaces the deployment and starts it with no data.
const eu = yield* Convex.Deployment("Eu", { project, type: "prod", region: "aws-eu-west-1",});Deployment: Moving Between Projects
Section titled “Deployment: Moving Between Projects”const deployment = yield* Convex.Deployment("Backend", { project: newProject, type: "dev",});Deployment: Pausing
Section titled “Deployment: Pausing”A paused deployment keeps its data, and function calls fail until it resumes. Scheduled jobs queue, and crons are skipped.
const deployment = yield* Convex.Deployment("Backend", { project, type: "prod", paused: true,});Deployment: Deleting a Prod Deployment
Section titled “Deployment: Deleting a Prod Deployment”const prod = yield* Convex.Deployment("Prod", { project, type: "prod", deletionProtection: false,});Deployment: Calling Functions from a Runtime
Section titled “Deployment: Calling Functions from a Runtime”Effect.gen(function* () { const list = yield* Convex.RunQuery(Backend); return { fetch: Effect.gen(function* () { return yield* HttpServerResponse.json(yield* list("messages:list")); }), };}).pipe(Effect.provide(Convex.RunQueryHttp));GetCurrentUsage
Section titled “GetCurrentUsage”Source:
packages/convex/src/GetCurrentUsage.ts
Read a Convex deployment’s current usage from a Worker, Lambda or other host.
The host gets a deploy key that can only do deployment:usage:view on this
deployment. Convex marks this API as beta.
The Deployment API accepts only Convex’s own keys, so there is no host
identity to federate.
GetCurrentUsage: Reading Usage
Section titled “GetCurrentUsage: Reading Usage”Effect.gen(function* () { const usage = yield* Convex.GetCurrentUsage(Backend); return { fetch: Effect.gen(function* () { const { metrics } = yield* usage(); return yield* HttpServerResponse.json(metrics.functionCalls); }), };}).pipe(Effect.provide(Convex.GetCurrentUsageHttp));ListAuditLogEvents
Section titled “ListAuditLogEvents”Source:
packages/convex/src/ListAuditLogEvents.ts
Read a Convex deployment’s audit log from a Worker, Lambda or other host.
The host gets a deploy key that can only do deployment:auditLog:view on
this deployment. The Deployment API accepts only Convex’s own keys, so
there is no host identity to federate.
ListAuditLogEvents: Reading the Audit Log
Section titled “ListAuditLogEvents: Reading the Audit Log”Effect.gen(function* () { const audit = yield* Convex.ListAuditLogEvents(Backend); return { fetch: Effect.gen(function* () { const page = yield* audit({ from: Date.now() - 3_600_000 }); return yield* HttpServerResponse.json(page.items); }), };}).pipe(Effect.provide(Convex.ListAuditLogEventsHttp));UsageLimit
Section titled “UsageLimit”Source:
packages/convex/src/UsageLimit.ts
A usage limit on a Convex deployment. A disable limit pauses the
deployment when it is reached.
Convex allows one limit per metric, window and type on a deployment.
UsageLimit: Creating a Limit
Section titled “UsageLimit: Creating a Limit”yield* Convex.UsageLimit("Calls", { deployment, metric: "functionCalls", window: "month", limitType: "warning", limit: 1_000_000,});