Posts
Get Post by ID
Get details for a specific post by ID
Endpoint
GET /posts/:postIdRequest
curl https://api.postcore.dev/posts/post_abc123 \
-H "x-api-key: YOUR_API_KEY"const response = await fetch(
`https://api.postcore.dev/posts/${postId}`,
{
headers: {
'x-api-key': process.env.POSTCORE_API_KEY
}
}
);
const { post } = await response.json();
console.log(`Post status: ${post.status}`);import os
import requests
response = requests.get(
f'https://api.postcore.dev/posts/{post_id}',
headers={'x-api-key': os.getenv('POSTCORE_API_KEY')}
)
post = response.json()['post']
print(f"Post status: {post['status']}")Response
{
"post": {
"postId": "post_abc123",
"profileKey": "prof_abc123",
"platform": "linkedin",
"content": "Excited to announce our new feature! 🚀",
"scheduledFor": "2025-01-15T14:00:00Z",
"createdAt": "2025-01-08T12:00:00Z",
"publishedAt": "2025-01-15T14:00:12Z",
"status": "published",
"platformUrl": "https://linkedin.com/feed/update/urn:li:share:123456789"
}
}Status Code: 200 OK
Response Fields
| Field | Type | Description |
|---|---|---|
postId | string | Unique post identifier |
profileKey | string | Associated profile |
platform | string | Platform name |
content | string | Post content |
scheduledFor | string | Scheduled publish time |
createdAt | string | When post was created |
publishedAt | string | null | When post was published |
status | string | "pending", "published", or "failed" |
platformUrl | string | null | URL to post on platform |
Use Cases
Check Publishing Status
Poll a post to see if it's been published:
async function waitForPublish(postId) {
const maxAttempts = 10;
const delayMs = 5000; // 5 seconds
for (let i = 0; i < maxAttempts; i++) {
const { post } = await fetch(`https://api.postcore.dev/posts/${postId}`, {
headers: { "x-api-key": apiKey },
}).then((r) => r.json());
if (post.status === "published") {
console.log("Post published!", post.platformUrl);
return post;
}
if (post.status === "failed") {
console.error("Post failed to publish");
return post;
}
// Still pending, wait and try again
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
throw new Error("Timeout waiting for post to publish");
}Get Platform URLs After Publishing
const { post } = await fetch(`https://api.postcore.dev/posts/${postId}`, {
headers: { "x-api-key": apiKey },
}).then((r) => r.json());
if (post.status === "published" && post.platformUrl) {
// Share the link
console.log(`View on ${post.platform}: ${post.platformUrl}`);
// Or display in your UI
const link = document.createElement("a");
link.href = post.platformUrl;
link.textContent = `View on ${post.platform}`;
}Verify Post Before Deleting
async function deletePostSafely(postId) {
// First, check the post status
const { post } = await fetch(`https://api.postcore.dev/posts/${postId}`, {
headers: { "x-api-key": apiKey },
}).then((r) => r.json());
if (post.status === "published") {
console.error("Cannot delete published post");
return false;
}
if (post.status === "pending") {
// Safe to delete
await fetch(`https://api.postcore.dev/posts/${postId}`, {
method: "DELETE",
headers: { "x-api-key": apiKey },
});
console.log("Post deleted");
return true;
}
}Error Responses
Post Not Found
{
"error": "POST_NOT_FOUND",
"message": "Post not found"
}Status: 404 Not Found
Common causes:
- Invalid
postId - Post was deleted
- Post belongs to a different account
- Typo in the postId parameter
Invalid API Key
{
"error": "INVALID_API_KEY",
"message": "Invalid API key"
}Status: 401 Unauthorized
Comparison with List Posts
| Use Case | Best Endpoint |
|---|---|
| Get all posts | GET /posts |
| Check one post's status | GET /posts/:postId |
| Find posts by criteria | GET /posts + filter |
| Get published URLs | GET /posts/:postId |
| Build a dashboard | GET /posts |
Generally, use GET /posts/:postId when you already have the post ID and need to check its current state or get the platform URL after publishing.