How to Post to Twitter/X
from OpenClaw
Give your OpenClaw agent the ability to create, schedule, and publish tweets on X through OpenTweet's REST API or MCP server. One API key, no X developer account.
Set up in 5 minutes • Free 7-day trial
Why Post to Twitter from OpenClaw?
OpenClaw is an open-source framework that lets AI agents use skills to perform tasks. Your agent already has a personality defined in its SOUL.md file and can run on cron schedules. The one thing it cannot do out of the box is post to X, because X requires authenticated API access that is painful to set up yourself.
OpenTweet closes that gap. Your agent calls a simple REST endpoint or uses the OpenTweet MCP server, and posting a tweet becomes a single tool call. You connect your X account to OpenTweet once, generate an API key, and your agent handles the rest. No X developer application, no OAuth dance in your agent code, no token refresh logic to maintain.
The result is a fully autonomous posting loop: a cron trigger fires, your agent generates tweet content based on its SOUL.md personality, and the tweet goes out through the OpenTweet API. You define the schedule and the prompts, the agent does the work.
Step-by-Step: Tweet from OpenClaw
Set Up Your OpenClaw Agent
OpenClaw is an open-source framework that lets AI agents use skills to perform tasks. Your agent's personality and behavior live in its SOUL.md file, and skills are defined in SKILL.md files that the agent reads to understand what it can do. Get your agent running first, then add Twitter posting as a skill. Everything from here on is a single config file and one API key.
Get Your OpenTweet API Key
Sign up for OpenTweet (free 7-day trial on all plans), connect your X account once, then go to Settings > API Keys to generate a key. Set it as the OPENTWEET_API_KEY environment variable in your agent runtime. Never paste the raw ot_ key into your config files. If your repo is public, anyone can use a hardcoded key. You can revoke or rotate the key at any time from your dashboard.
Add a Twitter Posting Skill
Create a SKILL.md file with YAML frontmatter (name and description are required) and document the OpenTweet endpoints: GET /api/v1/me to verify the connection, POST /api/v1/posts to create tweets, GET /api/v1/posts to list them. All requests use the base URL https://opentweet.io/api/v1 with an Authorization: Bearer header. Your agent reads this file and knows exactly how to post.
Or Connect via the MCP Server
If your setup supports the Model Context Protocol, run npx opentweet-mcp instead of writing REST calls yourself. The MCP server exposes ready-made tools for creating tweets, scheduling posts, managing threads, controlling your evergreen queue, and checking analytics. It works with Claude, Cursor, OpenClaw, and any MCP-compatible framework, and it authenticates with the same OpenTweet API key.
Schedule Posting with Cron
OpenClaw uses cron schedules to trigger AI agents at set intervals. Add cron entries to your config, each pairing a cron expression with a prompt. For example, "0 9 * * 1-5" triggers every weekday at 9 AM. You can add multiple entries with different prompts, one for morning industry insights and another for evening engagement posts. Use our free cron builder to generate the config visually.
Validate and Let It Run
Before going autonomous, verify the connection with GET /api/v1/me and run your SKILL.md through our free OpenClaw config validator, which checks frontmatter, auth headers, base URLs, hardcoded keys, and rate limit awareness. Once everything passes, your agent generates tweet content based on its SOUL.md personality and posts to X through OpenTweet, fully automated.
The Two Ways to Connect
Option 1: REST API
Document this in your SKILL.md and your agent posts with one request.
curl -X POST https://opentweet.io/api/v1/posts \
-H "Authorization: Bearer $OPENTWEET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello from my OpenClaw agent"}'Option 2: MCP Server
Add the OpenTweet MCP server and your agent gets ready-made tweet tools.
{
"mcpServers": {
"opentweet": {
"command": "npx",
"args": ["opentweet-mcp"],
"env": {
"OPENTWEET_API_KEY": "ot_your_key"
}
}
}
}What Your OpenClaw Agent Can Do
Posting & Scheduling
- Post tweets with a single API call
- Create and schedule multi-tweet threads
- Run on cron schedules you define
- Generate content from its SOUL.md personality
- Draft tweets for review before publishing
- Post without an X developer account
Management & Analytics
- Verify the connection with GET /api/v1/me
- List drafts and scheduled posts
- Manage your evergreen content queue via MCP
- Check posting analytics via MCP tools
- Rotate or revoke API keys from the dashboard
- Stay within the 60 requests/minute rate limit
Pro Tips for OpenClaw + Twitter
Use Environment Variables for the Key
Reference OPENTWEET_API_KEY as an environment variable in your SKILL.md and set the actual ot_ key in your agent runtime. Hardcoding keys in config files is the most common security mistake in agent setups. If your skill files ever end up in a public repo, a hardcoded key means anyone can post as you.
Split Content Types Across Cron Entries
Instead of one generic posting prompt, add multiple cron entries with focused prompts. One at 9 AM for industry insights, another at 5 PM for engagement posts. Each entry pairs its own schedule with its own prompt, so your agent produces varied content instead of repeating the same angle every day.
Document Rate Limits in Your Skill
The OpenTweet API is rate-limited to 60 requests per minute. Add a rate limit section to your SKILL.md so the agent paces itself. Agents that fire requests blindly get throttled with 429 errors. A single sentence in the skill file prevents the whole class of problem.
Verify the Connection Before Posting
Make GET /api/v1/me the first step in your skill workflow. It confirms the API key is valid and the X account is connected before the agent tries to publish anything. A failed verification up front is a clear error message. A failed post mid-run is a silent gap in your content calendar.
Common Mistakes to Avoid
Hardcoding the API Key
Pasting your actual ot_ key into SKILL.md or any config file is a security risk. If your repo is public, anyone can use your key to post from your account. Always reference OPENTWEET_API_KEY as an environment variable and set it in your agent runtime. Our config validator flags this automatically.
Using the Wrong Base URL
Localhost, staging URLs, or incorrect paths will cause every API call to fail when deployed. Always use https://opentweet.io/api/v1 as the base URL for all endpoints. This is the single most common reason an OpenClaw Twitter skill works in testing and breaks in production.
Skipping the Auth Header
Every API request needs a Bearer token. Without it, the API returns 401 Unauthorized and your agent has no way to post. Document the header exactly as Authorization: Bearer followed by your key reference, so the agent includes it on every request without guessing.
Mismatched Timezones on Cron
The timezone of your cron schedule depends on your server or OpenClaw deployment configuration, not your local clock. If your agent posts at 9 AM UTC when you meant 9 AM Eastern, your tweets land at the wrong time every single day. Confirm the deployment timezone before trusting the schedule.
Frequently Asked Questions
What is OpenClaw?
OpenClaw is an open-source framework that lets AI agents use skills to perform tasks. A Twitter posting skill lets your AI agent create and publish tweets autonomously via the OpenTweet API. The agent's personality lives in a SOUL.md file, and cron schedules trigger it at set intervals.
Does my OpenClaw agent need an X developer account to post?
No. Your agent posts through OpenTweet's REST API or MCP server using an OpenTweet API key (ot_ prefix). OpenTweet handles the connection to X, so you skip the X developer application entirely. Connect your X account to OpenTweet once, then your agent posts with a single API call.
How does OpenClaw post tweets on a schedule?
OpenClaw uses cron schedules to trigger AI agents at set intervals. When triggered, the agent generates tweet content based on its SOUL.md personality and posts via the OpenTweet API. You can add multiple cron entries, each with a different schedule and prompt, for example one at 9 AM for industry insights and another at 5 PM for engagement posts.
Should I use the REST API or the MCP server?
Both work. The REST API is the simplest: document the endpoints in a SKILL.md file and your agent posts with a single HTTP request. The MCP server (npx opentweet-mcp) gives your agent ready-made tools for tweets, threads, scheduling, evergreen queues, and analytics, and it works with Claude, Cursor, OpenClaw, and any MCP-compatible framework.
How much does it cost to post from OpenClaw?
OpenTweet plans start at $11.99/month for Pro, which includes API access and MCP server support. Advanced is $29/month and Agency is $49/month for multiple X accounts. All plans include a 7-day free trial. OpenClaw itself is open source.
What are the API rate limits?
The OpenTweet API is rate-limited to 60 requests per minute. Document this in your SKILL.md so the agent paces itself and avoids 429 errors. For normal posting schedules of a few tweets per day, you will never come close to the limit.
Start Tweeting from OpenClaw
Set up in 5 minutes. Free 7-day trial. No X developer account needed.