Repository navigation
fix: use the v2 REST API for page and space operations on Confluence Cloud - #298
Merged
Merged
Conversation
…Cloud Atlassian removed the v1 /content and /space endpoints on Cloud; they now answer 410 Gone, which breaks read, info, create, create-child, update, edit, move, delete, children, spaces and space-lookup. On Cloud, route these through /wiki/api/v2 (pages, folders, spaces) and adapt the responses to the v1 shape the rest of the client and CLI already consume. Server/Data Center keeps the v1 endpoints unchanged. CONFLUENCE_PAGE_API=v1|v2 (or the pageApi option) overrides the automatic choice. Add tests for the v2 paths, including Japanese text, full-width punctuation, emoji and ZWJ sequences, inline code/bold next to CJK, lists and tables through markdown -> storage -> markdown. Existing v1-mocking suites now pin pageApi: 'v1'. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Document granular scopes per command (incl. delete and ancestors) and
show v2-specific scope guidance on 401/403 from v2 endpoints.
- Read the Link rel="next" header (cursor only) as well as _links.next
when paginating v2 lists.
- Use the listing's _links.base, or the configured siteUrl, for child
page links so gateway usage no longer yields api.atlassian.com URLs.
- Resolve folder parent/ancestors via /folders/{id}/ancestors and honour
the record's parentId in normalizePage.
- Continue ancestor chains beyond the 250-item cap from the highest
ancestor.
- Resolve blog post ids via /blogposts/{id} for read/info/delete.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Pass the title-search response _links.base into shaped pages so gateway usage yields site URLs. - When probing /pages, /blogposts and /folders, keep searching after a 401/403 on one collection and report the auth error (not a 404) if nothing matches; stop on 5xx/network errors. Applies to read, info and delete. - Rewrite the README scope documentation per actual CLI call path and limit the classic scope table to the endpoints still on v1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lder read Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Switching every Cloud client to v2 changed output for sites whose v1 endpoints still work (null child versions, account IDs instead of names, ancestors without titles) and broke `copy-tree --dry-run --json`, whose plan fingerprint needs a version per page. In the default auto mode a client now starts on v1 everywhere. On Cloud a v1 page/space call that answers 410 switches the client to v2 and re-runs that operation there; a 410 applied nothing, so a write is sent once more. Server/Data Center never switches. Unknown CONFLUENCE_PAGE_API values are rejected. Also from review: - copy-tree dry-run JSON fills in missing versions from v2. - v2 child listings ask for child-position order, title lookups for current pages, and a page created without a parent goes to the space root (root-level=true), as on v1. - A wrong id is reported as not found when /pages answers 404 and only a later collection refuses. - getSpaces rejects options.start on v2; creating a blog post through v2 is refused instead of creating a page; repeated cursors end a listing. - README keeps the classic scope table and documents the fallback. Existing test files are back to upstream and pass unchanged. A probe comparing requests and results with upstream/main for 23 operations is byte-identical for Cloud (v1 working) and Server. Full jest suite (2015) and lint pass. Live, read-only, against a site whose v1 answers 410: children, spaces and find work through the fallback; root-level, sort and status parameters were checked live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
Owner
|
Thank you so much for this, @k-k1! Really appreciate the careful approach of staying on v1 until a 410 shows up, so nothing changes for anyone whose v1 endpoints still work, and the thorough test coverage for the v2 paths. This is a big help for Cloud users as the v1 endpoints go away. Merging now. |
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 15, 2026
## [2.31.1](v2.31.0...v2.31.1) (2026-11-15) ### Bug Fixes * use the v2 REST API for page and space operations on Confluence Cloud ([#298](#298)) ([470e0f2](470e0f2))
|
🎉 This PR is included in version 2.31.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Description
Closes #296
Atlassian is removing the v1 content/space endpoints on Confluence Cloud. On a site where they are gone, with CLI 2.31.0 (OAuth 3LO token through the api.atlassian.com gateway)
read,info,create,updateandspace-lookupfail with HTTP 410:com.atlassian.confluence.api.service.exceptions.pagesmodes.GoneException: This deprecated endpoint has been removed.for GET/POST /content, /content/{id}, /content/{id}/child/page, /content?spaceKey= and /space/{key}. v1 /search (CQL) still works.Page and space operations get a
/wiki/api/v2implementation (pages, blogposts, folders, spaces) whose responses are adapted to the v1 shape the client and CLI already consume.Routing is conservative: nothing changes for anyone whose v1 endpoints still work. In the default
automode every client starts on v1, exactly as today. Only on Cloud (existingisCloud(): *.atlassian.net, api.atlassian.com,CONFLUENCE_FORCE_CLOUD), when a v1 page/space call answers410 Gone, does the client switch to v2 for the rest of the command and re-run that operation there (a 410 means nothing was applied, so re-sending a write is safe). Server/Data Center never switches.CONFLUENCE_PAGE_API=auto|v1|v2(or thepageApioption) forces a family; any other value is rejected. All existing test files pass unmodified.The change is fairly large (most of it in
lib/confluence-client.jsplus a new test file). I'm happy to split it, change the approach, or drop parts if you prefer a different direction.Ported
parentId), delete, space-lookup, spaces, children/copy-tree/export child listing, display-URL resolution, the page fetch of inline-comment creation.How it works
/content/{id}served pages, blog posts and folders; v2 splits them, so read/info/delete probe/pages,/blogposts,/folders. A 404 or 401/403 on one collection (e.g. a token without the blog post scope) does not stop the search. If nothing matches, a 404 from/pagesis reported as not found (naming the collections that could not be checked), while a refusal from/pagesitself is reported as the auth error; 5xx/network errors stop at once.Link: rel="next"header or body_links.next(only the cursor value is used, the URL is never followed); a repeated cursor ends the listing. The librarygetSpacesrejectsoptions.starton v2 instead of silently returning the first page (the CLI has no--start).root-level=true(v2 otherwise files it under the space homepage; v1 created it at the space root); child listings requestsort=child-position(page-tree order, which copy-tree relies on for siblings); title lookups requeststatus=current, as v1 matched current pages only.copy-tree --dry-run --jsonfetches the version of each listed page to buildplannedTreeFingerprint./folders/{id}/ancestors._links.baseis used (gateway-safe), falling back to the configuredsiteUrl.Not ported (follow-ups): attachments, content properties, version list/purge, comment list/create/delete, user-key resolution. On a site where those v1 endpoints are gone as well they still fail (the site I tested answers 410 for attachments, versions and comments), so
exportthere needs--skip-attachments; the README says so. I kept them out to keep this PR reviewable and can follow up.Limitations on v2 (only where v1 is gone): child listings carry no version (
childrenJSONversionis null) and their URLs are built from space key + id;infoshows account IDs instead of display names and ancestors have no titles; create/update return a smaller object (no_expandable,version.byhas onlyaccountId);update/moveare pages only (as before); creating ablogpostthrough the library is rejected rather than silently creating a page.Scopes (OAuth 3LO / scoped tokens). Sites still on v1 keep the existing classic scopes (the README table is unchanged). Once v2 is in use, the commands need granular scopes (the README has the full table):
read:page,read:blogpost,read:folder,read:space,read:content.metadata(ancestors),write:page,write:folder,delete:page/delete:blogpost/delete:folder.read:hierarchical-contentis needed only for folder direct-children listings (children --type folders|all); page child listings needread:page+read:space. Classic scopes no longer cover these commands; they still cover search, attachments, comments, properties and versions. A missing scope can surface as 401 or 403. Unscoped API tokens (basic auth) are not affected.Type of Change
Testing
tests/cloud-v2-pages.test.js(mocked HTTP) covers the v2 helpers and core page operations (read, info, create, create-child, update, move, delete, spaces, children); page/blogpost/folder probing including missing-scope cases; Link-header and cursor pagination; >250 ancestors; gateway link/base handling (children, title search,siteUrlfallback); Server/DC still on v1; auto mode (a Cloud site serving v1 never touches v2, a 410 switches once and later calls go straight to v2, a 410 on create re-sends once through v2, other v1 errors and Server/DC 410s are not retried); API override, invalid values andforceCloudrouting; child-position sort,status=current, repeated cursors, version filling for the copy-tree plan, inline-comment body fetch via v2; markdown -> storage -> markdown round trips for Japanese text, full-width punctuation, emoji (surrogate pairs, ZWJ), code/bold adjacent to CJK, lists and tables, plus entity assertions on the JSON request body. Existing test files are unchanged and pass; forcing v2 on Cloud makes 106 of them fail, which shows they still guard the v1 behaviour. A side-by-side probe of 23 client operations against a mocked adapter produced byte-identical requests and results tomainfor a Cloud site still serving v1 and for Server/DC. Full jest suite (2015 tests) and lint pass.Partial live check against a Confluence Cloud site through the OAuth gateway (the site's v1 endpoints answer 410), read-only apart from two probe pages:
children(text and JSON, page-tree order),spacesandfindworked through the fallback, andsort=child-position,status=currentandroot-level=truewere accepted (a page created without a parent landed under the homepage withoutroot-level, at the root with it). Commands needing scopes our token lacks (read:content.metadata,read:hierarchical-content) returned the 401 with the scope hint as expected. Writes and edit/copy-tree/export were not exercised end-to-end against v2 from this branch.Checklist
Additional Context
AI assistance (Claude Code) was used for the change, its review and validation.
🤖 Generated with Claude Code