Delete Document

This example shows you how to delete a document you've added to your account

Delete documents from your trusted document library

The Delete Document API endpoint allows you to delete a document from your Locusive account.

Endpoint

POST <https://api.locusive.com/v1/documents/{id}>

Request Headers

The API request must include the following header:

Authorization: Bearer <Your-Secret-Key> - The secret key for authenticating the API request.

URL Path Parameters

  • id (string, required): The ID of the document to delete

Example Java code

package com.locusive.public_api.ad_hoc;

import com.google.gson.Gson;
import com.locusive.public_api.PublicApiConfig;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

public class AdHocDeleteContentFromPublicApiScript {
	private static final String ApiKey = "your-api-key";
	private static final String Url = "https://api.locusive.com/v1/documents";

	public static void main(String[] args) {
		try {
			String idToDelete = "id-to-delete";
			HttpDelete httpDelete = new HttpDelete(UrlBase + "/" + idToDelete);
			httpDelete.addHeader("Authorization", "Bearer " + ApiKey);
			httpDelete.addHeader("Content-Type", "application/json"); // indicate we're sending JSON

			// Execute the HTTP request
			try (CloseableHttpClient httpClient = HttpClients.createDefault();
			     CloseableHttpResponse response = httpClient.execute(httpDelete)) {
				System.out.println(response.getStatusLine().getStatusCode());
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Responses

  • 204: Document deleted successfully
  • 400: A bad request error
  • 403: Permission denied
  • 500: If there is an internal server error while processing the request

What’s Next