Platform Endpoints
Delete Environment
Clean up an environment and its database schema
DELETE
/
api
/
platform
/
env
/
{envId}
Delete Environment
curl --request DELETE \
--url https://api.example.com/api/platform/env/{envId}import requests
url = "https://api.example.com/api/platform/env/{envId}"
response = requests.delete(url)
print(response.text)const options = {method: 'DELETE'};
fetch('https://api.example.com/api/platform/env/{envId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/platform/env/{envId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/platform/env/{envId}"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.example.com/api/platform/env/{envId}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/platform/env/{envId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body{
"environmentId": "<string>",
"status": "<string>"
}Request
DELETE /api/platform/env/{envId}
Path Parameters
string
required
Environment ID from
initEnvExample Request
curl -X DELETE https://api.agentdiff.dev/api/platform/env/abc123def456 \
-H "X-API-Key: ad_live_sk_..."
Response
string
Environment identifier that was deleted
string
Status:
"deleted"Example Response
{
"environmentId": "abc123def456",
"status": "deleted"
}
What Happens
- Schema dropped: PostgreSQL schema and all data deleted
- Record updated: Environment marked as deleted in database
- Resources freed: Pool slot recycled for reuse
Always delete environments when done to free up resources. Environments auto-expire after their TTL, but explicit deletion is faster.
Errors
| Error | Status | Description |
|---|---|---|
environment_not_found | 404 | Environment doesn’t exist |
environment_already_deleted | 400 | Environment was already deleted |
SDK Usage
# Delete environment
client.delete_env(envId=env.environmentId)
print("Environment cleaned up")
// Delete environment
await client.deleteEnv(env.environmentId);
console.log('Environment cleaned up');
Best Practices
Always clean up in finally blocks
Always clean up in finally blocks
env = client.init_env(...)
try:
run = client.start_run(envId=env.environmentId)
# ... your test code ...
finally:
client.delete_env(envId=env.environmentId)
Use context managers (Python)
Use context managers (Python)
# Coming soon: context manager support
# with client.environment(...) as env:
# ...
⌘I
Delete Environment
curl --request DELETE \
--url https://api.example.com/api/platform/env/{envId}import requests
url = "https://api.example.com/api/platform/env/{envId}"
response = requests.delete(url)
print(response.text)const options = {method: 'DELETE'};
fetch('https://api.example.com/api/platform/env/{envId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/platform/env/{envId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/platform/env/{envId}"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.example.com/api/platform/env/{envId}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/platform/env/{envId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body{
"environmentId": "<string>",
"status": "<string>"
}