Build platform integration
Reflex's build platform integration gives framework tools a typed way to work with the Reflex Build API. It connects caller identity to projects and apps, turns app artifacts into deployments, and keeps environments, provider resources, and hosted runtime operations under one platform model.
Integration model
The integration presents one typed boundary for the main build-platform resources. Callers use resource groups for platform actions while the service keeps ownership of build execution, deployment state, and hosted runtime data.
Typed client boundary
The primary clients are ReflexBuild and AsyncReflexBuild. They expose typed groups for authentication, projects, apps, deployments, environments, providers, usage, and security reviews. The clients support synchronous and asynchronous callers, and the package lets callers choose an HTTP transport or supply one of their own. The build-service SDK covers the generated service interface and client lifecycle.
The clients return typed views of identities, projects, apps, deployments, environments, provider accounts, and operation results. This gives tools a stable view of platform state while the service performs the build and runtime work.
References: packages/…/README.md• L1-28 packages/…/README.md• L217-251 packages/…/__init__.py• L1-7
Service workflow
The integration takes a caller from access and target selection to build submission and deployment tracking. It then lets the caller inspect or change the hosted result through app, environment, and provider operations.
The flow below shows how local preparation connects to remote platform state.
flowchart LR
A[Access token] --> B[Resolve organization]
B --> C[Resolve project and app]
C --> D[Choose environment and provider]
D --> E[Upload build]
E --> F[Run deployment]
F --> G[Promote or manage runtime]
G --> H[Read status history logs and usage]
The deployment and hosting page describes the wider local export and hosting flow. This page focuses on the typed platform boundary that the flow uses.
References: packages/…/deployments.py• L75-162 packages/…/apps.py• L746-809 packages/…/deployments.py• L266-368
Authentication and access
Authentication identifies the caller and the organization that owns the target resources. The resulting identity also carries plan and permission limits that can affect later platform actions.
Access token sources
The client accepts an explicit token or the REFLEX_ACCESS_TOKEN environment value. It does not read the token saved by reflex login, so local and automated callers must pass the token through one of these supported paths. Browser login creates a token after user approval.
Token management returns typed token records. auth.tokens.create() and auth.tokens.refresh() return objects that expose the token through .token; a refresh can also report that the previous token remains active, which tells the caller whether it must revoke that token.
This boundary supports both local and automated work. Local commands can pass a deliberate token. CI can pass the same kind of token through a protected environment or secret store.
References: packages/…/CHANGELOG.md• L26-42 packages/…/CHANGELOG.md• L44-58 packages/…/README.md• L150-177 packages/…/_base.py• L131-163 packages/…/auth.py• L158-248
Identity and permissions
auth.me() resolves the user, organization, plan tier, and token scope. A valid token can still lack access to a project, provider, secret, or deployment.
Project access uses built-in roles, custom roles, members, and teams. Some changes can wait for approval, so a successful request can create a pending state instead of an immediate permission change.
References: packages/…/README.md• L18-20 packages/…/README.md• L48 packages/…/types.py• L13-51 packages/…/projects.py• L68-88 packages/…/projects.py• L233-323 packages/…/projects.py• L326-399
Projects and applications
Projects provide the ownership and access boundary for hosted apps. Each app belongs to one project, so project membership controls which people and service accounts can view or change that app.
Project resources
The project surface supports discovery, creation, rename, deletion, usage views, and audit history. It also manages project roles, direct members, and team grants so access matches the work required by the apps in the project.
The hosting CLI can select a project by ID or name and reuse that selection in later commands. This preserves local context without changing the service ownership model.
References: packages/…/README.md• L30-48 packages/…/projects.py• L402-526 packages/…/project.py• L114-235
Application resources
Apps are the deployable units inside projects. The app surface manages app identity, runtime settings, start and stop actions, scaling, deployment history, logs, rollback, secrets, custom domains, managed databases, sign-in settings, and third-party connections.
These actions can change or inspect a hosted app without a new local source build in every case. A rollback can reuse a stored deployment. Secret, database, and sign-in changes can affect a later deployment or restart rather than changing the running app at once.
References: packages/…/README.md• L48-60 packages/…/README.md• L117-148 packages/…/apps.py• L282-390 packages/…/apps.py• L452-649 packages/…/apps.py• L775-863
Deployment and environment operations
Deployment operations turn exported frontend and backend artifacts into a hosted app version. The platform records the version, runs the build, reports the result, and keeps history for later inspection or rollback.
Build submission
deployments.create() accepts the production archives and deployment choices such as region, machine size, hostname, secrets, rollout strategy, and runtime versions. The client prepares upload targets and submits the deployment to the control plane. The service continues the deployment after submission.
Callers use deployments.wait() or separate status and report operations to distinguish a running deployment from one that failed or waits for approval. Build logs and deployment reports provide the next useful context when a build does not go live.
References: packages/…/README.md• L62-86 packages/…/deployments.py• L64-162 packages/…/deployments.py• L266-368 packages/…/types.py• L143-188
Environment pipelines
An environment pipeline gives an app ordered stages such as development and production. A new build enters the first stage. Later stages receive a promoted version with their own URL, secrets, and runtime state.
Promotion reuses the built version instead of rebuilding source. A target environment can require approval. Callers must treat AwaitingApproval as a real state that needs action rather than as a failed deployment.
References: packages/…/README.md• L88-115 packages/…/environments.py• L48-97 packages/…/environments.py• L99-224 packages/…/types.py• L301-363
Deployment observation
The platform exposes both short-term progress and durable records. Status and reports show whether a deployment is pending, running, awaiting approval, or finished with a failure. App history records versions for inspection or rollback. Runtime logs show what a live app is doing.
This split matters because a deployment can finish after a local command exits. A dashboard, CLI command, or long-running automation job can reconnect by deployment or app identity and read the current state.
References: packages/…/README.md• L41-48 packages/…/README.md• L79-86 packages/…/deployments.py• L266-368 packages/…/apps.py• L562-585 packages/…/apps.py• L788-863
Provider integrations
Provider operations decide where a hosted runtime runs while keeping the app in the same project and deployment model. Reflex Build is the managed default. An organization can also connect Google Cloud for managed deployments to its own Cloud Run resources.
Provider accounts
The provider surface reports Google Cloud readiness, lists connected accounts, verifies access, rotates keys, changes runtime and network settings, and selects a default account. Organization-level provider changes need stronger access because they affect shared cloud resources.
An app can switch provider, select a named account, choose whether the frontend runs from the provider runtime, and set Google Cloud instance bounds. A provider change can release resources from the old target, so the returned change state is part of the operation result.
References: packages/…/README.md• L190-215 packages/…/providers.py• L89-297 packages/…/providers.py• L300-455 packages/…/apps.py• L651-744
Provider visibility
The hosting CLI exposes provider status and connection lists for engineers who choose a deployment target. A member may read deploy readiness without being allowed to read all account details. The CLI therefore keeps status and administrative account data as separate views.
Managed provider operations keep the app, deployment history, logs, and lifecycle in Reflex Build. Standalone cloud deployment uses local cloud credentials and does not create the same hosted app record. See deployment and hosting for this wider distinction.
References: packages/…/providers.py• L194-285 packages/…/providers.py• L288-387 packages/…/providers.py• L352-362
Supporting service operations
The build platform also exposes services that support the app lifecycle around deployment. These services keep runtime data, product controls, and operational records under the same authenticated project and app model.
Runtime configuration
App secrets provide environment-specific values to the deployed runtime. Custom domains connect an app to DNS records and certificate readiness. The managed database service provisions shared Postgres resources and places connection values into app secrets for later deployments. Sign-in settings and third-party connections extend the app with managed user access and external service credentials.
These operations affect deployment behavior even when they do not create a deployment. A secret, database, or sign-in change may wait for a new deployment. A domain or connection may have readiness or access requirements that the caller must inspect.
References: packages/…/README.md• L50-60 packages/…/README.md• L117-148 packages/…/apps.py• L78-209 packages/…/apps.py• L211-279 packages/…/apps.py• L282-307 packages/…/types.py• L265-393
Account and platform services
The client includes token management, organization usage, and source security reviews alongside hosting resources. Token management supports scoped automation access. Usage reports plan allowance activity. Security reviews return findings before or around deployment workflows.
These services use the same identity and error model as app operations. Automation can therefore combine their results with project, deployment, and provider state before it continues.
References: packages/…/README.md• L171-188 packages/…/auth.py• L34-140 packages/…/usage.py• L1-120 packages/…/security_reviews.py• L1-140 packages/…/types.py• L927-996
Client lifecycle and failure model
The typed clients own the link between callers and the build service during a workflow. They support sync and async use, accept a configurable transport, and expose errors that separate access, network, response, and deployment outcomes.
Client lifetime
ReflexBuild can be used as a context manager or closed explicitly. AsyncReflexBuild has the matching async context and close operation. A client creates its default transport when the caller does not provide one. When a caller supplies a transport, that caller keeps ownership of it.
The SDK requires Python 3.11 or newer. Its HTTP libraries are optional extras, while this repository's development group installs the aiohttp, httpx, and httpx2 paths together. The public reflex_build_sdk.transports.default_transport() factory lets a wrapper preserve the SDK's default HTTP-library choice. A wrapper owns that returned transport and must close it when finished.
The build-service SDK is the child page for client lifetime, transport choices, and the generated sync and async surface. This page uses those details only to show where the platform integration begins and ends.
References: packages/…/CHANGELOG.md• L5-16 packages/…/CHANGELOG.md• L26-42 packages/…/README.md• L221-251 packages/…/+default-transport-factory.feature.md• L1 packages/…/__init__.py• L1-7 packages/…/__init__.py• L23-71 packages/…/_client.py• L32-124 packages/…/_client.py• L31-122 packages/…/_base.py• L1-130 packages/…/_aiohttp.py• L73-197 pyproject.toml• L21 pyproject.toml• L128 pyproject.toml• L526-584
Error outcomes
API errors identify the request and preserve service detail. Deployment failures include the deployment report. Timeouts say that the operation is still unresolved rather than claiming that it failed. Safe transient requests can be retried. A caller must not treat every write as safe to repeat.
Response decoding turns JSON into the SDK's typed models. It checks primitive values, collections, enumerations, dates, and data objects. A mismatch includes the location of the invalid value, while unknown response fields remain compatible with newer service responses.
This distinction lets higher-level tools choose a useful next action: fix access or input errors, retry a safe transient request, inspect a deployment report, or continue an approval flow.
References: packages/…/README.md• L217-219 packages/…/_errors.py• L14-64 packages/…/_errors.py• L80-209 packages/…/_base.py• L265-334 packages/…/_decode.py• L20-104 packages/…/_decode.py• L352-395
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the sync and async resource surfaces aligned. A capability added to one client must remain available to callers using the other client.
- Keep token scope, project permissions, and CLI authentication behavior aligned. A command can appear logged in while still lacking the resource permission it needs.
- Keep explicit token and environment-token handling aligned with the package contract. Do not restore an assumption that clients read the token saved by
reflex login. - Keep token creation and refresh result models aligned with callers that read
.tokenand inspect previous-token revocation state. - Preserve the relationship between project, app, environment, and deployment identifiers. A mismatch can send a valid operation to the wrong lifecycle stage.
- Review build upload, deployment submission, and status interpretation together. A change in one stage can turn a successful upload into an untracked or falsely reported deployment.
- Keep provider account selection separate from provider readiness and standalone cloud deployment. These paths use different ownership and recovery rules.
- Keep environment secrets, hostnames, and promotion behavior aligned. A promotion can use the right build with the wrong runtime configuration if these contracts drift.
- Preserve typed response shapes and error detail fields used by the SDK and CLI. A shape change can fail after the service accepts the request.
- Keep pyproject.toml workspace source, dependency, Python version, and
exclude-newerentries aligned with the SDK package. A repository tool must resolve the intended localreflex-build-sdksurface on a supported Python version. - Keep the SDK package's optional transport extras aligned with the transports that the root development dependency installs. A missing extra can leave a supported client path unavailable to repository tools.
- Keep wrapper use of
default_transport()aligned with the SDK's default HTTP-library selection. A wrapper must own and close a transport it obtains from the factory. - Keep response model changes aligned with decoder rules. A service field or type change must still produce useful typed values and error paths.
- Keep streamed upload timeout behavior aligned across supported transports. A stalled body must become a clear timeout rather than an unbounded wait.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A token is missing, expired, revoked, or scoped away from the target project | The client cannot read or change the requested platform resource. | Resolve token identity with auth.me() and use a token with the required project and resource access. |
A caller expects the token saved by reflex login or treats a created token as a string | Client setup or token use fails before the intended platform operation. | Pass token= or set REFLEX_ACCESS_TOKEN, and read created or refreshed token values from .token. |
| A build is submitted before its upload targets are usable | The deployment can be rejected or the exported frontend can point at the wrong public URL. | Prepare upload targets before export and submit the matching backend and frontend archives. |
A deployment reaches AwaitingApproval and the caller treats it as failure or success | Automation stops too early or reports an app as live before approval. | Preserve the approval state and let an authorized user approve it before continuing. |
| Environment secrets change after a build is created but before promotion | The promoted version can run with values different from the source environment. | Treat each environment's secrets as part of its runtime state and inspect the target before promotion. |
| A provider switch releases the old runtime and the new provider cannot provision | The app can remain stopped or have incomplete provider resources. | Check provider readiness first and inspect the returned release state after the switch. |
| A caller retries a non-idempotent write after losing the response | The service may apply the operation twice or create an untracked second operation. | Use SDK retry rules and reconcile by the returned resource or deployment identity. |
| A supplied Google Cloud key lacks required access or becomes invalid | Managed Google Cloud deployment and later provider operations fail. | Verify the connection and rotate the key through the provider account lifecycle. |
| A wrapper obtains a default transport and leaves it open | The HTTP client can retain resources after the platform workflow ends. | Close the transport returned by default_transport() when the wrapper finishes. |
| The SDK workspace source, dependency, Python floor, or recent-package cutoff exemption is missing | Repository tools may resolve a different SDK, reject the package during resolution, or run on an unsupported Python version. | Keep the package metadata and root workspace entries aligned. |
| A selected transport extra is not installed for the client path in use | Client setup fails before a platform request can start. | Keep the SDK optional transport extras and the root development dependency extras in sync. |
| A service response no longer matches a typed model | The client raises a response validation error instead of returning platform state. | Treat response fields and types as a contract and inspect the reported data path. |
| A streamed upload stops moving and the transport has no effective stall limit | The caller waits without a result and cannot apply normal timeout handling. | Use transport behavior that turns a stalled body into a timed-out transport error. |
Key files
| File | Why to read it |
|---|---|
| packages/…/README.md | Gives the public product view of authentication, projects, apps, deployments, environments, providers, and supporting services. |
| packages/…/CHANGELOG.md | Records compatibility changes for token handling, transport extras, client names, Python support, and typed response behavior. |
| packages/…/_client.py | Shows the main typed resource boundary for the build platform. |
| packages/…/_client.py | Shows the async form of the same platform surface and its lifecycle. |
| packages/…/types.py | Defines typed views of identity, projects, apps, environments, deployments, providers, and results. |
| packages/…/auth.py | Shows browser login, token identity, and automation token operations. |
| packages/…/projects.py | Shows project ownership, access roles, members, teams, and audit history. |
| packages/…/apps.py | Shows app lifecycle actions, runtime configuration, history, logs, and provider settings. |
| packages/…/deployments.py | Shows build submission, deployment observation, validation, and deployment metadata. |
| packages/…/environments.py | Shows staged deployment pipelines, promotion, approval, and environment secrets. |
| packages/…/providers.py | Shows organization provider readiness and connected Google Cloud operations. |
| packages/…/_errors.py | Shows the distinction between access, API, network, timeout, and deployment failures. |
| packages/…/_decode.py | Shows how service responses become typed models and how validation failures locate bad data. |
| packages/…/__init__.py | Shows the public transport types, optional transport loading, and the default transport factory. |
| packages/…/_aiohttp.py | Shows async transport session ownership and stalled upload handling. |
| packages/…/pyproject.toml | Shows the SDK package's Python support and optional transport extras. |
| packages/…/+default-transport-factory.feature.md | Records the public default transport factory used by transport wrappers. |
| packages/…/deploy.py | Shows how the public reflex deploy command hands app preparation to the hosting integration. |
| packages/…/providers.py | Shows the CLI view of provider readiness and named provider connections. |
| pyproject.toml | Shows the root Python support, workspace resolution, development transport extras, and package time-cutoff rules. |