API Reference
Complete method reference for the Post2allClient class.
Constructor
import { Post2allClient } from "@post2all/sdk"
const client = new Post2allClient({
apiKey: "amp_your_api_key", // required
baseUrl: "https://www.post2all.com/api/v1", // optional, this is the default
fetchImplementation: fetch, // optional, custom fetch for testing
})| Option | Type | Required | Default |
|---|---|---|---|
apiKey | string | Yes | — |
baseUrl | string | No | https://www.post2all.com/api/v1 |
fetchImplementation | typeof fetch | No | Global fetch |
The API key is sent as the x-api-key header on every request.
listAccounts()
Returns all connected social media accounts for your organization.
const response = await client.listAccounts()Returns: ListAccountsResponse
{
accounts: {
id: string
platform: "twitter" | "linkedin" | "youtube" | "instagram" | "pinterest" | "threads"
platformAccountId: string
username: string | null
displayName: string | null
avatarUrl: string | null
status: string
supportedPostTypes: {
text: boolean
image: boolean
video: boolean
}
createdAt: string
}[]
}createPost()
Creates a text, image, or video post. Supports draft, scheduled, and immediate publishing with inline media upload.
const response = await client.createPost({
type: "text",
socialAccountIds: ["acc_123", "acc_456"],
content: "Hello world",
status: "scheduled",
scheduledAt: "2026-06-20T09:00:00Z",
mediaPaths: ["./photo.jpg"],
accountSettings: {
acc_123: { caption: "Custom caption" },
},
})Input: CreatePostInput
| Field | Type | Required | Description |
|---|---|---|---|
type | "text" | "image" | "video" | Yes | Post content type |
socialAccountIds | string[] | Yes | Account IDs to post to (from listAccounts) |
content | string | No | Post content text. Required for text posts |
status | "draft" | "scheduled" | No | Default: "scheduled" (publishes immediately if no scheduledAt) |
scheduledAt | string (ISO 8601) | No | Schedule date. Required if status is "scheduled" |
mediaPaths | string[] | No | Local file paths for image/video posts |
accountSettings | Record<string, Record<string, unknown>> | No | Per-account content overrides |
Returns: CreatePostResponse
{
post: {
id: string
type: string
content: string | null
status: string
scheduledAt: string | null
createdAt: string
mediaCount?: number
accountCount?: number
}
}Notes
- Image/video posts require
mediaPathsor content — provide at least one - Drafts don't trigger publishing and don't count against limits
- Scheduled without
scheduledAtpublishes immediately (API defaults to now) - Media files are read from local disk and uploaded inline in the request
listPosts()
Lists posts with pagination and optional filters.
const response = await client.listPosts({
page: 1,
limit: 20,
status: "published",
type: "text",
})Input: ListPostsInput (all optional)
| Field | Type | Description |
|---|---|---|
page | number | Page number (default: 1) |
limit | number | Items per page (default: 20, max: 100) |
status | "draft" | "scheduled" | "published" | "partially_failed" | "failed" | Filter by status |
type | "text" | "image" | "video" | Filter by type |
Returns: ListPostsResponse
{
posts: {
id: string
type: string
content: string | null
status: string
scheduledAt: string | null
publishedAt: string | null
createdAt: string
accounts: {
id: string | null
platform: string
username: string | null
displayName: string | null
disconnected: boolean
status: string
platformPostUrl: string | null
error: string | null
}[]
}[]
pagination: {
page: number
limit: number
hasMore: boolean
}
}getPost()
Returns full details for a single post including per-account publish status.
const response = await client.getPost("post_abc")Parameters: postId: string
Returns: GetPostResponse
{
post: {
id: string
type: string
content: string | null
media?: { type: string, path: string }[]
status: string
scheduledAt: string | null
publishedAt: string | null
createdAt: string
updatedAt: string | null
accounts: {
id: string | null
platform: string
platformAccountId: string | null
username: string | null
displayName: string | null
avatarUrl: string | null
disconnected: boolean
status: string
platformPostId: string | null
platformPostUrl: string | null
error: string | null
publishedAt: string | null
}[]
}
}updatePost()
Updates a draft or scheduled post. All fields are optional — only provided fields are updated.
const response = await client.updatePost("post_abc", {
content: "Updated content",
scheduledAt: "2026-06-21T10:00:00Z",
})Parameters
| Param | Type | Description |
|---|---|---|
postId | string | Post ID to update |
input | UpdatePostInput | Fields to update |
Input: UpdatePostInput (all optional)
| Field | Type | Description |
|---|---|---|
type | "text" | "image" | "video" | New post type |
content | string | New content |
socialAccountIds | string[] | New target accounts |
status | "draft" | "scheduled" | New status |
scheduledAt | string (ISO 8601) | New schedule date |
accountSettings | Record<string, Record<string, unknown>> | New per-account settings |
Returns: UpdatePostResponse
{
post: {
id: string
type: string
content: string | null
status: string
scheduledAt: string | null
publishedAt: string | null
createdAt: string
updatedAt: string | null
}
}Only draft or scheduled posts can be updated. Published posts are immutable.
deletePost()
Permanently deletes a post. Cancels any pending publish schedule and removes associated media.
const response = await client.deletePost("post_abc")Parameters: postId: string
Returns: DeletePostResponse
{ success: true }cancelPost()
Moves a scheduled post back to draft status. Cancels the pending publish trigger.
const response = await client.cancelPost("post_abc")Parameters: postId: string
Returns: CancelPostResponse
{
post: {
id: string
type: string
content: string | null
status: "draft"
scheduledAt: string | null
createdAt: string
updatedAt: string | null
}
}Only works for posts with status: "scheduled".
Error Handling
All methods throw Post2allApiError on non-2xx responses:
import { Post2allApiError } from "@post2all/sdk"
try {
await client.createPost({ ... })
} catch (error) {
if (error instanceof Post2allApiError) {
error.status // HTTP status code
error.code // Error code (e.g., "INVALID_API_KEY")
error.message // Human-readable message
error.details // Raw API error body
}
}| Code | HTTP | Description |
|---|---|---|
INVALID_API_KEY | 401 | Missing or invalid API key |
EXPIRED_API_KEY | 401 | API key has expired |
RATE_LIMITED | 429 | Too many requests |
FORBIDDEN | 403 | Key doesn't have org access |
PLAN_UPGRADE_REQUIRED | 403 | Plan doesn't include API access |
INVALID_REQUEST | 400 | Malformed body or missing fields |
INVALID_ACCOUNTS | 400 | Account IDs don't belong to your org |
UNSUPPORTED_MEDIA | 400 | File type not image/* or video/* |
POST_NOT_FOUND | 404 | Post ID not found |
INTERNAL_ERROR | 500 | Server error |
CLI
The post2all CLI is built on this SDK. Install it with:
pnpm add -g @post2all/cli# Authenticate
post2all config set-key amp_xxx
# List accounts
post2all accounts
# Create a post
post2all post create \
--type text \
--accounts acc_1,acc_2 \
--content "Hello from CLI"
# List posts
post2all posts --status scheduled
# Cancel a scheduled post
post2all post cancel post_abcSee the CLI repository for full documentation and the SKILL.md for AI agent integration.