Janet Carson
05/04/2026, 8:00 PMMarvin
05/04/2026, 8:00 PMMarvin
05/04/2026, 8:01 PM"<flow_name>/<deployment_name>"
Quick example:
python
from prefect.client.orchestration import get_client
def get_deployment_created_date(deployment_full_name: str):
with get_client(sync_client=True) as client:
deployment = client.read_deployment_by_name(deployment_full_name)
return deployment.created
Usage:
python
date = get_deployment_created_date("my-flow/my-deployment")
print(date)
If you want the last updated date instead:
python
from prefect.client.orchestration import get_client
def get_deployment_updated_date(deployment_full_name: str):
with get_client(sync_client=True) as client:
deployment = client.read_deployment_by_name(deployment_full_name)
return deployment.updated
If you want, I can also give you:
- an async version
- a version with error handling for “deployment not found”
- a version that accepts just the deployment name and searches for matchesJanet Carson
05/04/2026, 8:05 PMMarvin
05/04/2026, 8:05 PMMarvin
05/04/2026, 8:07 PMpython
from prefect.client.orchestration import get_client
from prefect.exceptions import ObjectNotFound
def get_deployment_created_date(deployment_full_name: str):
"""
Return the created timestamp for a deployment.
Expected format:
'<flow_name>/<deployment_name>'
"""
try:
with get_client(sync_client=True) as client:
deployment = client.read_deployment_by_name(deployment_full_name)
return deployment.created
except ValueError as exc:
raise ValueError(
"Invalid deployment name format. Expected '<flow_name>/<deployment_name>'."
) from exc
except ObjectNotFound as exc:
raise LookupError(
f"Deployment not found: {deployment_full_name}"
) from exc
If you want the updated timestamp instead:
python
from prefect.client.orchestration import get_client
from prefect.exceptions import ObjectNotFound
def get_deployment_updated_date(deployment_full_name: str):
"""
Return the updated timestamp for a deployment.
Expected format:
'<flow_name>/<deployment_name>'
"""
try:
with get_client(sync_client=True) as client:
deployment = client.read_deployment_by_name(deployment_full_name)
return deployment.updated
except ValueError as exc:
raise ValueError(
"Invalid deployment name format. Expected '<flow_name>/<deployment_name>'."
) from exc
except ObjectNotFound as exc:
raise LookupError(
f"Deployment not found: {deployment_full_name}"
) from exc
Where is the return value of read_deployment_by_name defined?
The method returns a DeploymentResponse object.
You can see that in:
- the API reference for the client: https://docs.prefect.io/v3/api-ref/python/prefect-client-orchestration-__init__/
- the schema docs for `DeploymentResponse`: https://docs.prefect.io/v3/api-ref/python/prefect-client-schemas-responses/
The actual returned model is defined in the prefect.client.schemas.responses module as DeploymentResponse, which includes fields like:
- id
- name
- created
- updated
- flow_id
- work_pool_name
- parameters
- schedules
What’s the significance of deployment_full_name vs just deployment name?
This is important: read_deployment_by_name(...) does not accept only the deployment’s short name.
It expects the full name in this format:
python
"<flow_name>/<deployment_name>"
So this is valid:
python
"my-flow/my-deployment"
And this is not valid:
python
"my-deployment"
Why? Because deployment names are looked up in the context of a flow. The client splits the string on / into:
- flow_name
- deployment_name
If you pass only my-deployment, Prefect can’t determine which flow it belongs to, and the method raises a ValueError.
So deployment_full_name is just a clearer variable name than deployment_name, because it reminds you that the function expects the combined flow/deployment identifier, not the short deployment name alone.
If you want, I can also give you a helper that accepts flow_name and deployment_name as separate arguments instead of requiring the combined string.