Skip to main content
POST
/
2
/
articles
/
draft
Create draft Article
curl --request POST \
  --url https://api.x.com/2/articles/draft \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "content_state": {
    "blocks": [
      {
        "text": "<string>",
        "data": {},
        "depth": 123,
        "entity_ranges": [
          {
            "key": 123,
            "length": 123,
            "offset": 123
          }
        ],
        "inline_style_ranges": [
          {
            "length": 123,
            "offset": 123
          }
        ],
        "key": "<string>"
      }
    ],
    "entities": [
      {
        "key": "<string>",
        "value": {
          "data": {
            "caption": "<string>",
            "markdown": "<string>",
            "media_items": [
              {
                "media_category": "<string>",
                "media_id": "<string>"
              }
            ],
            "post_id": "<string>",
            "url": "<string>"
          }
        }
      }
    ]
  },
  "title": "<string>"
}
'
{
  "data": {
    "id": "1146654567674912769",
    "title": "<string>"
  },
  "errors": [
    {
      "title": "<string>",
      "type": "<string>",
      "detail": "<string>",
      "status": 123
    }
  ]
}

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Body

application/json
content_state
object
required

DraftJS content state representing the article body.

title
string
required

The title of the article.

Minimum string length: 1
cover_media
object

Optional cover media for the article.

Response

The request has succeeded.

data
object

The newly created draft Article.

errors
object[]
Minimum array length: 1

An HTTP Problem Details object, as defined in IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).