# dev.knotless.createGist

> Writes a dev.knotless.repo record whose kind is gist, named by a new TID, in the account logged in to this appview's web pages, and commits the files given to its main branch in one commit, as `knotless gist create` does. Requires the session cookie the pages' login sets: the appview writes with the session it keeps for that account. Clients holding their own session write the record and push themselves.

- 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.createGist)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.createGist/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.createGist/analytics)

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

Type: procedure · POST

### Input (application/json)

- `description` (string): What the gist is, shown above its files.
  - Constraints: maxLength: 3000, maxGraphemes: 300
- `files` (array, required): Its files, at the root of its main branch, each named once.
  - Constraints: minLength: 1, maxLength: 20
  - `items` (ref)
    - Reference: `#file`

### Output (application/json)

- `schema` (ref)
  - Reference: `dev.knotless.defs#repoMade`

### Errors

- `InvalidRequest`: No files, a file with no name or a name with a /, or two files of one name.
- `AuthenticationRequired`: No account is logged in to the pages, or its session has ended.

## #file (`dev.knotless.createGist#file`)

Type: object

A text file of a gist.

### Properties

- `content` (string, required): Its text, written as UTF-8.
  - Constraints: maxLength: 1000000
- `name` (string, required): Its name at the gist's root, with no /.
  - Constraints: maxLength: 255

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "file": {
      "description": "A text file of a gist.",
      "properties": {
        "content": {
          "description": "Its text, written as UTF-8.",
          "maxLength": 1000000,
          "type": "string"
        },
        "name": {
          "description": "Its name at the gist's root, with no /.",
          "maxLength": 255,
          "type": "string"
        }
      },
      "required": [
        "name",
        "content"
      ],
      "type": "object"
    },
    "main": {
      "description": "Writes a dev.knotless.repo record whose kind is gist, named by a new TID, in the account logged in to this appview's web pages, and commits the files given to its main branch in one commit, as `knotless gist create` does. Requires the session cookie the pages' login sets: the appview writes with the session it keeps for that account. Clients holding their own session write the record and push themselves.",
      "errors": [
        {
          "description": "No files, a file with no name or a name with a /, or two files of one name.",
          "name": "InvalidRequest"
        },
        {
          "description": "No account is logged in to the pages, or its session has ended.",
          "name": "AuthenticationRequired"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "description": {
              "description": "What the gist is, shown above its files.",
              "maxGraphemes": 300,
              "maxLength": 3000,
              "type": "string"
            },
            "files": {
              "description": "Its files, at the root of its main branch, each named once.",
              "items": {
                "ref": "#file",
                "type": "ref"
              },
              "maxLength": 20,
              "minLength": 1,
              "type": "array"
            }
          },
          "required": [
            "files"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "ref": "dev.knotless.defs#repoMade",
          "type": "ref"
        }
      },
      "type": "procedure"
    }
  },
  "description": "Creates a gist in the account logged in to this appview's pages.",
  "id": "dev.knotless.createGist",
  "lexicon": 1
}
```
