Simon Rascovsky
02/15/2025, 7:34 AMMarvin
02/15/2025, 7:34 AM/api/events
endpoint in the Prefect REST API typically includes an event
and a resource
definition. Prefect Cloud will populate default values for any missing fields, like occurred
and id
, so you don't need to include those in your payload.
Here's a basic structure you might use:
json
{
"event": "your-event-name",
"resource": {
"prefect.resource.id": "your-resource-id",
"prefect.resource.description": "your-resource-description"
},
"payload": {
// Any additional data you want to include
}
}
For more detailed information, you can refer to the Prefect documentation on webhook triggers.Simon Rascovsky
02/15/2025, 8:01 AMMarvin
02/15/2025, 8:02 AMresource
field in the event payload refers to the primary resource that the event concerns. It typically includes an identifier and a description of the resource. In the context of Prefect, resources can be objects like flows, tasks, deployments, work queues, and logs. These resources are often prefixed with prefect
or prefect-cloud
.
Here’s a brief overview of the resource
field structure:
- prefect.resource.id
: A unique identifier for the resource. This is typically a string that you define to identify the resource related to the event.
- prefect.resource.description
: A description of the resource, providing context about what the resource is or the action that was taken.
For example, if you are emitting an event related to a deployment request, your resource
might look like this:
json
"resource": {
"prefect.resource.id": "deployment-request-123",
"prefect.resource.description": "A deployment request was created"
}
This structure helps Prefect understand what the event is about and how it relates to your Prefect objects. More details can be found in the Prefect documentation on events.Simon Rascovsky
02/15/2025, 8:06 AMMarvin
02/15/2025, 8:06 AMprefect
prefix to clearly identify it as a Prefect resource. Therefore, you should format it as "prefect.resource.id": "prefect.my-automation-name"
. This ensures that the resource is recognized as part of the Prefect ecosystem and follows the structured specification for events.