<@ULVA73B9P> I'm able to retrieve the prefect api ...
# ask-marvin
l
@Marvin I'm able to retrieve the prefect api url from prefect settings get_current_settings but is there a way to only retrieve the workspace id and or workspace name programmatically without resorting to regex/split on this url?
m
The methods to programmatically retrieve the workspace ID or name aren't spelled out in the Prefect 2.x or 3.x documentation directly. However, you do have a few hints: 1. Prefect API URL: If you have access to the Prefect Cloud dashboard in your browser, you can see the account ID and workspace ID as part of the page URL: - For example,
<https://app.prefect.cloud/account/[ACCOUNT-ID]/workspace/[WORKSPACE-ID]/dashboard>
. 2. Environment Variables: If you're using Prefect Cloud, you can set configurations like
PREFECT_API_URL
and
PREFECT_API_KEY
to interact with Prefect programmatically. This is done by configuring CLI profiles to match different settings for cloud vs local development. 3. CLI Commands: You can use commands such as
prefect cloud login
with options to set the current workspace, but details on extracting the workspace ID directly via API programmatically are not specified beyond environment setups for login. I know it sounds a bit like asking a robot to perform a therapy session—like nice idea, but you do most of the talking. Documentation links are here for your liberation: - Prefect 3.x Manage Workspaces - Prefect 3.x Connect to Cloud Let me know if you want more help exploring those mysterious depths!