Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to Twitter / X (Bearer Token)

Scalekit connector
Open markdown

The Twitter / X (Bearer Token) connector lets your AI agent act in each user's Twitter / X (Bearer Token) account. Each user connects their own Twitter / X (Bearer Token) access token once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 44 tools.

Tools
44
What they doRead · write · destructive
41 · 2 · 141 read2 write1 destructive
Users sign in with

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 (Bearer Token) connection

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

    Console steps with screenshots

    Register a Twitter Bearer Token with Scalekit to make app-only requests — reading public tweets, users, and search results without acting on behalf of a specific user. You’ll need a Bearer Token from an app in the X Developer Console.

    1. 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

    2. Generate a Bearer Token

      • Open your app and go to the Keys & Tokens tab.

      • Under App-Only Authentication, click Generate next to Bearer Token (or Regenerate if one already exists).

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

      • Copy the token immediately — X shows it in full only once.

    3. Add the token in Scalekit

      • In Scalekit dashboard, go to AgentKit > Connections > Create Connection. Search for Twitter Bearer and click Create.
      • Paste the Bearer Token you copied in step 2.
      • 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 = 'twitterbearer'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Twitter / X (Bearer Token):', 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: 'twitterbearer_activity_subscriptions_list',
    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
  • twitterbearer_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.

  • twitterbearer_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
  • twitterbearer_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
  • twitterbearer_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
  • twitterbearer_followers_getRetrieves a list of users who follow a specified public Twitter user ID.Read-only

    Get Followers by User ID

    Retrieves a list of users who follow a specified public Twitter user ID.

    Inputs

    idstringrequired
    Twitter user ID to get followers for
    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
  • twitterbearer_following_getRetrieves users followed by a specific Twitter user, allowing pagination and customization of returned user and tweet data fields via expansions.Read-only

    Get Following by User ID

    Retrieves users followed by a specific Twitter user, allowing pagination and customization of returned user and tweet data fields via expansions.

    Inputs

    idstringrequired
    Twitter user ID
    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
  • twitterbearer_full_archive_search_countsReturns a count of Tweets from the full archive that match a specified query, aggregated by day, hour, or minute.Read-only

    Get Full Archive Search Counts

    Returns a count of Tweets from the full archive that match a specified query, aggregated by day, hour, or minute. start_time must be before end_time if both are provided. since_id/until_id cannot be used with start_time/end_time.

    Inputs

    querystringrequired
    Search query
    end_timestring
    ISO 8601 end time
    granularitystring
    Aggregation granularityone of minutehourday
    next_tokenstring
    Next page token
    since_idstring
    Minimum tweet ID
    start_timestring
    ISO 8601 start time
    until_idstring
    Maximum tweet ID