{
  "openapi": "3.1.0",
  "info": {
    "title": "GitMoon API",
    "version": "1.0.0",
    "description": "Git hosting for people and AI agents. Every call acts as the GitMoon user who owns the API key (or OAuth token). Same operations as the MCP server at https://gitmoon.dev/mcp. Create an API key at https://gitmoon.dev/dashboard/settings/api-keys. GitMoon has no git push/clone, pull requests or issues; write files with commit_files.",
    "contact": {
      "name": "GitMoon",
      "url": "https://gitmoon.dev/integrations"
    }
  },
  "servers": [
    {
      "url": "https://gitmoon.dev/api/v1"
    }
  ],
  "externalDocs": {
    "description": "Setup guides for AI tools",
    "url": "https://gitmoon.dev/integrations"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "read",
      "description": "Read-only operations"
    },
    {
      "name": "write",
      "description": "Operations that change data or spend tokens"
    }
  ],
  "paths": {
    "/repos": {
      "get": {
        "operationId": "list_repositories",
        "summary": "List my repositories",
        "description": "List the repositories you own on GitMoon, newest activity first. Optional text filter on the name or description.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": false,
            "description": "Text to match in the name or description.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 30
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "create_repository",
        "summary": "Create a repository",
        "description": "Create a new repository in your GitMoon account. It is private unless you set visibility to PUBLIC. Fails if you already have a repository with the same name.",
        "tags": [
          "write"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Repository name, e.g. my-app."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "PRIVATE",
                      "PUBLIC"
                    ],
                    "default": "PRIVATE"
                  },
                  "default_branch": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60,
                    "default": "main"
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/repos/{repo}": {
      "get": {
        "operationId": "get_repository",
        "summary": "Get a repository",
        "description": "Get one repository: name, visibility, default branch, branches, file count and the latest commits.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo}/files": {
      "get": {
        "operationId": "list_files",
        "summary": "List files",
        "description": "List the files of a repository at a branch or commit (default branch when ref is empty). Optional folder prefix.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ref",
            "in": "query",
            "required": false,
            "description": "Branch name or full commit sha. Leave empty for the default branch.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "path",
            "in": "query",
            "required": false,
            "description": "Folder prefix, e.g. src/ . Empty lists every file.",
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo}/file": {
      "get": {
        "operationId": "read_file",
        "summary": "Read a file",
        "description": "Read one file by path at a branch or commit. Text files come back as text; other files as base64. Files over 1 MB are not returned.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "File path, e.g. src/index.ts",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 400
            }
          },
          {
            "name": "ref",
            "in": "query",
            "required": false,
            "description": "Branch name or full commit sha. Leave empty for the default branch.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo}/commits": {
      "post": {
        "operationId": "commit_files",
        "summary": "Commit files",
        "description": "Create, update and delete several files in ONE commit on a branch of your repository. Files you do not list stay as they are. Limits: 300 files, 5 MB per file, 15 MB per commit. Send expected_head_sha to fail instead of overwriting if someone else committed first. Set create_branch to make the bran…",
        "tags": [
          "write"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "branch": {
                    "type": "string",
                    "maxLength": 120,
                    "description": "Branch to commit to. Default: the default branch."
                  },
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000,
                    "description": "Commit message."
                  },
                  "files": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 300,
                    "items": {
                      "type": "object",
                      "properties": {
                        "path": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 400
                        },
                        "content": {
                          "type": "string",
                          "description": "New file content as UTF-8 text."
                        },
                        "content_base64": {
                          "type": "string",
                          "description": "New file content as base64 (images, fonts, binaries)."
                        },
                        "delete": {
                          "type": "boolean",
                          "description": "true to delete this file."
                        }
                      },
                      "required": [
                        "path"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "expected_head_sha": {
                    "type": "string",
                    "maxLength": 64,
                    "description": "Optional safety check: the branch head you based your change on."
                  },
                  "create_branch": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "message",
                  "files"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list_commits",
        "summary": "List commits",
        "description": "List commits of a repository, newest first. Optional branch filter.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "branch",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo}/branches": {
      "get": {
        "operationId": "list_branches",
        "summary": "List branches",
        "description": "List the branches of a repository with their head commit.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "create_branch",
        "summary": "Create a branch",
        "description": "Create a branch in your repository from another branch or a commit (default: the default branch).",
        "tags": [
          "write"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "New branch name, e.g. feature/login"
                  },
                  "from": {
                    "type": "string",
                    "maxLength": 120,
                    "description": "Branch name or commit sha to start from."
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/repos/{repo}/reviews": {
      "post": {
        "operationId": "run_ai_review",
        "summary": "Run AI review (spends tokens)",
        "description": "Run GitMoon's AI on a commit of your repository: CODE_REVIEW (default), AUTO_FIX, REFACTOR or DOCGEN. This SPENDS AI tokens from your GitMoon plan (monthly quota first, then bought token packs). Ask the user before running it. Returns the review text and the tokens used.",
        "tags": [
          "write"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "commit_sha": {
                    "type": "string",
                    "maxLength": 64,
                    "description": "Commit to review. Default: the latest commit."
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "CODE_REVIEW",
                      "AUTO_FIX",
                      "REFACTOR",
                      "DOCGEN"
                    ],
                    "default": "CODE_REVIEW"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/repos/{repo}/visibility": {
      "patch": {
        "operationId": "set_repository_visibility",
        "summary": "Set repository visibility",
        "description": "Make your repository PUBLIC (shown in Explore, anyone can read it) or PRIVATE. Only the owner can do this. Check with the user before making code public.",
        "tags": [
          "write"
        ],
        "parameters": [
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "description": "Repository id (UUID) or the name of one of your own repositories. Public repositories of other people can be read by id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "PUBLIC",
                      "PRIVATE"
                    ]
                  }
                },
                "required": [
                  "visibility"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/explore/repos": {
      "get": {
        "operationId": "search_public_repositories",
        "summary": "Search public repositories",
        "description": "Search public repositories in GitMoon Explore by name or description. Sort: trending (Kudos this week), top (all-time Kudos) or new.",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "trending",
                "top",
                "new"
              ],
              "default": "trending"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "A GitMoon API key (gitmoom_...) from Dashboard > Settings > API keys."
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ]
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      }
    }
  }
}