---
title: "X Tool"
---

Connect your X (Twitter) account to search and retrieve tweets using OAuth authentication.

## Prerequisites

- Active X (Twitter) account
- Project with agent building permissions

## Add X Tool to Your Project

1. Navigate to **Tools Library** and search for "X"
2. Click **Add Tool** on the X - Search Tweets listing
3. Enter a **Tool Name** for your library
4. Click **Save**

## Configure Authentication

1. In the tool setup page, select **X OAuth** from the authentication dropdown
2. Click **Create a New Credential**


3. Click **Authorize** to connect your X account
4. Grant the required permissions when prompted
5. Save the generated token as a new credential

> 💡 **Note:** Your X account credentials are automatically refreshed in the background through OAuth refresh tokens.

## Add Tool to Agent

1. Open your agent in the **Agent Canvas**
2. Drag the X tool from your library to the agent
3. Configure any additional settings as needed

For detailed setup instructions, see the [Tools Setup Guide](../tools.mdx).

## Using X Search Tool

The X Search tool queries recent tweets from the last 7 days using the X API.

### Search for Tweets by Topic

Ask your agent to search for specific topics:
```
"Search X for tweets about AI development"
```

![X results](../Images/X_tweets.png)

### Search by User Account

Query tweets from specific users:
```
"Show me recent tweets from @username"
```

![X results](../Images/X_user_tweets.png)

### Paginate Through Results

Request additional results with follow-up queries:
```
"Show me more results" or "Are there more tweets?"
```

![X more results](../Images/X_more_tweets.png)

### Specify Result Count

Request a specific number of tweets:
```
"Get me 30 recent tweets about machine learning"
```

![X multiple tweets](../Images/X_30_tweets.png)

## Best Practices

> 💡 **Tip:** Add a custom prompt to your agent with details about your search use case, specific accounts you monitor, or your industry domain for better results.

> ⚠️ **Limitation:** X Search tool is limited to tweets from the last 7 days due to X API restrictions.
