# Create a Confluence page with the REST API

URL: https://goingstellar.ro/reference/atlassian-rest-api/create-page/

POST /wiki/api/v2/pages takes spaceId, status, title, an optional parentId and a body with representation and value. Pages are created as published unless status is draft. A title that already exists in the space is refused with 400.

## Endpoints

| Method | Path | What it does |
|---|---|---|
| POST | `/wiki/api/v2/pages` | Creates a page in a space; status draft creates a draft. |

## Examples

### POST /wiki/api/v2/pages

Creates a published child page under an existing page.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "spaceId": "{spaceId}",
  "status": "current",
  "title": "Example child page",
  "parentId": "{pageId}",
  "body": {
    "representation": "storage",
    "value": "<p>Child.</p>"
  }
}' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/wiki/api/v2/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'spaceId': '{spaceId}',
          'status': 'current',
          'title': 'Example child page',
          'parentId': '{pageId}',
          'body': {'representation': 'storage', 'value': '<p>Child.</p>'}},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "spaceId": "655364",
 "parentId": "33653083",
 "version": {
  "number": 1,
  "message": ""
 },
 "id": "33620331",
 "body": {
  "storage": {
   "representation": "storage",
   "value": "<p>Child.</p>"
  }
 },
 "status": "current",
 "title": "Example child page",
 "_links": {
  "webui": "/spaces/SD/pages/33620331/Example+child+page"
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### POST /wiki/api/v2/pages

Creates a page with a title that is already used in the space.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "spaceId": "{spaceId}",
  "status": "current",
  "title": "Example child page",
  "body": {
    "representation": "storage",
    "value": "<p>Dup.</p>"
  }
}' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/wiki/api/v2/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'spaceId': '{spaceId}',
          'status': 'current',
          'title': 'Example child page',
          'body': {'representation': 'storage', 'value': '<p>Dup.</p>'}},
)
print(r.status_code, r.text)
```

Response: HTTP 400

```
{
 "errors": [
  {
   "status": 400,
   "code": "BAD_REQUEST",
   "title": "A page with this title already exists: A page already exists with the same TITLE in this space",
   "detail": null
  }
 ]
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### POST /wiki/api/v2/pages

Creates a draft. No parentId is given.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "spaceId": "{spaceId}",
  "status": "draft",
  "title": "Example draft page",
  "body": {
    "representation": "storage",
    "value": "<p>Draft.</p>"
  }
}' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/wiki/api/v2/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'spaceId': '{spaceId}',
          'status': 'draft',
          'title': 'Example draft page',
          'body': {'representation': 'storage', 'value': '<p>Draft.</p>'}},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "parentId": "655541",
 "version": {
  "number": 1
 },
 "status": "draft",
 "title": "Example draft page",
 "id": "33554754",
 "_links": {
  "webui": "/pages/resumedraft.action?draftId=33554754&draftShareId=ec24211b-9e2f-4f91-8ae2-f7e703d96c38"
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### POST /wiki/rest/api/content

The v1 call: space by key, parent as an ancestor, body under storage.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "type": "page",
  "title": "Example page created with v1",
  "space": {
    "key": "SD"
  },
  "ancestors": [
    {
      "id": "{pageId}"
    }
  ],
  "body": {
    "storage": {
      "value": "<p>v1</p>",
      "representation": "storage"
    }
  }
}' \
  'https://your-domain.atlassian.net/wiki/rest/api/content'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/wiki/rest/api/content',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'type': 'page',
          'title': 'Example page created with v1',
          'space': {'key': 'SD'},
          'ancestors': [{'id': '{pageId}'}],
          'body': {'storage': {'value': '<p>v1</p>', 'representation': 'storage'}}},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "id": "33784019",
 "type": "page",
 "status": "current",
 "title": "Example page created with v1",
 "space": {
  "key": "SD"
 },
 "ancestors": [
  {
   "id": "655541",
   "title": "Software Development"
  }
 ],
 "extensions": {
  "position": 1247
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

## How it behaves

- A call with status current and a parentId returns 200 (not 201) with the new page, version 1, and parentId set to the given parent (conf-page-create-child).
- A second page with the same title in the same space gives 400 BAD_REQUEST with the message "A page already exists with the same TITLE in this space" (conf-page-create-duplicate-title).
- A draft created without parentId has status "draft" and a parentId equal to the space homepage id, and its webui link is a resumedraft.action URL (conf-page-create-draft).
- The v1 call returns the full content object including history, ancestors and space (conf-page-create-v1).

## Pitfalls

- The status is 200, not 201, for page creation in v2, so a client that checks for 201 will report a failure on success.
- Titles are unique per space. A retry after a timeout can hit the 400 even though the first call worked.
- A draft has status draft and a resumedraft.action link, so it is not a published page yet.

## Questions and answers

### How do I create a page at the top of a space?

The spec has a root-level query parameter for that. It was not run, so test it on a scratch space first.

### Which fields are required?

spaceId and a body. The spec says a published page also needs a title.

## Related

- [Body formats](https://goingstellar.ro/reference/atlassian-rest-api/page-body-formats/)
- [Update a page and versions](https://goingstellar.ro/reference/atlassian-rest-api/update-page-versions/)
- [Child pages](https://goingstellar.ro/reference/atlassian-rest-api/page-children/)
- [Delete, trash and purge](https://goingstellar.ro/reference/atlassian-rest-api/delete-trash-purge/)
- [Spaces](https://goingstellar.ro/reference/atlassian-rest-api/spaces/)

## Sources

- [Create page (Confluence REST API v2)](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-post)
- [The Confluence Cloud REST API v2 (Atlassian Developer)](https://developer.atlassian.com/cloud/confluence/rest/v2/intro/)

