Skip to main content
DELETE
/
v1
/
tasks
/
{task_id}
Delete Task
curl --request DELETE \
  --url https://api.xpander.ai/v1/tasks/{task_id} \
  --header 'x-api-key: <api-key>'
import requests

url = "https://api.xpander.ai/v1/tasks/{task_id}"

headers = {"x-api-key": "<api-key>"}

response = requests.delete(url, headers=headers)

print(response.text)
const options = {method: 'DELETE', headers: {'x-api-key': '<api-key>'}};

fetch('https://api.xpander.ai/v1/tasks/{task_id}', 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.xpander.ai/v1/tasks/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);

$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.xpander.ai/v1/tasks/{task_id}"

req, _ := http.NewRequest("DELETE", url, nil)

req.Header.Add("x-api-key", "<api-key>")

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.xpander.ai/v1/tasks/{task_id}")
.header("x-api-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.xpander.ai/v1/tasks/{task_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}
Delete a task by ID. Running tasks will be cancelled before deletion, and all associated data including results and conversation history will be permanently removed.

Path Parameters

task_id
string
required
Unique identifier of the task to delete (UUID format)

Response

Returns 204 No Content on successful deletion (empty response body).

Example Request

curl -X DELETE -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>"

Response Status Codes

StatusMeaning
204Task deleted successfully
404Task not found
401Unauthorized (invalid API key)
403Forbidden (task belongs to different organization)

Important Notes

  • Permanent deletion - This action cannot be undone
  • Running tasks - Will be cancelled before deletion
  • Data removal - Results, conversation history, and all associated data are removed
  • Sub-tasks - All sub-tasks are also deleted

Example with Error Handling

TASK_ID="<task-id>"

RESPONSE=$(curl -w "\n%{http_code}" -X DELETE \
  -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/$TASK_ID")

HTTP_CODE=$(echo "$RESPONSE" | tail -n1)

if [[ $HTTP_CODE == "204" ]]; then
  echo "Task deleted successfully"
elif [[ $HTTP_CODE == "404" ]]; then
  echo "Task not found"
else
  echo "Error: $HTTP_CODE"
fi

Use Cases

  • Clean up completed tasks - Remove old task data to save storage
  • Cancel running tasks - Stop a task that’s in progress
  • Manage sensitive data - Delete tasks containing sensitive information
  • Maintain organization - Remove test or failed tasks

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

task_id
string
required

Response

Successful Response