Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to Twitter / X

Scalekit connector
Open markdown

The Twitter / X connector lets your AI agent act in each user's Twitter / X account. Each user connects their own Twitter / X access token once, and Scalekit sends it with every call, so your agent never handles credentials. Your agent calls the Twitter / X API as the user through Scalekit's API proxy.

Tools
104
What they doRead · write · destructive
62 · 35 · 762 read35 write7 destructive
Users sign in with

What you can do

  • Publish posts: create and delete posts with media, polls, and replies, and publish long-form articles
  • Search posts: search recent or full-archive posts with X search syntax and count matching results
  • Read timelines and mentions: fetch the home timeline, a user’s posts, their mentions, and list timelines
  • Engage with posts: like, repost, and bookmark posts, and see who liked, reposted, or quoted them
  • Send direct messages: message users and group conversations, and read conversation history
  • Manage follows and lists: follow, mute, and look up users, and create and curate lists

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the Twitter / X connection

    In AgentKit > Connections, create a Twitter / X connection. The name you give it is the connection_name your code passes. See Configure connections.

    Console steps with screenshots

    Register your Twitter app credentials with Scalekit so it can manage the OAuth 2.0 authentication flow and token lifecycle on your behalf. You’ll need a Client ID and Client Secret from the Twitter Developer Portal.

    1. Create a Twitter connection in Scalekit

      • In Scalekit dashboard, go to AgentKit > Connections > Create Connection. Search for Twitter and click Create.

        Search for Twitter and create a new connection in Scalekit Agent Auth

      • In the Configure Twitter Connection panel, copy the Redirect URI. It looks like https://<SCALEKIT_ENVIRONMENT_URL>/sso/v1/oauth/<CONNECTION_ID>/callback. You’ll paste this into Twitter in the next step.

        Copy the Redirect URI from the Configure Twitter Connection panel

    2. Create an app in the Twitter Developer Portal

      • Go to the Twitter Developer Portal and sign in.

      • Click + Add App (or + Create Project to group apps by environment).

        Twitter Developer Portal showing Projects and Apps with the Add App button

      • Select Production environment and give your app a name.

    3. Configure user authentication settings

      • In your app’s overview, find User authentication settings and click Set up.

        Twitter app User authentication settings panel

      • Set the following values:

        SettingValue
        App permissionsRead and Write — needed to post and manage content on behalf of users
        Type of AppWeb App, Automated App or Bot
        Callback URI / Redirect URLPaste the Redirect URI from Scalekit
        Website URLYour application’s public homepage
      • Click Save.

    4. Copy OAuth 2.0 credentials

      • In your app, navigate to Keys and tokens.

      • Under OAuth 2.0 Client ID and Client Secret, click Generate (or Regenerate if credentials already exist).

      • Copy the Client ID and Client Secret.

        Twitter app Keys and tokens page showing Client ID and Client Secret

    5. Add credentials in Scalekit

      • In Scalekit dashboard, go to AgentKit > Connections and open the Twitter connection you created.

      • Enter your credentials:

        • Client ID — from the Twitter OAuth 2.0 section
        • Client Secret — copied in the previous step
        • Scopes — select the permissions your app needs:
          • tweet.read — read tweets and timelines
          • tweet.write — create, delete, and manage tweets
          • users.read — read user profile data
          • follows.read — read follower/following lists
          • follows.write — follow and unfollow users
          • like.read — read liked tweets
          • like.write — like and unlike tweets
          • bookmark.read — read bookmarked tweets
          • bookmark.write — add and remove bookmarks
          • list.read — read list membership and tweets
          • list.write — create, update, and delete lists
          • dm.read — read direct messages
          • dm.write — send direct messages
          • mute.read — read muted users
          • mute.write — mute and unmute users
          • block.read — read blocked users
          • block.write — block and unblock users
          • offline.access — obtain refresh tokens for long-lived access

        Scalekit Twitter connection with Client ID, Client Secret, and scopes configured

      • Click Save.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'twitter'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Twitter / X:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'twitter_user_me',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user opens the link once and enters their Twitter / X credentials there. If your app already has a user's credentials, add the account from your backend instead, as the console steps above show. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • twitter_activity_subscriptions_listList existing X activity subscriptions for the authenticated app.Read-only

    List Activity Subscriptions

    List existing X activity subscriptions for the authenticated app. Complements Create Activity Subscription, which only covers creating new subscriptions on this same resource.

    Inputs

    This tool takes no inputs.

  • twitter_blocked_users_getRetrieves the authenticated user's block list.Read-only

    Get Blocked Users

    Retrieves the authenticated user's block list. The id parameter must be the authenticated user's ID. Use Get Authenticated User action first to obtain your user ID.

    Inputs

    idstringrequired
    Authenticated user's Twitter ID — must match the authenticated user
    expansionsstring
    Comma-separated expansions
    max_resultsinteger
    Max results per page (1-1000)
    pagination_tokenstring
    Pagination token for next page
    user_fieldsstring
    Comma-separated user fields
  • twitter_bookmarks_getRetrieves Tweets bookmarked by the authenticated user.Read-only

    Get Bookmarks by User

    Retrieves Tweets bookmarked by the authenticated user. The provided User ID must match the authenticated user's ID.

    Inputs

    idstringrequired
    Authenticated user's Twitter ID
    expansionsstring
    Comma-separated expansions
    max_resultsinteger
    Max results per page (1-100)
    pagination_tokenstring
    Pagination token for next page
    tweet_fieldsstring
    Comma-separated tweet fields
  • twitter_community_getGet details of an X Community by its ID: name, description, access type, join policy, and member count.Read-only

    Get Community by ID

    Get details of an X Community by its ID: name, description, access type, join policy, and member count.

    Inputs

    idstringrequired
    Community ID to look up
    community_fieldsstring
    Comma-separated Community fields to include, e.g. access,created_at,description,member_count,name
  • twitter_compliance_job_getRetrieves status, download/upload URLs, and other details for an existing Twitter compliance job specified by its unique ID.Read-only

    Retrieve Compliance Job by ID

    Retrieves status, download/upload URLs, and other details for an existing Twitter compliance job specified by its unique ID.

    Inputs

    idstringrequired
    Compliance job ID
  • twitter_compliance_jobs_listReturns a list of recent compliance jobs, filtered by type (tweets or users) and optionally by status.Read-only

    Retrieve Compliance Jobs

    Returns a list of recent compliance jobs, filtered by type (tweets or users) and optionally by status.

    Inputs

    typestringrequired
    Type of compliance jobs to listone of tweetsusers
    statusstring
    Filter by job statusone of createdin_progressfailedcomplete
  • twitter_dm_conversation_events_getFetches Direct Message (DM) events for a one-on-one conversation with a specified participant ID, ordered chronologically newest to oldest.Read-only

    Get DM Events for a DM Conversation

    Fetches Direct Message (DM) events for a one-on-one conversation with a specified participant ID, ordered chronologically newest to oldest. Does not support group DMs.

    Inputs

    participant_idstringrequired
    User ID of the DM conversation participant
    dm_event_fieldsstring
    Comma-separated DM event fields
    event_typesstring
    Filter by event types
    expansionsstring
    Comma-separated expansions
    max_resultsinteger
    Max results per page (1-100)
    pagination_tokenstring
    Pagination token for next page

Workflows

Proxy API call
const me = await actions.request({
connectionName: 'twitter',
identifier: 'user_123',
path: '/2/users/me',
method: 'GET',
params: { 'user.fields': 'name,username,profile_image_url,description' },
});
console.log('Authenticated user:', me);
// Example: post a tweet
const tweet = await actions.request({
connectionName: 'twitter',
identifier: 'user_123',
path: '/2/tweets',
method: 'POST',
body: { text: 'Hello from Scalekit Agent Auth!' },
});
console.log('Posted tweet:', tweet);
// Example: search recent tweets
const search = await actions.request({
connectionName: 'twitter',
identifier: 'user_123',
path: '/2/tweets/search/recent',
method: 'GET',
params: { query: 'from:twitterdev', max_results: '10' },
});
console.log('Search results:', search);
Execute a tool
const result = await actions.executeTool({
connector: 'twitter',
identifier: 'user_123',
toolName: 'twitter_blocked_users_get',
toolInput: {
id: '<YOUR_USER_ID>', // use the id from /2/users/me
},
});
console.log(result);