Delete a single deployment

From these docs... https://developers.cloudflare.com/api/resources/workers/subresources/scripts/subresources/deployments/methods/delete/ ...you should be able to run this curl to delete a deployment:
curl -X DELETE "https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}" -H "Authorization: Bearer {api_token}"
curl -X DELETE "https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}" -H "Authorization: Bearer {api_token}"
I know how to fill in all of the parameters except {script_name}. TBH it seems like curl -X DELETE and {deployment_id} should give the API sufficient information to do the job, but leaving that aside, what value is meant to be used for {script_name} in order to delete the deployment?
11 Replies
Hard@Work
Hard@Work2w ago
The name of the Worker itself? Where are you getting the deployment_id from?
fredguest
fredguestOP2w ago
From the dashboard for the worker on the "Deployments" tab. So I guess the deployment_ids listed there are not unique within the account_id and need to be scoped to the worker? In that case I would excpect the parameter to be called worker_name not script_name, but it sounds like you're saying the worker name is what goes there correct?
Hard@Work
Hard@Work2w ago
Yeah, that should be it
Walshy
Walshy2w ago
deployment is a guid but either way, yes, script = worker script is mostly just legacy naming
fredguest
fredguestOP2w ago
Ah cool, makes sense now, thank you both. Huh, that didn't work, I got this error:
"errors": [
{
"code": 10336,
"message": "This deployment does not exist on your Worker."
}
]
"errors": [
{
"code": 10336,
"message": "This deployment does not exist on your Worker."
}
]
but I copied the deployment id from the worker's dashboard, so it does exist on the worker, at least according to the dashboard.
Walshy
Walshy2w ago
are you using the deployment or version id
fredguest
fredguestOP2w ago
Ah, it does say version id next to each deployment, I assumed that was the deployment id, I guess it's not. Where can I find the actual deployment ids?
Walshy
Walshy2w ago
it doesn't look like the UI shows them... if you go to "Deployment history" and then open dev tools, it's in the /deployments API call
fredguest
fredguestOP2w ago
That worked, cheers Walshy. Btw, that "Deployment History" page updates so it no longer lists the deployment you deleted, but the page that shows the "Active Deployment" and "Version History" does not update, it still includes the version that was deleted in the list of versions. Not a big deal, just a heads up as it might be worth updating in both locations to avoid confusion.
Hard@Work
Hard@Work2w ago
IIRC that's because while you can delete a deployment, you cannot delete a version
fredguest
fredguestOP2w ago
I see, it would be nice to clean up the version history as well if that's something that could be implemented in the future.

Did you find this page helpful?