Add link management API: list, rename, update, toggle, delete - #647
Open
PLNech wants to merge 1 commit into
Open
Add link management API: list, rename, update, toggle, delete#647PLNech wants to merge 1 commit into
PLNech wants to merge 1 commit into
Conversation
polr's v2 API can shorten, look up, and report analytics, but managing existing links is only possible through the admin web UI. This adds five api-key-protected endpoints under /api/v2/action/, reusing the existing `api` middleware (authentication and quotas are unchanged): GET action/list list your links (admins: all), optional substring filter POST action/rename rename a link ending in place (destination/clicks kept) POST action/update change a link's destination URL POST action/toggle enable/disable a link without deleting it POST action/delete delete a link All five enforce ownership: a user may manage links they created, admins may manage any link, and anonymous API users are refused. Validation and error handling mirror the existing shorten/lookup endpoints (ApiException codes, alpha_dash endings, URL validation, collision checks on rename). The delete endpoint builds on the approach in cydrobolt#632 (thanks @technowhizz), adding ownership enforcement, POST + action/ namespacing for consistency, and a structured response. Adds tests/ApiLinkManagementTest.php (20 tests pass) covering success, validation, ownership, admin override, and not-found paths. Documents all five endpoints in docs/developer-guide/api.md. Adds a GitHub Actions CI workflow (PHP 7.2/7.3 + MySQL) since Travis CI is no longer active. Closes cydrobolt#221, cydrobolt#442, cydrobolt#538.
This was referenced Jun 11, 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.
Summary
polr's v2 API can shorten, look up, and report analytics, but managing existing links is only possible through the admin web UI. This adds five api-key-protected endpoints under
/api/v2/action/, reusing the existingapimiddleware so authentication and quotas are unchanged:GETaction/listPOSTaction/renamePOSTaction/updatePOSTaction/togglePOSTaction/deleteOwnership & safety
All five enforce ownership: a user may manage links they created, admins may manage any link, and anonymous API users are refused. Validation and error handling mirror the existing
shorten/lookupendpoints (ApiExceptioncodes,alpha_dashendings, URL validation, collision checks on rename).Credit
The
deleteendpoint builds on the approach in #632 (thanks @technowhizz), adding ownership enforcement,POST+action/namespacing for consistency with the rest of the v2 API, and a structured JSON response.Tests & CI
tests/ApiLinkManagementTest.php— 20 tests (success, validation, ownership, admin override, not-found). Full suite passes (20 tests, 58 assertions).composer.lockcurrently requires PHP ≥ 7.2 (doctrine/lexer 1.2.1), which is why the matrix starts at 7.2.Docs
All five endpoints documented in
docs/developer-guide/api.mdin the existing style.Closes #221, closes #442, closes #538.