Skip to main content

Examples & recipes

Copy-paste recipes for common tasks. Replace <your-api-origin> and the API key with your own. Set the key as an env var to avoid pasting it inline.

export POSTBUZZ_API_KEY="gx_live_YOUR_API_KEY"
export POSTBUZZ_ORIGIN="https://api.your-deployment.example.com"

List your connected accounts

curl "$POSTBUZZ_ORIGIN/api/v1/accounts" \
-H "Authorization: Bearer $POSTBUZZ_API_KEY"

Grab an id from the response to use as accountId below.

Create a draft post

curl -X POST "$POSTBUZZ_ORIGIN/api/v1/posts" \
-H "Authorization: Bearer $POSTBUZZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"caption": "Starting a draft — coming soon.",
"accountIds": ["acc_abc123"]
}'

No scheduledAt, so this saves as a draft.

Schedule a cross-post

curl -X POST "$POSTBUZZ_ORIGIN/api/v1/posts" \
-H "Authorization: Bearer $POSTBUZZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"caption": "Shipping today 🚀",
"accountIds": ["acc_instagram", "acc_x"],
"accountOverrides": [
{ "accountId": "acc_x", "captionOverride": "Shipping today." }
],
"scheduledAt": "2026-07-15T14:30:00Z"
}'

Create a post with media

curl -X POST "$POSTBUZZ_ORIGIN/api/v1/posts" \
-H "Authorization: Bearer $POSTBUZZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"caption": "Behind the scenes",
"postType": "reel",
"accountIds": ["acc_instagram"],
"mediaIds": ["med_01"]
}'

List posts with pagination

curl "$POSTBUZZ_ORIGIN/api/v1/posts?limit=10&offset=0" \
-H "Authorization: Bearer $POSTBUZZ_API_KEY"

Delete a scheduled post

curl -X DELETE "$POSTBUZZ_ORIGIN/api/v1/posts/pst_abc123" \
-H "Authorization: Bearer $POSTBUZZ_API_KEY"

JavaScript: a small API client

class PostbuzzClient {
constructor(origin, apiKey) {
this.origin = origin;
this.apiKey = apiKey;
}

async request(path, init = {}) {
const res = await fetch(`${this.origin}${path}`, {
...init,
headers: {
Authorization: `Bearer ${this.apiKey}`,
"Content-Type": "application/json",
...init.headers,
},
});
if (!res.ok) {
const body = await res.json().catch(() => ({}));
throw new Error(`${res.status}: ${body.error ?? res.statusText}`);
}
return res.status === 204 ? null : res.json();
}

listAccounts() {
return this.request("/api/v1/accounts");
}

listPosts({ limit = 25, offset = 0 } = {}) {
const q = new URLSearchParams({ limit, offset });
return this.request(`/api/v1/posts?${q}`);
}

createPost(post) {
return this.request("/api/v1/posts", {
method: "POST",
body: JSON.stringify(post),
});
}

deletePost(id) {
return this.request(`/api/v1/posts/${id}`, { method: "DELETE" });
}
}

// Usage
const client = new PostbuzzClient(
process.env.POSTBUZZ_ORIGIN,
process.env.POSTBUZZ_API_KEY,
);

const { data: accounts } = await client.listAccounts();
const { id } = await client.createPost({
caption: "Posted from my script",
accountIds: [accounts[0].id],
scheduledAt: new Date(Date.now() + 3_600_000).toISOString(), // +1h
});
console.log("Scheduled:", id);