# dev.knotless.createCommit

> Fails with 409 when a change touches a path that moved since `base`, or when the branch kept moving under the batch.

- Kind: procedure
- Authority: knotless.dev
- Lexicon: 1
- Published by [lexicons.knotless.dev](https://lexicon.garden/identity/did:plc:yqsg7znbbhfmj3a2nrpnaerk), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.createCommit)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.createCommit/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.createCommit/analytics)

## Procedure (`dev.knotless.createCommit`)

Type: procedure · POST

### Input (application/json)

- `author` (ref)
  - Reference: `#author`
- `base` (string): The hex object ID of the commit the changes were made against. Without it the changes apply to whatever the branch holds.
  - Constraints: minLength: 40, maxLength: 64
- `branch` (string, required): Without refs/heads/. Created when absent, from `base`, or else from the default branch's tip.
  - Constraints: maxLength: 255
- `changes` (array, required)
  - `items` (ref)
    - Reference: `#change`
- `message` (string, required)
  - Constraints: maxLength: 20000
- `name` (string, required): The repository's name: its dev.knotless.repo record key.
  - Constraints: maxLength: 100
- `repo` (string · did, required): The repository's owner.

### Output (application/json)

- `batched` (integer, required): How many commits went out in the write that carried this one.
  - Constraints: minimum: 0
- `changed` (boolean, required): False when the changes left the tree as it was, and no commit was made.
- `parent` (string): The hex object ID the commit was built on; absent for a branch's first commit.
  - Constraints: minLength: 40, maxLength: 64
- `sha` (string, required): The hex object ID of the commit, or of the branch tip when nothing changed.
  - Constraints: minLength: 40, maxLength: 64

## #author (`dev.knotless.createCommit#author`)

Type: object

Who the commit names as its author, when not the gateway's default.

### Properties

- `email` (string, required)
  - Constraints: maxLength: 1000
- `name` (string, required)
  - Constraints: maxLength: 1000

## #change (`dev.knotless.createCommit#change`)

Type: object

One path written, edited or deleted.

### Properties

- `data` (bytes): The file's new contents; absent, with no `edits`, to delete it.
- `edits` (array): Replacements in the file as the commit's parent holds it, made in order, when `data` is absent. The file keeps its mode. Fails with 409 when one's `old` is not in the file exactly once.
  - `items` (ref)
    - Reference: `#edit`
- `executable` (boolean)
  - Constraints: default: false
- `path` (string, required): Relative to the repository root.
  - Constraints: maxLength: 4096

## #edit (`dev.knotless.createCommit#edit`)

Type: object

One replacement in a text file.

### Properties

- `new` (string, required): What takes its place.
  - Constraints: maxLength: 20000
- `old` (string, required): Text the file holds exactly once.
  - Constraints: minLength: 1, maxLength: 20000

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "author": {
      "description": "Who the commit names as its author, when not the gateway's default.",
      "properties": {
        "email": {
          "maxLength": 1000,
          "type": "string"
        },
        "name": {
          "maxLength": 1000,
          "type": "string"
        }
      },
      "required": [
        "name",
        "email"
      ],
      "type": "object"
    },
    "change": {
      "description": "One path written, edited or deleted.",
      "properties": {
        "data": {
          "description": "The file's new contents; absent, with no `edits`, to delete it.",
          "type": "bytes"
        },
        "edits": {
          "description": "Replacements in the file as the commit's parent holds it, made in order, when `data` is absent. The file keeps its mode. Fails with 409 when one's `old` is not in the file exactly once.",
          "items": {
            "ref": "#edit",
            "type": "ref"
          },
          "type": "array"
        },
        "executable": {
          "default": false,
          "type": "boolean"
        },
        "path": {
          "description": "Relative to the repository root.",
          "maxLength": 4096,
          "type": "string"
        }
      },
      "required": [
        "path"
      ],
      "type": "object"
    },
    "edit": {
      "description": "One replacement in a text file.",
      "properties": {
        "new": {
          "description": "What takes its place.",
          "maxLength": 20000,
          "type": "string"
        },
        "old": {
          "description": "Text the file holds exactly once.",
          "maxLength": 20000,
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "old",
        "new"
      ],
      "type": "object"
    },
    "main": {
      "description": "Fails with 409 when a change touches a path that moved since `base`, or when the branch kept moving under the batch.",
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "author": {
              "ref": "#author",
              "type": "ref"
            },
            "base": {
              "description": "The hex object ID of the commit the changes were made against. Without it the changes apply to whatever the branch holds.",
              "maxLength": 64,
              "minLength": 40,
              "type": "string"
            },
            "branch": {
              "description": "Without refs/heads/. Created when absent, from `base`, or else from the default branch's tip.",
              "maxLength": 255,
              "type": "string"
            },
            "changes": {
              "items": {
                "ref": "#change",
                "type": "ref"
              },
              "type": "array"
            },
            "message": {
              "maxLength": 20000,
              "type": "string"
            },
            "name": {
              "description": "The repository's name: its dev.knotless.repo record key.",
              "maxLength": 100,
              "type": "string"
            },
            "repo": {
              "description": "The repository's owner.",
              "format": "did",
              "type": "string"
            }
          },
          "required": [
            "repo",
            "name",
            "branch",
            "message",
            "changes"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "batched": {
              "description": "How many commits went out in the write that carried this one.",
              "minimum": 0,
              "type": "integer"
            },
            "changed": {
              "description": "False when the changes left the tree as it was, and no commit was made.",
              "type": "boolean"
            },
            "parent": {
              "description": "The hex object ID the commit was built on; absent for a branch's first commit.",
              "maxLength": 64,
              "minLength": 40,
              "type": "string"
            },
            "sha": {
              "description": "The hex object ID of the commit, or of the branch tip when nothing changed.",
              "maxLength": 64,
              "minLength": 40,
              "type": "string"
            }
          },
          "required": [
            "sha",
            "changed",
            "batched"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "description": "Commits file changes to a branch through a gateway its owner has delegated writes to, without a clone. Commits to one branch that arrive together are built into one chain and written as one ref update. Requires a service token from the caller's PDS, audience the gateway's DID, for this method; the caller must be the owner or a collaborator.",
  "id": "dev.knotless.createCommit",
  "lexicon": 1
}
```
