Twitter / X

Post tweets, threads, polls, and media to Twitter/X via the PostPeer API.

Overview

Publish tweets, threads, polls, and rich media to Twitter/X through a single API endpoint. PostPeer handles OAuth, token refreshes, and rate limits.

Quick Start

1. Connect a Twitter Account

curl https://api.postpeer.dev/v1/connect/twitter \
  -H "x-access-key: YOUR_API_KEY"

Response:

{
  "url": "https://twitter.com/i/oauth2/authorize?..."
}

Redirect the user to the url. After authorization, the account is connected to your project.

2. Get the Account ID

curl https://api.postpeer.dev/v1/connect/integrations \
  -H "x-access-key: YOUR_API_KEY"

Find the integration with "platform": "twitter" and note the id.

3. Post a Tweet

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hello from PostPeer!",
    "platforms": [
      { "platform": "twitter", "accountId": "abc123" }
    ],
    "publishNow": true
  }'

Response:

{
  "success": true,
  "status": "published",
  "postId": "post_xyz789",
  "platforms": [
    {
      "platform": "twitter",
      "success": true,
      "platformPostUrl": "https://twitter.com/you/status/123456"
    }
  ]
}

Features

Text Posts

Post a standard tweet with up to 280 characters.

Images & Videos

Attach media using the mediaItems array:

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Check out this photo!",
    "platforms": [
      { "platform": "twitter", "accountId": "abc123" }
    ],
    "mediaItems": [
      { "type": "image", "url": "https://example.com/photo.jpg" }
    ],
    "publishNow": true
  }'

Supported media:

  • Images: JPG, PNG, GIF, WebP (up to 4 per tweet)
  • Videos: MP4 (1 per tweet)
  • GIFs: animated GIF (1 per tweet)

Threads

Create multi-tweet threads using platformSpecificData.threadItems:

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "1/ Here'\''s a thread about our API...",
    "platforms": [
      {
        "platform": "twitter",
        "accountId": "abc123",
        "platformSpecificData": {
          "threadItems": [
            { "text": "2/ Connect any social account via OAuth" },
            { "text": "3/ Post to all platforms with one request" }
          ]
        }
      }
    ],
    "publishNow": true
  }'

Polls

Create polls with 2-4 options:

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "What should we build next?",
    "platforms": [
      {
        "platform": "twitter",
        "accountId": "abc123",
        "platformSpecificData": {
          "poll": {
            "options": ["Analytics", "Webhooks", "Bulk upload"],
            "durationMinutes": 1440
          }
        }
      }
    ],
    "publishNow": true
  }'

Reply Settings

Control who can reply using platformSpecificData.replySettings:

  • "everyone" (default)
  • "following"
  • "mentionedUsers"

Limits

LimitValue
Character limit280 per tweet
Images per tweet4
Videos per tweet1
Thread lengthNo hard limit
Poll options2-4

On this page