> ## Documentation Index
> Fetch the complete documentation index at: https://onecli.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Let AI Agents Post and Read on X (Twitter)

> Let agents search and read posts, timelines, and mentions on X, and post, like, follow, or DM. Connect your own X app, and the gateway hides the token.

## Overview

OneCLI connects AI agents to [X](https://x.com) through OAuth. Agents can search and read posts, read timelines and mentions, and post, like, follow, or send DMs. The gateway injects the token into every request, so your agent never sees it.

X uses **your own X developer app**, on OneCLI Cloud and self-hosted alike. Setup takes about five minutes, once.

## What you will set up

* Your own X developer app with OAuth 2.0
* An X connection that injects the token on every request
* Per-agent, per-tool access, with approval for public posts and DMs

## Connect X

**1. Create an X app**

In the [X Developer Portal](https://developer.x.com/en/portal/dashboard), open **Projects & Apps** and create an app. Under **User authentication settings**, turn on OAuth 2.0, set the type to **Web App**, and set permissions to **Read and write and Direct message**.

**2. Add the callback URL**

In OneCLI, open **Connections** > **X** > **Custom credentials** and copy the **Redirect URI**. Paste it into the X app's **Callback URI / Redirect URL** and save.

![X Developer Console, User authentication settings, App info section with the OneCLI callback URL and https://onecli.example.com as the Website URL.](https://mintcdn.com/chartdbinc/dTUFGeS6j-vov2tm/images/integrations/x/01-provider-app-info.png?fit=max\&auto=format\&n=dTUFGeS6j-vov2tm\&q=85\&s=745689e756eed0c290e4b1593e2172c1)

App info in the X app's User authentication settings.

**3. Add your credentials and connect**

Copy the app's OAuth 2.0 **Client ID** and **Client Secret** into **Custom credentials**, click **Save credentials**, then click **Connect X** and **Authorize app** on X.

![OneCLI connect window for X showing Configuration required, the setup guide link, and the Configure credentials button.](https://mintcdn.com/chartdbinc/yFw2bbdvTPdZgMOT/images/integrations/x/onecli-connect-x.png?fit=max\&auto=format\&n=yFw2bbdvTPdZgMOT\&q=85\&s=c08d5f08de4aea7998188f1271109db1)

The X connect window in OneCLI before credentials are added.

## What agents can do

| Area | What agents can do |
| - | - |
| **Read** | Look up users and posts, search posts, read timelines, mentions, followers, following, likes, bookmarks, lists, blocks, mutes, and DMs |
| **Write** | Post and delete posts, like, repost, follow, bookmark, block, mute, send DMs, upload media, create lists, and hide replies |

## Controlling access

[Grant](https://onecli.sh/docs/guides/agent-access.md) the connection to each agent that needs it, and choose per tool what runs freely, what needs approval, and what's blocked. Anything that posts publicly or messages people (**Create post**, **Send DM**, **Repost**, **Follow**) belongs behind approval. Organization [rules](https://onecli.sh/docs/guides/rules.md) add guardrails on top. A blocked request never reaches X.

To disconnect, remove the connection in **Connections** > **X**, then revoke OneCLI on X under **Settings** > **Security and account access** > **Apps and sessions**.

## FAQ

> [accordion] Do I need my own X developer app?
>
> Yes, on OneCLI Cloud and self-hosted alike. Setup takes about five minutes, once.

> [accordion] Does the agent see my X token?
>
> No. The token stays in OneCLI, and the gateway adds it at the proxy. See [How it works](https://onecli.sh/docs/how-it-works.md).

> [accordion] Can I approve posts before they go out?
>
> Yes. Put **Create post** and other public or messaging actions behind approval when you [grant](https://onecli.sh/docs/guides/agent-access.md) the connection.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.