0

Delete a deployment

by
Published Oct 17, 2025

Delete a deployment Deployment deletion has some restrictions: - You can only delete deployments that have been offline and unused for at least 15 minutes. Example cURL request: ```command curl -s -X DELETE \ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ https://api.replicate.com/v1/deployments/acme/my-app-image-generator ``` The response will be an empty 204, indicating the deployment has been deleted.

Script replicate Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Replicate = {
3
  token: string;
4
};
5
/**
6
 * Delete a deployment
7
 * Delete a deployment
8

9
Deployment deletion has some restrictions:
10

11
- You can only delete deployments that have been offline and unused for at least 15 minutes.
12

13
Example cURL request:
14

15
```command
16
curl -s -X DELETE \
17
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
18
  https://api.replicate.com/v1/deployments/acme/my-app-image-generator
19
```
20

21
The response will be an empty 204, indicating the deployment has been deleted.
22

23
 */
24
export async function main(
25
  auth: Replicate,
26
  deployment_owner: string,
27
  deployment_name: string,
28
) {
29
  const url = new URL(
30
    `https://api.replicate.com/v1/deployments/${deployment_owner}/${deployment_name}`,
31
  );
32

33
  const response = await fetch(url, {
34
    method: "DELETE",
35
    headers: {
36
      Authorization: "Bearer " + auth.token,
37
    },
38
    body: undefined,
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.text();
45
}
46