Posts

Delete Post

Delete a scheduled post before it's published.

Endpoint

DELETE /posts/:postId

Request

curl -X DELETE https://api.postcore.dev/posts/post_abc123 \
  -H "x-api-key: YOUR_API_KEY"
const response = await fetch(
  `https://api.postcore.dev/posts/${postId}`,
  {
    method: 'DELETE',
    headers: {
      'x-api-key': process.env.POSTCORE_API_KEY
    }
  }
);

const data = await response.json();
console.log(data.message); // "Post deleted successfully"
import os
import requests

response = requests.delete(
    f'https://api.postcore.dev/posts/{post_id}',
    headers={'x-api-key': os.getenv('POSTCORE_API_KEY')}
)

data = response.json()
print(data['message'])  # "Post deleted successfully"

Response

{
  "message": "Post deleted successfully"
}

Status Code: 200 OK


Important Restrictions

Can Only Delete Pending Posts

You can only delete posts with status: "pending". Posts that have already been published or failed cannot be deleted via the API.

// ✅ Can delete
{ "status": "pending" }

// ❌ Cannot delete
{ "status": "published" }
{ "status": "failed" }

Published Posts Stay on Platforms

Even if you could delete a post record from postcore, the actual post on LinkedIn or Bluesky would remain. You must delete published posts directly on each platform.


Use Cases

Cancel Scheduled Post

async function cancelScheduledPost(postId) {
  // Verify it's still pending
  const { post } = await fetch(`https://api.postcore.dev/posts/${postId}`, {
    headers: { "x-api-key": apiKey },
  }).then((r) => r.json());

  if (post.status !== "pending") {
    console.error(`Cannot delete ${post.status} post`);
    return false;
  }

  // Delete the post
  await fetch(`https://api.postcore.dev/posts/${postId}`, {
    method: "DELETE",
    headers: { "x-api-key": apiKey },
  });

  console.log("Post canceled successfully");
  return true;
}

Delete All Pending Posts for a Profile

async function deletePendingForProfile(profileKey) {
  // Get all posts
  const { posts } = await fetch("https://api.postcore.dev/posts", {
    headers: { "x-api-key": apiKey },
  }).then((r) => r.json());

  // Filter to pending posts for this profile
  const pendingPosts = posts.filter(
    (p) => p.profileKey === profileKey && p.status === "pending"
  );

  // Delete each one
  for (const post of pendingPosts) {
    await fetch(`https://api.postcore.dev/posts/${post.postId}`, {
      method: "DELETE",
      headers: { "x-api-key": apiKey },
    });
  }

  console.log(`Deleted ${pendingPosts.length} pending posts`);
}

Bulk Delete with Confirmation

async function bulkDeletePosts(postIds) {
  const results = {
    deleted: [],
    failed: [],
  };

  for (const postId of postIds) {
    try {
      const response = await fetch(`https://api.postcore.dev/posts/${postId}`, {
        method: "DELETE",
        headers: { "x-api-key": apiKey },
      });

      if (response.ok) {
        results.deleted.push(postId);
      } else {
        const error = await response.json();
        results.failed.push({ postId, error: error.message });
      }
    } catch (error) {
      results.failed.push({ postId, error: error.message });
    }
  }

  console.log(`Deleted: ${results.deleted.length}`);
  console.log(`Failed: ${results.failed.length}`);
  return results;
}

Error Responses

Post Not Found

{
  "error": "POST_NOT_FOUND",
  "message": "Post not found"
}

Status: 404 Not Found

Common causes:

  • Invalid postId
  • Post was already deleted
  • Post belongs to a different account

Cannot Delete Published Post

{
  "error": "CANNOT_DELETE_PUBLISHED",
  "message": "Cannot delete published posts. Delete directly on the platform."
}

Status: 400 Bad Request

Solution: Published posts cannot be deleted via the API. You must delete them directly on LinkedIn or Bluesky.

Cannot Delete Failed Post

{
  "error": "CANNOT_DELETE_FAILED",
  "message": "Cannot delete failed posts. They remain for record-keeping."
}

Status: 400 Bad Request

Explanation: Failed posts remain in your records so you can see what went wrong. They don't count toward rate limits or affect future posts.

Invalid API Key

{
  "error": "INVALID_API_KEY",
  "message": "Invalid API key"
}

Status: 401 Unauthorized


Best Practices

Always Check Status First

Before attempting to delete, verify the post is pending:

const { post } = await fetch(`https://api.postcore.dev/posts/${postId}`, {
  headers: { "x-api-key": apiKey },
}).then((r) => r.json());

if (post.status === "pending") {
  // Safe to delete
  await deletePost(postId);
} else {
  console.log(`Cannot delete ${post.status} post`);
}

Handle Deletion Errors Gracefully

async function safeDelete(postId) {
  try {
    const response = await fetch(`https://api.postcore.dev/posts/${postId}`, {
      method: "DELETE",
      headers: { "x-api-key": apiKey },
    });

    if (!response.ok) {
      const error = await response.json();

      if (error.error === "CANNOT_DELETE_PUBLISHED") {
        return { success: false, reason: "already_published" };
      }

      if (error.error === "POST_NOT_FOUND") {
        return { success: false, reason: "not_found" };
      }

      throw new Error(error.message);
    }

    return { success: true };
  } catch (error) {
    console.error("Delete failed:", error);
    return { success: false, reason: "error", error };
  }
}

Provide User Feedback

async function deleteWithFeedback(postId) {
  const { post } = await fetch(`https://api.postcore.dev/posts/${postId}`, {
    headers: { "x-api-key": apiKey },
  }).then((r) => r.json());

  if (post.status === "published") {
    alert(
      "This post has already been published. Please delete it directly on " +
        post.platform
    );
    return;
  }

  if (
    confirm(
      `Delete this ${post.platform} post scheduled for ${post.scheduledFor}?`
    )
  ) {
    await fetch(`https://api.postcore.dev/posts/${postId}`, {
      method: "DELETE",
      headers: { "x-api-key": apiKey },
    });

    alert("Post deleted successfully");
  }
}