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

# X (Twitter)

> How to add X to your system

<Snippet file="never-share.mdx" />

<Note>
  Watch the YouTube Tutorial: [https://m.youtube.com/watch?si=swqzAXiSTFOXZiFo\&v=3WneMPnOu88](https://m.youtube.com/watch?si=swqzAXiSTFOXZiFo\&v=3WneMPnOu88)
</Note>

X is a bit different.

They created an oAuth2 flow, but it works only with Twitter v2 API.
But in order to upload pictures to X, you need to use the old Twitter v1 API.
So you are going to use the normal oAuth1 flow for that (that supports Twitter v2 also 🤷🏻‍).

<Steps>
  <Step title="Create a new app">
    Head over the [Twitter developers page](https://developer.twitter.com/en/portal/dashboard) and create a new app.
    Click to sign-up for a new free account

    <img src="https://mintcdn.com/postiz/NC1G4tduhaxm8LzE/images/providers/x/x-001.png?fit=max&auto=format&n=NC1G4tduhaxm8LzE&q=85&s=94589e4e4357a0357a5e4da4a7f4326f" alt="X" width="1238" height="368" data-path="images/providers/x/x-001.png" />
  </Step>

  <Step title="Edit application settings">
    Click to edit the application settings

    <img src="https://mintcdn.com/postiz/NC1G4tduhaxm8LzE/images/providers/x/x-002.png?fit=max&auto=format&n=NC1G4tduhaxm8LzE&q=85&s=fdf900423074b1e1549aa66c5df49123" alt="X" width="1660" height="852" data-path="images/providers/x/x-002.png" />
  </Step>

  <Step title="Set up authentication flow">
    Click to set up an authentication flow

    <img src="https://mintcdn.com/postiz/NC1G4tduhaxm8LzE/images/providers/x/x-003.png?fit=max&auto=format&n=NC1G4tduhaxm8LzE&q=85&s=653a11fc92ed3c7e0bab5dd721fbd4ff" alt="X" width="1668" height="420" data-path="images/providers/x/x-003.png" />

    * In the App Permission set it to `Read and Write`
    * In the Type of App set it to `Native App`
    * In the App Info set the `Callback URI / Redirect URL`

    <Note>
      You must select `Native App` for OAuth 1.0a to work correctly. Selecting `Web App, Automated App or Bot` will cause authentication to fail with error code 32.
    </Note>
  </Step>

  <Step title="Configure OAuth2 Redirect URI">
    <Snippet file="oauth2redirect.mdx" />

    **Your X OAuth2 Redirect URI:**

    * Production: `https://your-postiz-domain.com/integrations/social/x`
    * Local development: `http://localhost:4200/integrations/social/x`
    * Docker: `http://localhost:5000/integrations/social/x`
    * If X requires HTTPS for localhost: `https://redirectmeto.com/http://localhost:4200/integrations/social/x`
  </Step>

  <Step title="Copy your API keys">
    Save it and go to "Keys and Tokens" tab.

    Click on "Regenerate" inside "Consumer Keys" and copy the `API Key` and `API Key Secret`.

    Open .env file and add the following:

    ```env theme={null}
    X_API_KEY=""
    X_API_SECRET=""
    ```
  </Step>
</Steps>

## Optional environment variables

* `X_URL` — override the X API base URL (e.g. for self-hosted X-compatible APIs).
* `DISABLE_X_ANALYTICS=true` — skip the analytics fetch on the X channel page. Useful if your X plan doesn't include analytics access and the failed call is noisy.
* `STRIP_LINKS_FROM_X_POSTS=true` — automatically remove URLs from post text before publishing. Some accounts see better reach with no links; this enforces it globally.

## Post Settings

When creating a post for X, you can configure the following options:

* **Who can reply** — Control who can reply to your post: everyone, accounts you follow, mentioned accounts, subscribers, or verified accounts.
* **Post to a community** — Optionally share your post to an X community by providing the community URL.
* **Made with AI** — Mark your post as containing AI-generated content. When enabled, the post will be labeled accordingly on X.
* **Paid partnership** — Mark your post as a paid promotion. When enabled, the post will be labeled as a paid partnership on X.
