Delete Document¶
Deletes the document with the specified ID from the semantic index.
Endpoint¶
Path parameter | Type | Details |
---|---|---|
{id} |
string | Unique ID of the document to be deleted. |
API request¶
-
Parameters
No parameters.
-
DELETE /v20241104/documents/{id}
curl -X DELETE "https://api.gainly.ai/v20241104/documents/YOUR_DOCUMENT_ID_HERE" \ # (1)! -H "X-API-Key: YOUR_API_KEY_HERE" # (2)!
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
# Prompt for AI coding assistants/IDEs (e.g., ChatGPT, Claude, GitHub Copilot, Cursor, Windsurf) Using the Gainly API: 1. Write code to call the delete_document operation (see OpenAPI spec: https://api.gainly.ai/v20241104/openapi.json) 2. Implement authentication using the header "X-API-Key" as described in the docs: https://docs.gainly.ai/latest/api-reference/authentication/ 3. Implement rate limit handling as described in the docs: https://docs.gainly.ai/latest/api-reference/rate-limits/ 4. Implement error handling 5. Handle the response according to the DocumentDeleteResponse schema in the OpenAPI spec
using System.Net.Http; var client = new HttpClient(); var id = "YOUR_DOCUMENT_ID_HERE"; // (1)! var url = $"https://api.gainly.ai/v20241104/documents/{id}"; client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY_HERE"); // (2)! var response = await client.DeleteAsync(url); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result);
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
package main import ( "fmt" "net/http" ) func main() { id := "YOUR_DOCUMENT_ID_HERE" // (1)! url := fmt.Sprintf("https://api.gainly.ai/v20241104/documents/%s", id) req, _ := http.NewRequest("DELETE", url, nil) req.Header.Set("X-API-Key", "YOUR_API_KEY_HERE") // (2)! resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Println(result) }
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.URI; var client = HttpClient.newHttpClient(); var id = "YOUR_DOCUMENT_ID_HERE"; // (1)! var url = "https://api.gainly.ai/v20241104/documents/" + id; var request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("X-API-Key", "YOUR_API_KEY_HERE") // (2)! .DELETE() .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
const axios = require('axios'); // or: import axios from 'axios'; const id = 'YOUR_DOCUMENT_ID_HERE'; // (1)! const url = `https://api.gainly.ai/v20241104/documents/${id}`; const headers = { 'X-API-Key': 'YOUR_API_KEY_HERE' // (2)! }; axios.delete(url, { headers }) .then(response => console.log(response.data)) .catch(error => console.error('Error:', error.message));
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
<?php $client = new \GuzzleHttp\Client(); $id = 'YOUR_DOCUMENT_ID_HERE'; # (1)! $url = "https://api.gainly.ai/v20241104/documents/{$id}"; $response = $client->request('DELETE', $url, [ 'headers' => [ 'X-API-Key' => 'YOUR_API_KEY_HERE' # (2)! ], ]); echo $response->getBody();
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
import requests id = "YOUR_DOCUMENT_ID_HERE" # (1)! url = f"https://api.gainly.ai/v20241104/documents/{id}" headers = { "X-API-Key": "YOUR_API_KEY_HERE" # (2)! } response = requests.delete(url, headers=headers) data = response.json() print(data)
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
require 'uri' require 'net/http' require 'openssl' id = 'YOUR_DOCUMENT_ID_HERE' # (1)! url = URI("https://api.gainly.ai/v20241104/documents/#{id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Delete.new(url) request['X-API-Key'] = 'YOUR_API_KEY_HERE' # (2)! response = http.request(request) puts response.read_body
- Replace
YOUR_DOCUMENT_ID_HERE
with the document ID you want to delete. - Replace
YOUR_API_KEY_HERE
with the value of your API key.
- Replace
API Response¶
Returns an object with deleted
parameter on success.