Add JSON API support for user data exports#2786
Merged
flavorjones merged 1 commit intobasecamp:mainfrom Apr 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds JSON API support for user data exports, mirroring the existing account exports JSON endpoints. It enables clients to create personal data exports and poll their status asynchronously, with support for multiple export states (pending, processing, completed, failed).
Changes:
- Add JSON format handlers to
Users::DataExportsController#createand#showactions - Create
show.json.jbuildertemplate to serialize export objects with conditional download URLs - Add comprehensive controller tests covering JSON requests, authorization, rate limiting, and different export states
- Document the new JSON export endpoints in
docs/API.mdwith request/response examples
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/controllers/users/data_exports_controller.rb | Modified create/show actions to handle JSON responses via respond_to blocks; updated set_export to load all export states for JSON requests (vs only completed for HTML) |
| app/views/users/data_exports/show.json.jbuilder | New Jbuilder template that serializes export id, status, created_at, and conditionally includes download_url when export is completed and file is attached |
| test/controllers/users/data_exports_controller_test.rb | Added 6 new test cases covering JSON create/show, different export states, authorization, and rate limiting scenarios |
| docs/API.md | Added comprehensive documentation for both account exports and user data exports JSON endpoints with response schema examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7331aec to
ac53a8a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Add JSON API support for user data exports and document the export API surface.
What changed
Users::DataExportsController#createand#showapp/views/users/data_exports/show.json.jbuilderdocs/API.md, including existing account export JSON endpoints and new user data export JSON endpointsAPI behavior
New JSON support
POST /:account_slug/users/:user_id/data_exports.jsonGET /:account_slug/users/:user_id/data_exports/:id.jsonResponse shape:
idstatuscreated_atdownload_urlwhen completed and attachedNotes
Tests
bin/rails test test/controllers/users/data_exports_controller_test.rb test/controllers/accounts/exports_controller_test.rb