Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to Twitter / X (OAuth)

Scalekit connector
Open markdown

The Twitter / X (OAuth) connector lets your AI agent act in each user's Twitter / X (OAuth) account. Each user signs in to Twitter / X (OAuth) once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 92 tools.

Tools
92
What they doRead · write · destructive
52 · 34 · 652 read34 write6 destructive
Users sign in with
OAuth app
Scalekit's or your own

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 (OAuth) connection

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

    Scalekit credentials are available for Twitter / X, so you don't need to register an OAuth app. To show your own app on the consent screen, use your own credentials instead.

    Use your own OAuth app

    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 an app in the X Developer Console.

    1. Create a Twitter OAuth connection in Scalekit

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

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

    2. Choose or create an app in the X Developer Console

      • Go to the X Developer Console and sign in.

      • Under Access > Apps, either select an existing app or click + Create App.

        X Developer Console Create New Client Application dialog

    3. Configure user authentication settings

      • Open your app, go to Settings, and find User authentication settings.

      • 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

        X app authentication settings showing App permissions, Type of App, and Callback URI fields

      • Click Save.

    4. Copy OAuth 2.0 credentials

      • In your app, go to the Keys & Tokens tab.

      • Under OAuth 2.0 Keys, copy the Client ID. Click Regenerate next to Client Secret if you haven’t generated one yet, then copy it.

        X app Keys and Tokens tab with Consumer Key, Secret Key, and Bearer Token values redacted

    5. Add credentials in Scalekit

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

      • Enter your credentials:

        • Client ID — from the OAuth 2.0 Keys 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
      • 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 = 'twitteroauth'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Twitter / X (OAuth):', 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: 'twitteroauth_user_me',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user signs in once. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • twitteroauth_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.

  • twitteroauth_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
  • twitteroauth_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
  • twitteroauth_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
  • twitteroauth_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
  • twitteroauth_dm_conversation_retrieveRetrieves Direct Message (DM) events for a specific conversation ID on Twitter.Read-only

    Retrieve DM Conversation Events

    Retrieves Direct Message (DM) events for a specific conversation ID on Twitter. Useful for analyzing messages and participant activities.

    Inputs

    dm_conversation_idstringrequired
    DM conversation ID
    dm_event_fieldsstring
    Comma-separated DM event fields
    expansionsstring
    Comma-separated expansions
    max_resultsinteger
    Max results per page (1-100)
    pagination_tokenstring
    Pagination token for next page
  • twitteroauth_dm_event_getFetches a specific Direct Message (DM) event by its unique ID.Read-only

    Get DM Events by ID

    Fetches a specific Direct Message (DM) event by its unique ID. Allows optional expansion of related data like users or tweets.

    Inputs

    event_idstringrequired
    DM event ID
    dm_event_fieldsstring
    Comma-separated DM event fields
    expansionsstring
    Comma-separated expansions