Post a page in Confluence programmatically using cURL
The shortest tutorial to start your Confluence integration

Introduction
I had some issues programmatically creating a page in Confluence. Unfortunately, ChatGPT & Gemini didn’t provide the correct cURL command to do it, so here is the step by step guide to do it.
1. Create an Atlassian token
Atlassian token last maximum 1 year and are tied to the user who created them; they can be used to authenticate any Atlassian product programmatically.
Go to the Atlassian token page and create a new token:
Enter a name a set the expiration date.
2. Get the space id where you want to post the page
Open a terminal and set the following environment variables relative to your Confluence instance:
export ATLASSIAN_TOKEN="your_atlassian_token"
export USER_EMAIL="your_email"
export ATLASSIAN_INSTANCE="{your_domain}.atlassian.net"
and list the spaces available to determine the id of the space you want to post the page in:
curl -X GET \
-u "$USER_EMAIL:$ATLASSIAN_TOKEN" \
-H "Content-Type: application/json" \
"https://$ATLASSIAN_INSTANCE/wiki/api/v2/spaces" | jq "."
Identify the space id of the space you want to post the page in from the results array output.
3. Post the page
In the same terminal, post a test page in draft mode (replace 12345 with the space id found in the previous step):
curl -X POST \
-u "$USER_EMAIL:$ATLASSIAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"spaceId": "12345",
"title": "Hello World",
"status": "draft",
"body": {
"representation": "storage",
"value": "<p>Page created from cURL</p>"
}
}' \
"https://$ATLASSIAN_INSTANCE/wiki/api/v2/pages"
(Don’t use a variable for the SPACE_ID in this command since the shell won’t expand the variable in the body wrapped in single quotes section).
You should see the page in draft mode: