Automate · Lesson 13 of 20
Keep your workspace in Git
Store collections as files next to your code, review them in pull requests and sync both ways without overwriting anyone.
Your API tests change with your code, so they deserve the same history, branches and reviews. swc workspace pull writes a workspace as plain JSON files you can commit; swc workspace push saves your edits back. The files use the same layout as Export workspace in the app, so either side can read them.
Pull the workspace into your repository
swc login # once: paste an API key from Account → API keys
swc workspace pull api/ -w "Shop team"You get:
api/
swastik.json which collections and environments are in the folder
collections/shop-api.json one readable file per collection
environments/staging.json one per environment
globals.jsonCommit the folder. Secret values and current values are never written to these files, so they are safe to commit.
Change, review, push
- Edit the files, or keep working in the app and run
swc workspace pull api/again; files change only where something really changed, so diffs stay small. - Open a pull request. Reviewers see exactly which requests, tests and variables changed.
- After the merge, save the files back to the workspace:
swc workspace status api/ # what would change, without saving
swc workspace push api/No lost work
Both commands are careful about other people's changes:
pushsaves only files that changed, each against the version you pulled. If someone edited the same collection in the app since,pushstops with a conflict instead of overwriting their work. Pull, merge, push again (or--forceif you are sure).pullnever overwrites a file you edited and have not pushed. It keeps your file and tells you.- A secret left blank in a file keeps the value saved in the account.
pushnever deletes anything in the account.
Renaming a collection in the app keeps its file name, so Git shows an edit, not a delete and an add.
Run it from CI
A job on your main branch can keep the account up to date automatically:
SWC_API_KEY=${{ secrets.SWC_API_KEY }} swc workspace push api/What you learned
swc workspace pullwrites collections, environments and globals as reviewable JSON;pushsaves them back.- Conflicts are reported, unpushed edits are kept and secrets never reach the files.
Next: give front-end developers an API to build against before the real one exists.