# How to Post to Social Media with CrewAI (2026) · PostLake > Markdown version of https://postlake.dev/guides/crewai . The canonical page for humans. > PostLake is the social media API for AI agents: https://postlake.dev/llms.txt Post to social media with *CrewAI*. Share one PostLake tool across the crew (or MCP). Publishing stays one call; the normalised response is what the next agent reasons over. **In short:** One CrewAI tool → PostLake publish. Next agents in the crew read the same targets[] shape. ## When this guide is for you A CrewAI crew needs a publisher role (research → write → post) without each agent speaking a different social API. ## Before you start Same setup the [docs quickstart](https://docs.postlake.dev/quickstart.md) uses. Do this once: - Sign up at [app.postlake.dev](https://app.postlake.dev) and verify your email (unlocks free credits). - On **Channels**, create a **profile** (e.g. `my-brand`) and connect at least one account. **Bluesky is the fastest first channel**: no app review. Instagram/TikTok/Facebook need each platform's review before API posting. - Account menu → **API Keys** → create a key (`sk_live_…`). It shows once; treat it like a password. ## Working example in CrewAI Connect accounts once in the dashboard, then this is the publish call: ``` from crewai.tools import tool import os, requests, uuid @tool("Post to social") def post_to_social(text: str) -> str: """Publish to the my-brand profile via PostLake. Returns JSON text.""" r = requests.post( "https://api.postlake.dev/v1/posts", headers={ "Authorization": f"Bearer {os.environ['POSTLAKE_API_KEY']}", "Idempotency-Key": str(uuid.uuid4()), }, json={"text": text, "profile": "my-brand"}, ) r.raise_for_status() return r.text # full Post JSON for the next agent # Agent(role="Publisher", tools=[post_to_social], ...) ``` ## Step by step 1. Connect accounts under one profile the Publisher agent is allowed to use. 1. Add one tool that POSTs `/v1/posts` and returns the response body so downstream agents can parse `targets`. 1. Attach the tool only to the publisher role, keep researchers read-only. 1. Or connect [MCP](https://docs.postlake.dev/mcp) and skip the custom tool entirely. ## Read the response (don't skip this) You get one `Post` with an overall `state` and a `targets[]` array. One entry per account. **Always check each target**; partial success is normal. ``` { "id": "post_a1b2c3", "state": "partial", "targets": [ { "platform": "bluesky", "state": "published", "url": "https://bsky.app/…" }, { "platform": "linkedin", "state": "failed", "error": { "type": "invalid_request", "message": "…", "retryable": false } } ] } ``` - `published`: every target succeeded. `partial`: some published, some failed. `failed`: none published. `processing`: still going (async networks like TikTok). - **You're only charged for targets that actually publish.** Failed targets cost nothing. - Send an `Idempotency-Key` header on writes so a retry never double-posts. - Full detail: [Publishing](https://docs.postlake.dev/publishing) · [Errors & retries](https://docs.postlake.dev/errors) ## Where the post goes Same rules as the docs. Pick one addressing style: - **By profile**: `"profile": "my-brand"` posts to every account under that profile (the name on Channels). - **Filter networks**: `"platforms": ["bluesky", "linkedin"]` narrows that set. It is a **filter, not a selector**: if you have two Pinterest boards, both match `pinterest`. - **By account id**: `"accounts": ["acc_…"]` for exact channels (copy an id on Channels, or `GET /v1/social-accounts`). - One profile and you omit `profile`? PostLake uses that profile. Multiple profiles and you omit it? You'll get an error that names them. See [Publishing: where to post](https://docs.postlake.dev/publishing). ## Do more (same API) - **Schedule**: add `scheduledAt` as UTC (trailing `Z`), or a naive local time plus `timezone` (IANA, e.g. `Europe/London`). Credits charge when it fires. [Scheduling docs](https://docs.postlake.dev/scheduling) · [scheduling guide](/guides/schedule-posts-api). - **Media**: `POST /v1/media`, then pass the `med_…` id in `media`. [Media docs](https://docs.postlake.dev/media). - **Per-network caption**: `textOverrides` (e.g. shorter text for X). **Per-network options**: `platformOptions` (Pinterest `boardId`, TikTok privacy, …). Live option lists: `GET /v1/platforms/{platform}`. - **Validate first**: `POST /v1/posts/validate` runs the same checks without publishing (free). ## Pitfalls specific to this path - Crew retries need idempotency keys or you will double-post on task re-runs. - Returning only "success" hides partial failures from the next agent. - Free-tier X/TikTok limits still apply. The tool error will show on that target. Want zero wrapper code? Connect the hosted [MCP server](https://docs.postlake.dev/mcp) (`https://api.postlake.dev/mcp`) over OAuth. Same accounts and responses as this API path. [Agents overview](/agents/). ## Common questions ### How do I add social posting to a CrewAI agent? Pass a custom tool that calls PostLake /v1/posts (or enable MCP). Give it to the publisher agent. One tool covers every network on the profile. ### Does each agent need its own posting logic? No. Share one PostLake tool. Other agents should consume the JSON result, not call platform APIs. ### Can CrewAI use PostLake via MCP? Yes, when your CrewAI/MCP host supports it. Same server URL as the MCP docs. ## Go deeper in the docs These guides stay short on purpose. Canonical behaviour lives here: [Docs ### Quickstart Account, first channel, first post, MCP or API.](https://docs.postlake.dev/quickstart) [Docs ### Publishing Request body, addressing. Partial success, lifecycle.](https://docs.postlake.dev/publishing) [Docs ### Scheduling UTC or local time plus timezone, edit/cancel, fire-time credits.](https://docs.postlake.dev/scheduling) [Docs ### Platforms Limits, media rules, live platformOptions.](https://docs.postlake.dev/platforms) Also: [Media](https://docs.postlake.dev/media) · [Errors](https://docs.postlake.dev/errors) · [MCP](https://docs.postlake.dev/mcp) · [Analytics](https://docs.postlake.dev/analytics) ## Related guides - [Post with LangChain](https://postlake.dev/guides/langchain.md) - [Post with AutoGen](https://postlake.dev/guides/autogen.md) - [Build an AI social agent](https://postlake.dev/guides/ai-social-media-agent.md) - [Cross-platform analytics](https://postlake.dev/guides/social-media-analytics-api.md) [All guides](https://postlake.dev/guides/index.md) · [Full docs](https://docs.postlake.dev/) · [llms.txt](https://postlake.dev/llms.txt) Plain markdown for agents: https://postlake.dev/guides/crewai.md · https://postlake.dev/llms.txt