Delete Blog
Delete Blog Endpoint
Section titled “Delete Blog Endpoint”Use the following endpoint to delete a blog post via the API.
Endpoint
Section titled “Endpoint”DELETE /api/v1/public/delete-blog/{blogId}Authentication
Section titled “Authentication”Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEYCode Examples
Section titled “Code Examples”// Replace "YOUR_UNIQUE_BLOG_ID" with the actual Blog ID// Endpoint: {API_ENDPOINTS.BLOGS.DELETE("YOUR_UNIQUE_BLOG_ID")}fetch(`https://api.blogz.ai/api/v1/public/delete-blog/YOUR_UNIQUE_BLOG_ID`, { method: 'DELETE', headers: { 'Authorization': `Bearer YOUR_API_KEY`, }}).then(response => response.json()) // Expecting JSON data for a successful DELETE.catch(error => console.error('Error deleting blog:', error));// Replace "YOUR_UNIQUE_BLOG_ID" with the actual Blog ID
fetch("https://api.blogz.ai/api/v1/public/delete-blog/YOUR_UNIQUE_BLOG_ID", { method: 'DELETE', headers: { 'Authorization': `Bearer YOUR_API_KEY`, }}).then((response: Response) => response.json()) // Expecting JSON data for a successful DELETE.then((data: any | null) => { if (data) { console.log('Blog deletion successful:', data); }}).catch((error: Error) => console.error('Error deleting blog:', error));import requestsimport json
# Endpoint base: {API_ENDPOINTS.BLOGS.DELETE_BASE}api_base_url = "https://api.blogz.ai/api/v1/public/delete-blog"api_key = "YOUR_API_KEY"blog_id_to_delete = "your-unique-blog-id" # Replace with the actual Blog IDapi_url_with_id = f"{api_base_url}/{blog_id_to_delete}"
headers = { "Authorization": f"Bearer {api_key}"}
try: response = requests.delete(api_url_with_id, headers=headers)
if response.status_code == 200: try: response_data = response.json() print("Blog deletion successful:", json.dumps(response_data, indent=2)) except json.JSONDecodeError: print(f"Blog deletion successful (Status Code: {response.status_code}), response body: {response.text}") elif response.status_code == 204: print("Blog deleted successfully (Status Code: 204 No Content).") else: response.raise_for_status()
except requests.exceptions.RequestException as e: print(f"Error deleting blog: {e}") if e.response is not None: print(f"Status Code: {e.response.status_code}") print(f"Response body: {e.response.text}")# Replace 'your-unique-blog-id' with the actual Blog ID# Endpoint: {API_ENDPOINTS.BLOGS.DELETE("your-unique-blog-id")}curl -X DELETE https://api.blogz.ai/api/v1/public/delete-blog/your-unique-blog-id \ -H "Authorization: Bearer YOUR_API_KEY"