Sites

Edit a site's pages and code: commit to its source

Changed on

Applies 1 to 100 file operations to the site's main branch as one commit. To send a unified diff instead of whole files, use POST /sites/{id}/source/commits/diff. It does not deploy: to put the commit live, call POST /sites/{id}/deploy with commit_sha set to the returned sha.

Each operation is an upsert (the file's whole new content; text as UTF-8, binary files as base64 with encoding: base64) or a delete. Paths are relative to the repository root. .., .git/ and a leading / are refused, and so are environment files (.env, .env.*, .dev.vars): store secrets with POST /sites/{id}/secrets instead. The upserts together carry at most 4 MiB, and a path may appear in one operation only.

Pass expected_head_sha, the head_sha your edits are based on. If main has moved the call fails with 409 stale_head and error.head_sha, the current head: read the files you are changing again and retry against it. Without it, the call still fails the same way if main moves while the commit is pushed, so no one's work is ever overwritten.

Operations that leave every file as it was make no commit and answer changed: false with the current head, so retrying a commit that already landed is safe.

A repository that refuses the commit for another reason, such as a protected branch on a connected GitHub repository, answers 422 commit_rejected with its reason.

post/sites/{id}/source/commits

Request

  • Base URL
    https://api.crevio.co/v1
  • Auth
    API key in header Authorization

Path parameters

id, string required

The resource's ID, as returned in its id field

Headers

Idempotency-Key, string

Makes this write safe to retry: a repeat with the same key replays the first response instead of creating a second resource. Scoped to the account, remembered for 24 hours; reusing a key with a different payload is an error.

Request body

object required
message, string required

The commit message, 1 to 5000 characters.

operations, object[] required

1 to 100 file operations, applied together as one commit. A path may appear once. The upserts together carry at most 4 MiB.

expected_head_sha, string

The head_sha your edits are based on (from a source read or your last commit). If main is anywhere else the call fails with 409 stale_head and changes nothing. A prefix of 7 or more characters is accepted.

Response

The commit main now points at

object required
object, 'site_source_commit' required
sha, string required

The commit main now points at.

previous_sha, string required

The commit main pointed at before.

changed, boolean required

False when the operations left every file as it was: no commit was made and sha equals previous_sha.

Changes

    • warning

      added the new idempotency_error enum value to the error/type response property for the response status

    • warning

      added the new idempotency_error enum value to the error/type response property for the response status

    • warning

      added the new idempotency_error enum value to the error/type response property for the response status

    3 more changes in this revision