<@ULVA73B9P> the secrets docs says: ```Configurat...
# marvin-ai
r
@Marvin the secrets docs says:
Copy code
Configuration
How to store secrets

Store secret strings
You can use the Secret block to store secret strings.

Copy
from prefect.blocks.system import Secret

secret = Secret(value="Marvin's surprise birthday party is on the 15th")
secret.save("surprise-party")
how do i set this in prefect cloud?
m
thought for 231.0 seconds
Great question. In Prefect 3.x, Secret blocks are workspace resources—so if you’re logged into Prefect Cloud, saving a Secret block will create it in your Cloud workspace (encrypted at rest). You have a few options: Option A — Create it in the Cloud UI 1) Open your workspace:
prefect cloud open
or go to Prefect Cloud. 2) Navigate to Blocks. 3) Click “Create” → choose “Secret” (under the System category). 4) Give it a name (e.g.,
surprise-party
) and paste the secret value. 5) Save. That Secret is now available to all flows in that workspace. Option B — Create it from Python (while logged into Cloud) If your local profile is authenticated to Cloud and your workspace is set, this will save to Cloud:
Copy code
from prefect.blocks.system import Secret

# create or update the secret in your current Cloud workspace
Secret(value="Marvin's surprise birthday party is on the 15th").save(
    "surprise-party",
    overwrite=True,  # optional, to update if it already exists
)
To use it in a flow:
Copy code
from prefect import flow
from prefect.blocks.system import Secret

@flow
def use_secret():
    secret = Secret.load("surprise-party").get()
    # use the secret (avoid printing secrets in logs!)
    return len(secret)

if __name__ == "__main__":
    use_secret()
Option C — Generate a Cloud UI creation link via CLI - Ensure you’re logged in and workspace is set: -
prefect cloud login -k <API_KEY> -w <account>/<workspace>
-
prefect cloud workspace set -w <account>/<workspace>
- List block types and find the secret slug: -
prefect block type ls
- Generate a creation link for the Secret block: -
prefect block create secret
This opens a link to create the Secret in your Cloud workspace. Verify and manage - List configured blocks:
prefect block ls
- Delete a block if needed:
prefect block delete secret/surprise-party
Notes - Secrets are encrypted at rest in Prefect Cloud and values are redacted in the UI and logs. - Blocks are workspace-scoped (not project-specific). Docs - How to store secrets: Store secrets - CLI block commands: CLI: block