> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-066e8699.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Use the X API Articles endpoints to programmatically create draft long-form Articles with rich text, media, and embeds, then publish them to X.

The Articles endpoints allow developers to create draft Articles and publish them on X programmatically. Articles are long-form posts that support rich text formatting, embedded posts, links, and images.

These endpoints require user-auth authentication via OAuth 1.0a or OAuth 2.0 PKCE with the `tweet.read`, `tweet.write`, and `users.read` scopes.

Currently, the API supports two endpoints:

## Create a draft Article

Developers can create a new draft Article using the `POST https://api.x.com/2/articles/draft` endpoint. The request body contains the article title, the body content as a [DraftJS](https://draftjs.org/docs/api-reference-content-state) content state of text blocks and entities, and optional cover media uploaded via the [media upload endpoints](/x-api/media/introduction).

## Publish an Article

Once a draft is ready, developers can make it publicly visible using the `POST https://api.x.com/2/articles/{article_id}/publish` endpoint, where `article_id` is the ID returned when the draft was created.

## Getting started

To use the endpoints, you need a user access token. For details on generating one, see the [OAuth 2.0 Authorization Code Flow with PKCE](/fundamentals/authentication/oauth-2-0/authorization-code) documentation.

Once you have the access token, you can create a draft Article as shown below:

```bash theme={null}
curl --request POST 'https://api.x.com/2/articles/draft' \
  --header 'Authorization: Bearer XXXXX' \
  --header 'Content-Type: application/json' \
  --data '{
    "title": "My first Article",
    "content_state": {
      "blocks": [
        {
          "text": "Hello from the Articles API!",
          "type": "unstyled"
        }
      ],
      "entities": []
    }
  }'
```

If the request is successful, you should see the JSON response as shown below:

```json theme={null}
{
  "data": {
    "id": "1146654567674912769",
    "title": "My first Article"
  }
}
```

You can then publish the draft using the returned Article ID:

```bash theme={null}
curl --request POST 'https://api.x.com/2/articles/1146654567674912769/publish' \
  --header 'Authorization: Bearer XXXXX'
```

If the request is successful, the response contains the ID of the post created for the published Article:

```json theme={null}
{
  "data": {
    "post_id": "1346889436626259968"
  }
}
```
