DELETE /api/v1/todos/105 • HTTP 200 OK
DELETE Request (Remove Resource API Example) — Request & Response Example
Demonstrates how clients command an API to purge or archive an entity using the DELETE HTTP verb.
1. HTTP Client Request (DELETE)
DELETE /api/v1/todos/105 HTTP/1.1
{
"Accept": "application/json"
}
2. Server JSON Response (HTTP 200 OK)
{
"success": true,
"deleted_id": 105,
"message": "Todo item #105 was permanently deleted from the database."
}
Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)
curl -X DELETE "https://cometflow.space/api/v1/todos/105" \
-H "Accept: application/json"
fetch('https://cometflow.space/api/v1/todos/105', {
method: 'DELETE'
})
.then(res => res.json())
.then(data => console.log(data.message));
import requests
res = requests.delete('https://cometflow.space/api/v1/todos/105')
print(res.json())
How This API Call Works Step-by-Step
- 1. Client issues HTTP DELETE with item ID 105 in URL.
- 2. Server validates that the user possesses permission to delete this record.
- 3. Server issues DELETE FROM todos WHERE id = 105 in database.
- 4. Server confirms deletion with 200 OK or 204 No Content.
Backend API Functions: The API function deleteTodo(req, res) checks authorization, invokes the database deletion method, and sends a confirmation JSON response.
Frequently Asked Questions
Should DELETE return 200 OK or 204 No Content?
Both are standard. If your API returns a JSON confirmation message, return 200 OK. If your API returns an empty body, return 204 No Content.