Git
Every project has a Git repository. Push files, download the repo and read its history over HTTPS with your API key. No git credentials to manage.
Push files
# Single file curl -X POST $API/{slug}/git/files \ -H "X-API-Key: $KEY" \ -d '{"path": "src/app.js", "content": "console.log(\"hello\")", "message": "Add app.js"}' # Batch: up to 500 files in one atomic commit, deployed after the push curl -X POST $API/{slug}/git/files/batch \ -H "X-API-Key: $KEY" \ -d '{ "files": [ {"path": "index.html", "content": "<h1>Hello</h1>"}, {"path": "style.css", "content": "body { margin: 0; }"} ], "message": "Initial commit", "deploy": true }'
Plain-text content is base64-encoded for you. "deploy": true starts a deploy once the commit lands; see Deployment.
Download the repo
Working on a project you don't have on disk? Download it with your key instead of cloning:
curl -L "$API/{slug}/git/archive" -H "X-API-Key: $KEY" -o {slug}.zip unzip {slug}.zip # unpacks into ./{slug}-main/ # options: ?ref=<branch, tag or sha> (default main), &format=tar.gz (default zip)
Edit locally, then push the changes back with POST /{slug}/git/files/batch.
Read history, files and diffs
Every read takes an optional ref: a branch, tag or commit SHA, main by default.
# Commit history, newest first (limit up to 50; add &path=src/app.js for one file) curl "$API/{slug}/git/commits?limit=20&page=1" -H "X-API-Key: $KEY" # One commit: changed files and line stats; diff=true adds the unified diff (up to 1 MB) curl "$API/{slug}/git/commits/{sha}?diff=true" -H "X-API-Key: $KEY" # A file, or a directory listing, at any ref curl "$API/{slug}/git/files?path=src/app.js&ref={sha}" -H "X-API-Key: $KEY" # Every path in the repo in one call (up to 10,000 entries) curl "$API/{slug}/git/tree?ref=main" -H "X-API-Key: $KEY"
- A file comes back as
{"type": "file", "content", "text", "sha", "size"}:contentis base64,textis UTF-8 ornullfor binary files. Files over 1 MB return"too_large": trueand no content. - A directory comes back as
{"type": "dir", "entries": [...]}. - An unknown ref, SHA or path returns
404 GIT_NOT_FOUND. An empty repository returns"commits": [].
Collaborators
curl -X POST $API/{slug}/collaborators \ -H "X-API-Key: $KEY" \ -d '{"email": "teammate@company.com", "permission": "write"}' curl $API/{slug}/collaborators -H "X-API-Key: $KEY" curl -X DELETE $API/{slug}/collaborators/teammate@company.com -H "X-API-Key: $KEY"
Collaborators push code to the repository. Domains stay with the project's owner: see Domains.
Push with git
If your git.mosaic.site account has a password, the usual workflow works too. With auto_deploy on, each push deploys.
git clone https://git.mosaic.site/{username}/{slug}.git cd {slug} git add . && git commit -m "My app" && git push
Endpoints
| Endpoint | Method | Description |
|---|---|---|
| /{slug}/git/files | POST | Push one file |
| /{slug}/git/files/batch | POST | Push up to 500 files ("deploy": true to deploy) |
| /{slug}/git/archive | GET | The whole repo as one download (ref, format=zip|tar.gz) |
| /{slug}/git/commits | GET | Commit history (ref, path, limit up to 50, page) |
| /{slug}/git/commits/{sha} | GET | One commit and its changed files (diff=true for the diff) |
| /{slug}/git/files | GET | Read a file or list a directory at any ref |
| /{slug}/git/tree | GET | Every path in the repo at a ref |
| /{slug}/collaborators | GET POST | List or add collaborators |
| /{slug}/collaborators/{email} | DEL | Remove a collaborator |