Versions
A version is a checkpoint of all of a project’s files on its main branch. Under the hood every version is a commit in the project’s native git store, so ids are commit SHAs. Creating a version also syncs to a connected GitHub repository when one is linked.
List versions
Section titled “List versions”GET /api/v1/projects/{id}/versionsReturns the latest 50 versions, newest first: { versions } — each { id, message, author_id, created_at }.
curl "https://www.frontend.co/api/v1/projects/$ID/versions" \ -H "Authorization: Bearer $FRONTEND_API_KEY"const versions = await client.versions.list(projectId)Create a version
Section titled “Create a version”POST /api/v1/projects/{id}/versionsSnapshots all current project files (there is no staging index). Body: message (required). Returns { version: { id, message } } with 201.
curl -X POST "https://www.frontend.co/api/v1/projects/$ID/versions" \ -H "Authorization: Bearer $FRONTEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Before refactor" }'const { id } = await client.versions.create(projectId, 'Before refactor')Get a version
Section titled “Get a version”GET /api/v1/projects/{id}/versions/{versionId}Returns the version plus the project files as they were at that point: { version: { id, message, author_id, created_at, files } }.
const version = await client.versions.get(projectId, id)Restore a version
Section titled “Restore a version”POST /api/v1/projects/{id}/versions/{versionId}/restoreMakes that version’s files current again. The restore is recorded as a new version on main, so nothing is lost. Returns { restored, version: { id } } where restored is the id you passed and version.id is the new version.
await client.versions.restore(projectId, id)