> For the complete documentation index, see [llms.txt](https://docs.chaingpt.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/agenticos-framework-web3-ai-agent-on-x-open-source/twitter_developer_account_setup.md).

# Twitter\_Developer\_Account\_Setup

🔑 Twitter API Setup Guide (OAuth 2.0)

To run this application, you’ll need to obtain Twitter API credentials using **OAuth 2.0**. Follow the steps below to generate your **Client ID** and **Client Secret**.

***

#### 🔗 Twitter Developer Portal

➡ **Link:** <https://developer.twitter.com/en/portal/dashboard>

***

#### ✅ Step-by-Step Instructions

1. **Log in to the Twitter Developer Portal**

   Go to the [Twitter Developer Dashboard](https://developer.twitter.com/en/portal/dashboard) and sign in with your Twitter account.
2. **Create a New Project & App**
   * Navigate to: `Projects & Apps > Overview`
   * Click **"Create App"**
   * Provide an app name and select **OAuth 2.0** as the authentication method
3. **Configure OAuth 2.0 Settings**
   * Go to your app's **Settings** tab
   * Under **OAuth 2.0**, configure:
   * **Callback URL:**\
     `https://your-domain.com/api/login/callback` — *Replace `your-domain.com` with your actual domain. It must match exactly as configured in the Twitter Developer Portal.*
     * **Website URL:**\
       `https://your-deployment-url.com`
     * **Client Type:** Confidential
     * **Scopes (Permissions):**
       * `tweet.read`
       * `tweet.write`
       * `users.read`
       * `offline.access` *(required for refresh tokens)*
   * Save the changes.
4. **Generate OAuth 2.0 Credentials**
   * Navigate to the **Keys and Tokens** tab
   * Click **"Generate"** under **OAuth 2.0 Client ID and Client Secret**
   * Copy and store the credentials securely.

***

#### 🧪 Add to Environment Variables

* Paste your credentials in the `.env` file like you
* During one-click deployment, you'll be asked to enter these credentials as environment variables.

below:

```
TWITTER_CLIENT_ID=your_client_id_here
TWITTER_CLIENT_SECRET=your_client_secret_here
```

### Tweet Character Limits

When using this tool to post tweets via the Twitter (X) API, please note:

* **Free Twitter/X Users** are limited to **280 characters per tweet**.
* If you attempt to tweet more than 280 characters from a free account, the request will **fail**.
* To unlock longer tweet capabilities (up to 4,000 characters), users must upgrade to **Twitter Blue (X Premium)**.

👉 You can upgrade or learn more here: <https://x.com/i/premium_sign_up>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.chaingpt.org/dev-docs-b2b-saas-api-and-sdk/agenticos-framework-web3-ai-agent-on-x-open-source/twitter_developer_account_setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
