Reverse-Sync a Questionnaire
Reverse sync reads a local generated TypeScript file and pushes the data back to Strapi, creating a new draft version. Use this when you have made local edits that need to be reflected in the CMS.
1. Dry run first
Section titled “1. Dry run first”Always preview what will change before pushing:
yarn reverse-sync:questionnaire -q <slug> --dry-runThis shows a colored diff of what would change in Strapi — additions in green, deletions in red. No changes are made.
2. Review the diff
Section titled “2. Review the diff”Check for:
- Expected changes (the edits you made)
- Unexpected changes (formatting differences, field ordering)
- Missing data (questions or rules that should not be removed)
3. Push to Strapi
Section titled “3. Push to Strapi”yarn reverse-sync:questionnaire -q <slug>This creates a draft in Strapi with your local changes. The published version remains unchanged.
4. Verify in Strapi
Section titled “4. Verify in Strapi”- Open the questionnaire in Strapi admin
- You should see it has a draft with your changes
- Preview the draft to verify it works correctly
| Flag | Long form | Type | Default | Required | Description |
|---|---|---|---|---|---|
-q |
--slug |
string | – | Yes | Questionnaire slug to reverse-sync |
-t |
--target |
enum | staging |
No | Target environment: prod, staging, dev |
| – | --dependent |
boolean | false |
No | Only sync the dependent variant (file under dependents/) |
| – | --main-only |
boolean | false |
No | Only sync the main (non-dependent) variant; skips dependents/, claims/, etc. |
| – | --dry-run |
boolean | false |
No | Show the diff without pushing changes to Strapi |
| – | --force |
boolean | false |
No | Skip the confirmation prompt |
--dependent and --main-only are mutually exclusive.
Examples
Section titled “Examples”Push to production with confirmation skip:
yarn reverse-sync:questionnaire -q household -t prod --forceSync only the dependent variant:
yarn reverse-sync:questionnaire -q household --dependentTroubleshooting
Section titled “Troubleshooting”| Issue | Cause | Fix |
|---|---|---|
| “Relation not found” warnings | Expected when quote-page or option-list components do not exist on the target environment | Link missing relations manually in the Strapi questionnaire editor after the draft is created |
| Diff shows unexpected changes | Someone else modified the questionnaire in Strapi since your last sync | Re-run a forward sync first (yarn sync:questionnaire -q <slug>) to update your local file, then re-apply your changes |
| “Cannot push to production” or wrong target | Target environment not specified or defaulting to staging | Use -t prod explicitly to target production |
| “Questionnaire file not found for slug” | Local file does not exist for the given slug | Verify the slug matches a file in src/syncedData/questionnaires/ (check subdirectories too) |
See also
Section titled “See also”- Sync Commands Reference – full CLI reference for reverse-sync flags
- Promote a Questionnaire – next step after reverse-syncing
- Strapi Transform Pipeline – how the reverse transform maps canonical format back to Strapi