Install
npm install @autoposting.ai/sdk
fetch (Node.js 20+). ESM and CJS builds included.
Quick Start
import { Autoposting } from '@autoposting.ai/sdk'
const client = new Autoposting({ apiKey: 'sk-social-...' })
// Create and publish a post
const post = await client.posts.create({
brandSlug: 'my-brand',
text: 'Hello from the SDK!',
platforms: ['x', 'linkedin'],
})
await client.posts.publish(post.id)
Configuration
const client = new Autoposting({
apiKey: 'sk-social-...', // required
baseUrl: 'https://app.autoposting.ai/api-proxy', // optional — this is the default (the /api-proxy path; the bare host serves the dashboard, not the API)
timeout: 30000, // optional — request timeout in ms
})
Resources
| Resource | Methods |
|---|---|
client.posts | list · getById · create · update · remove · publish · schedule · unschedule · retry · rewrite · score |
client.media | upload |
client.brands | list · retrieve · create · update · remove · authStatus |
client.agents | list · retrieve · create · update · remove · run · toggle · runs |
client.kb | list · retrieve · create · remove · search · ingestUrl · docs |
client.ideas | list · generate · enrich · remove |
client.clips | list · retrieve · upload · importUrl · render · remove |
client.carousels | list · retrieve · create · generate · draft · remove |
client.webhooks | list · retrieve · create · update · remove · test |
client.billing | status · credits |
client.usage | summary |
client.workspaces | list · switchWorkspace |
Usage Examples
Post Scheduling
const posts = await client.posts.list({ status: 'scheduled' })
const post = await client.posts.create({
brandSlug: 'my-brand',
text: 'Check out our latest blog post!',
platforms: ['x', 'linkedin', 'threads'],
scheduledAt: '2026-02-01T14:00:00Z',
})
// AI-rewrite for better engagement
await client.posts.rewrite(post.id)
// Get AI score and feedback
const score = await client.posts.score(post.id)
AI Agents
const agent = await client.agents.create({
name: 'Daily Tech News',
type: 'publish',
brandSlug: 'my-brand',
prompt: 'Write a short post about the latest AI news',
frequency: 'daily',
time: '09:00',
})
await client.agents.run(agent.id)
const runs = await client.agents.runs(agent.id)
Knowledge Base
const kb = await client.kb.create({ name: 'Product Docs' })
await client.kb.ingestUrl(kb.id, 'https://docs.example.com')
const results = await client.kb.search(kb.id, 'pricing')
Carousels
const carousel = await client.carousels.generate({
topic: '5 Tips for Social Media Growth',
brandSlug: 'my-brand',
slideCount: 5,
})
await client.carousels.draft(carousel.id)
Webhooks
const webhook = await client.webhooks.create({
url: 'https://api.example.com/webhook',
events: ['post.published', 'post.failed'],
})
await client.webhooks.test(webhook.id)
Error Handling
The SDK throws typed errors you can catch by class:import {
AutopostingError, // base class
AuthenticationError, // 401 — invalid API key
ScopeError, // 403 — insufficient API key scopes
NotFoundError, // 404 — resource not found
ValidationError, // 400/422 — invalid input
RateLimitError, // 429 — rate limited
ServerError, // 5xx — server error
} from '@autoposting.ai/sdk'
try {
await client.posts.getById('nonexistent')
} catch (err) {
if (err instanceof NotFoundError) {
console.log('Post not found:', err.message)
}
if (err instanceof RateLimitError) {
console.log('Rate limited, retry after:', err.message)
}
}
Auth Priority (when using with CLI)
--api-key flag > AUTOPOSTING_API_KEY env > stored credentials
API Reference
Full endpoint reference with auth and error codes.
MCP Server
Let AI agents use the SDK via 51 MCP tools.
CLI
Terminal access with 61 commands.
npm
View on npm registry.

