//native
type Vercel = {
token: string;
};
/**
* Delete a Deployment
* This API allows you to delete a deployment, either by supplying its `id` in the URL or the `url` of the deployment as a query parameter. You can obtain the ID, for example, by listing all deployments.
*/
export async function main(
auth: Vercel,
id: string,
url: string | undefined,
teamId: string | undefined,
slug: string | undefined,
) {
const url_ = new URL(`https://api.vercel.com/v13/deployments/${id}`);
for (const [k, v] of [
["url", url],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url_.searchParams.append(k, v);
}
}
const response = await fetch(url_, {
method: "DELETE",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago