{
  "openapi": "3.1.0",
  "info": {
    "title": "Keko API",
    "description": "Keko accounts. Send `Authorization: Bearer <session token or JWT>` on every request except the public ones. Sign-in, device codes, JWTs and the JWKS are Better Auth’s, under `/api/auth`.",
    "version": "1.0.0"
  },
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "JsonValue": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JsonValue"
            }
          },
          {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "$ref": "#/components/schemas/JsonValue"
            },
            "examples": [
              {}
            ]
          }
        ]
      }
    }
  },
  "paths": {
    "/v1/health": {
      "get": {
        "tags": [
          "api"
        ],
        "summary": "Whether the API is up",
        "operationId": "getHealth",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/openapi.json": {
      "get": {
        "tags": [
          "api"
        ],
        "summary": "This API as an OpenAPI 3.1 document",
        "operationId": "getOpenapiJson",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/me": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "Who the session token or JWT belongs to",
        "operationId": "getMe",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "image": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "email",
                        "image"
                      ],
                      "additionalProperties": false
                    },
                    "analyticsReference": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "user",
                    "analyticsReference"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlist": {
      "post": {
        "tags": [
          "waitlist"
        ],
        "summary": "Asks to be emailed when the Mac app can be downloaded (10 tries per client in 10 minutes)",
        "operationId": "postWaitlist",
        "parameters": [],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 254
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/github/install": {
      "post": {
        "tags": [
          "github"
        ],
        "summary": "The GitHub App’s install page for you, to open in a browser (10 minutes)",
        "operationId": "postGithubInstall",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/github/installations": {
      "get": {
        "tags": [
          "github"
        ],
        "summary": "The GitHub App’s installations you can use",
        "operationId": "getGithubInstallations",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "installations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "number"
                          },
                          "accountLogin": {
                            "type": "string"
                          },
                          "accountType": {
                            "type": "string"
                          },
                          "repositorySelection": {
                            "type": "string"
                          },
                          "suspended": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "accountLogin",
                          "accountType",
                          "repositorySelection",
                          "suspended"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "installations"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/github/repositories": {
      "get": {
        "tags": [
          "github"
        ],
        "summary": "The repositories you can reach across your installations, a page at a time",
        "operationId": "getGithubRepositories",
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "perPage",
            "in": "query",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "repositories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "number"
                          },
                          "fullName": {
                            "type": "string"
                          },
                          "private": {
                            "type": "boolean"
                          },
                          "defaultBranch": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "installationId": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "fullName",
                          "private",
                          "defaultBranch",
                          "installationId"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "repositories",
                    "next"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/github/token": {
      "post": {
        "tags": [
          "github"
        ],
        "summary": "A GitHub token for one repository: yours for read and write, the App’s for review",
        "operationId": "postGithubToken",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "user",
                        "installation"
                      ]
                    }
                  },
                  "required": [
                    "token",
                    "expiresAt",
                    "kind"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "repository": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9-]{1,39}\\/[A-Za-z0-9._-]{1,100}$"
                  },
                  "purpose": {
                    "type": "string",
                    "enum": [
                      "read",
                      "write",
                      "review"
                    ]
                  }
                },
                "required": [
                  "repository",
                  "purpose"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/github/events": {
      "get": {
        "tags": [
          "github"
        ],
        "summary": "Webhook deliveries about repositories in your installations, oldest first, after a cursor (kept 14 days)",
        "operationId": "getGithubEvents",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "deliveryId": {
                            "type": "string"
                          },
                          "event": {
                            "type": "string"
                          },
                          "action": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "repository": {
                            "type": "string"
                          },
                          "installationId": {
                            "type": "number"
                          },
                          "receivedAt": {
                            "type": "string"
                          },
                          "payload": {
                            "$ref": "#/components/schemas/JsonValue"
                          }
                        },
                        "required": [
                          "deliveryId",
                          "event",
                          "action",
                          "repository",
                          "installationId",
                          "receivedAt",
                          "payload"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "events",
                    "next"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/github/grant": {
      "post": {
        "tags": [
          "github"
        ],
        "summary": "An engine’s grant to ask for your GitHub tokens and AI accounts while your apps are away (24 hours, renewable while your session lives)",
        "operationId": "postGithubGrant",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "grant": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "grant",
                    "expiresAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/variables": {
      "get": {
        "tags": [
          "variables"
        ],
        "summary": "A project’s variables for you: names and scopes, never values (`thread` adds that thread’s own)",
        "operationId": "getVariables",
        "parameters": [
          {
            "name": "project",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300
            }
          },
          {
            "name": "thread",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "variables": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string",
                            "enum": [
                              "shared",
                              "personal",
                              "thread"
                            ]
                          },
                          "updatedAt": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "name",
                          "scope",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "variables"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "variables"
        ],
        "summary": "Sets a shared, personal or thread value; it’s stored encrypted and only engines read it back (thread values are write-only)",
        "operationId": "putVariables",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "variable": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "scope": {
                          "type": "string",
                          "enum": [
                            "shared",
                            "personal",
                            "thread"
                          ]
                        },
                        "updatedAt": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "name",
                        "scope",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "variable"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "project": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "shared",
                      "personal",
                      "thread"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string",
                    "maxLength": 32768
                  },
                  "thread": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "project",
                  "scope",
                  "name",
                  "value"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "variables"
        ],
        "summary": "Removes a value; it can be put back for a day (`/v1/variables/restore`)",
        "operationId": "deleteVariables",
        "parameters": [
          {
            "name": "project",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "shared",
                "personal",
                "thread"
              ]
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "thread",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/variables/restore": {
      "post": {
        "tags": [
          "variables"
        ],
        "summary": "Puts back a value removed in the last day (Undo)",
        "operationId": "postVariablesRestore",
        "parameters": [
          {
            "name": "project",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "shared",
                "personal",
                "thread"
              ]
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "thread",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "variable": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "scope": {
                          "type": "string",
                          "enum": [
                            "shared",
                            "personal",
                            "thread"
                          ]
                        },
                        "updatedAt": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "name",
                        "scope",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "variable"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/variables/reveal": {
      "post": {
        "tags": [
          "variables"
        ],
        "summary": "One shared or personal value, for the eye button in Settings (logged)",
        "operationId": "postVariablesReveal",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "value"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "project": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "shared",
                      "personal"
                    ]
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "project",
                  "scope",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/variables/for-engine": {
      "post": {
        "tags": [
          "variables"
        ],
        "summary": "Every value a thread runs with, for its engine to write on the device (an engine’s grant only, so thread values stay write-only to apps; logged)",
        "operationId": "postVariablesForEngine",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "values": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string",
                            "enum": [
                              "shared",
                              "personal",
                              "thread"
                            ]
                          },
                          "value": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "name",
                          "scope",
                          "value"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "values"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "project": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "thread": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "project"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "Your AI accounts in the order runs use them, without their secrets, and what this API does with them (`capabilities`)",
        "operationId": "getAccounts",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "claude-subscription",
                              "chatgpt-subscription",
                              "copilot-subscription",
                              "anthropic-api",
                              "openai-compatible",
                              "api-key"
                            ]
                          },
                          "label": {
                            "type": "string"
                          },
                          "order": {
                            "type": "number"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "ok",
                              "invalid_token",
                              "plan_not_allowed",
                              "usage_limit",
                              "unavailable"
                            ]
                          },
                          "resetsAt": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "lastError": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "addedAt": {
                            "type": "number"
                          },
                          "updatedAt": {
                            "type": "number"
                          },
                          "baseUrl": {
                            "type": "string"
                          },
                          "providerId": {
                            "type": "string"
                          },
                          "authStyle": {
                            "type": "string",
                            "enum": [
                              "x-api-key",
                              "bearer"
                            ]
                          },
                          "api": {
                            "type": "string",
                            "enum": [
                              "openai-completions",
                              "openai-responses"
                            ]
                          },
                          "models": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "providerAccountId": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "label",
                          "order",
                          "state",
                          "resetsAt",
                          "lastError",
                          "addedAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "capabilities": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "accounts",
                    "capabilities"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "Adds an AI account; its secrets are stored encrypted and never come back to apps. An id already there answers 409 `exists`, one its owner removed 409 `removed`",
        "operationId": "postAccounts",
        "parameters": [],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "account": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "claude-subscription",
                            "chatgpt-subscription",
                            "copilot-subscription",
                            "anthropic-api",
                            "openai-compatible",
                            "api-key"
                          ]
                        },
                        "label": {
                          "type": "string"
                        },
                        "order": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "ok",
                            "invalid_token",
                            "plan_not_allowed",
                            "usage_limit",
                            "unavailable"
                          ]
                        },
                        "resetsAt": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "lastError": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "addedAt": {
                          "type": "number"
                        },
                        "updatedAt": {
                          "type": "number"
                        },
                        "baseUrl": {
                          "type": "string"
                        },
                        "providerId": {
                          "type": "string"
                        },
                        "authStyle": {
                          "type": "string",
                          "enum": [
                            "x-api-key",
                            "bearer"
                          ]
                        },
                        "api": {
                          "type": "string",
                          "enum": [
                            "openai-completions",
                            "openai-responses"
                          ]
                        },
                        "models": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "providerAccountId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "kind",
                        "label",
                        "order",
                        "state",
                        "resetsAt",
                        "lastError",
                        "addedAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "account"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "account": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "claude-subscription"
                          },
                          "id": {
                            "type": "string",
                            "pattern": "^[0-9a-f-]{36}$"
                          },
                          "label": {
                            "type": "string"
                          },
                          "token": {
                            "type": "string",
                            "maxLength": 8192,
                            "pattern": "^sk-ant-oat01-[A-Za-z0-9_-]{20,}$"
                          }
                        },
                        "required": [
                          "kind",
                          "label",
                          "token"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "chatgpt-subscription",
                              "copilot-subscription"
                            ]
                          },
                          "id": {
                            "type": "string",
                            "pattern": "^[0-9a-f-]{36}$"
                          },
                          "label": {
                            "type": "string"
                          },
                          "credential": {
                            "type": "object",
                            "properties": {
                              "access": {
                                "type": "string",
                                "maxLength": 8192
                              },
                              "refresh": {
                                "type": "string",
                                "maxLength": 8192
                              },
                              "expires": {
                                "type": "number"
                              },
                              "accountId": {
                                "type": "string",
                                "maxLength": 200
                              },
                              "enterpriseUrl": {
                                "type": "string",
                                "maxLength": 500
                              },
                              "availableModelIds": {
                                "maxItems": 1000,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 300
                                }
                              }
                            },
                            "required": [
                              "access",
                              "refresh",
                              "expires"
                            ]
                          }
                        },
                        "required": [
                          "kind",
                          "label",
                          "credential"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "anthropic-api"
                          },
                          "id": {
                            "type": "string",
                            "pattern": "^[0-9a-f-]{36}$"
                          },
                          "label": {
                            "type": "string"
                          },
                          "baseUrl": {
                            "type": "string",
                            "format": "uri"
                          },
                          "credential": {
                            "type": "string",
                            "maxLength": 8192
                          },
                          "authStyle": {
                            "type": "string",
                            "enum": [
                              "x-api-key",
                              "bearer"
                            ]
                          },
                          "headers": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "maxLength": 200
                            },
                            "additionalProperties": {
                              "type": "string",
                              "maxLength": 8192
                            },
                            "examples": [
                              {}
                            ]
                          },
                          "models": {
                            "maxItems": 1000,
                            "type": "array",
                            "items": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 300
                            }
                          }
                        },
                        "required": [
                          "kind",
                          "label",
                          "credential",
                          "authStyle"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "openai-compatible"
                          },
                          "id": {
                            "type": "string",
                            "pattern": "^[0-9a-f-]{36}$"
                          },
                          "label": {
                            "type": "string"
                          },
                          "baseUrl": {
                            "type": "string",
                            "format": "uri"
                          },
                          "api": {
                            "type": "string",
                            "enum": [
                              "openai-completions",
                              "openai-responses"
                            ]
                          },
                          "credential": {
                            "type": "string",
                            "maxLength": 8192
                          },
                          "headers": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "maxLength": 200
                            },
                            "additionalProperties": {
                              "type": "string",
                              "maxLength": 8192
                            },
                            "examples": [
                              {}
                            ]
                          },
                          "models": {
                            "maxItems": 1000,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 300
                                }
                              },
                              "required": [
                                "id"
                              ],
                              "additionalProperties": true
                            }
                          },
                          "compat": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "$ref": "#/components/schemas/JsonValue"
                            },
                            "examples": [
                              {}
                            ]
                          }
                        },
                        "required": [
                          "kind",
                          "label",
                          "baseUrl",
                          "api",
                          "credential",
                          "models"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "api-key"
                          },
                          "id": {
                            "type": "string",
                            "pattern": "^[0-9a-f-]{36}$"
                          },
                          "label": {
                            "type": "string"
                          },
                          "providerId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "credential": {
                            "type": "string",
                            "maxLength": 8192
                          }
                        },
                        "required": [
                          "kind",
                          "label",
                          "providerId",
                          "credential"
                        ]
                      }
                    ]
                  },
                  "state": {
                    "default": "ok",
                    "type": "string",
                    "enum": [
                      "ok",
                      "invalid_token",
                      "plan_not_allowed",
                      "usage_limit",
                      "unavailable"
                    ]
                  },
                  "resetsAt": {
                    "default": null,
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                },
                "required": [
                  "account"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/accounts/order": {
      "put": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "The order runs use your AI accounts in",
        "operationId": "putAccountsOrder",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "claude-subscription",
                              "chatgpt-subscription",
                              "copilot-subscription",
                              "anthropic-api",
                              "openai-compatible",
                              "api-key"
                            ]
                          },
                          "label": {
                            "type": "string"
                          },
                          "order": {
                            "type": "number"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "ok",
                              "invalid_token",
                              "plan_not_allowed",
                              "usage_limit",
                              "unavailable"
                            ]
                          },
                          "resetsAt": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "lastError": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "addedAt": {
                            "type": "number"
                          },
                          "updatedAt": {
                            "type": "number"
                          },
                          "baseUrl": {
                            "type": "string"
                          },
                          "providerId": {
                            "type": "string"
                          },
                          "authStyle": {
                            "type": "string",
                            "enum": [
                              "x-api-key",
                              "bearer"
                            ]
                          },
                          "api": {
                            "type": "string",
                            "enum": [
                              "openai-completions",
                              "openai-responses"
                            ]
                          },
                          "models": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "providerAccountId": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "label",
                          "order",
                          "state",
                          "resetsAt",
                          "lastError",
                          "addedAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "accounts"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 64
                    }
                  }
                },
                "required": [
                  "ids"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/accounts/for-engine": {
      "get": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "Your AI accounts with their secrets, for an engine (a JWT or an engine’s grant; every read is logged)",
        "operationId": "getAccountsForEngine",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "$ref": "#/components/schemas/JsonValue"
                        },
                        "examples": [
                          {}
                        ]
                      }
                    }
                  },
                  "required": [
                    "accounts"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/for-engine/{id}": {
      "patch": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "What an engine learned about an account: refreshed sign-in tokens, its state (logged)",
        "operationId": "patchAccountsForEngineById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "credential": {
                    "type": "object",
                    "properties": {
                      "access": {
                        "type": "string",
                        "maxLength": 8192
                      },
                      "refresh": {
                        "type": "string",
                        "maxLength": 8192
                      },
                      "expires": {
                        "type": "number"
                      },
                      "accountId": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "enterpriseUrl": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "availableModelIds": {
                        "maxItems": 1000,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 300
                        }
                      }
                    },
                    "required": [
                      "access",
                      "refresh",
                      "expires"
                    ]
                  },
                  "signedInAt": {
                    "type": "number"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "invalid_token",
                      "plan_not_allowed",
                      "usage_limit",
                      "unavailable"
                    ]
                  },
                  "resetsAt": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "lastError": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}": {
      "patch": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "Renames an account, edits an endpoint’s models, or stores new secrets after signing in again",
        "operationId": "patchAccountsById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "account": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "claude-subscription",
                            "chatgpt-subscription",
                            "copilot-subscription",
                            "anthropic-api",
                            "openai-compatible",
                            "api-key"
                          ]
                        },
                        "label": {
                          "type": "string"
                        },
                        "order": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "ok",
                            "invalid_token",
                            "plan_not_allowed",
                            "usage_limit",
                            "unavailable"
                          ]
                        },
                        "resetsAt": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "lastError": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "addedAt": {
                          "type": "number"
                        },
                        "updatedAt": {
                          "type": "number"
                        },
                        "baseUrl": {
                          "type": "string"
                        },
                        "providerId": {
                          "type": "string"
                        },
                        "authStyle": {
                          "type": "string",
                          "enum": [
                            "x-api-key",
                            "bearer"
                          ]
                        },
                        "api": {
                          "type": "string",
                          "enum": [
                            "openai-completions",
                            "openai-responses"
                          ]
                        },
                        "models": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "providerAccountId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "kind",
                        "label",
                        "order",
                        "state",
                        "resetsAt",
                        "lastError",
                        "addedAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "account"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "models": {
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 300
                    }
                  },
                  "token": {
                    "type": "string",
                    "maxLength": 8192
                  },
                  "credential": {
                    "type": "object",
                    "properties": {
                      "access": {
                        "type": "string",
                        "maxLength": 8192
                      },
                      "refresh": {
                        "type": "string",
                        "maxLength": 8192
                      },
                      "expires": {
                        "type": "number"
                      },
                      "accountId": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "enterpriseUrl": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "availableModelIds": {
                        "maxItems": 1000,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 300
                        }
                      }
                    },
                    "required": [
                      "access",
                      "refresh",
                      "expires"
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "Removes an account; it can be put back for a day",
        "operationId": "deleteAccountsById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}/restore": {
      "post": {
        "tags": [
          "ai-accounts"
        ],
        "summary": "Puts back an account removed in the last day (Undo)",
        "operationId": "postAccountsByIdRestore",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "account": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "claude-subscription",
                            "chatgpt-subscription",
                            "copilot-subscription",
                            "anthropic-api",
                            "openai-compatible",
                            "api-key"
                          ]
                        },
                        "label": {
                          "type": "string"
                        },
                        "order": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "ok",
                            "invalid_token",
                            "plan_not_allowed",
                            "usage_limit",
                            "unavailable"
                          ]
                        },
                        "resetsAt": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "lastError": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "addedAt": {
                          "type": "number"
                        },
                        "updatedAt": {
                          "type": "number"
                        },
                        "baseUrl": {
                          "type": "string"
                        },
                        "providerId": {
                          "type": "string"
                        },
                        "authStyle": {
                          "type": "string",
                          "enum": [
                            "x-api-key",
                            "bearer"
                          ]
                        },
                        "api": {
                          "type": "string",
                          "enum": [
                            "openai-completions",
                            "openai-responses"
                          ]
                        },
                        "models": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "providerAccountId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "kind",
                        "label",
                        "order",
                        "state",
                        "resetsAt",
                        "lastError",
                        "addedAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "account"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/export": {
      "get": {
        "tags": [
          "account"
        ],
        "summary": "Everything this API keeps about you, without secrets, as JSON",
        "operationId": "getAccountExport",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "keko.account-export"
                    },
                    "version": {
                      "type": "number",
                      "const": 1
                    },
                    "exportedAt": {
                      "type": "string"
                    },
                    "user": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "image": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "createdAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "email",
                        "image",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    "signIns": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "provider": {
                            "type": "string"
                          },
                          "accountId": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "provider",
                          "accountId",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "aiAccounts": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "variables": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "project": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "thread": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "project",
                          "scope",
                          "name",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "github": {
                      "type": "object",
                      "properties": {
                        "installations": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "accountLogin": {
                                "type": "string"
                              },
                              "accountType": {
                                "type": "string"
                              },
                              "repositorySelection": {
                                "type": "string"
                              },
                              "suspended": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "id",
                              "accountLogin",
                              "accountType",
                              "repositorySelection",
                              "suspended"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "installations"
                      ],
                      "additionalProperties": false
                    },
                    "billing": {
                      "type": "object",
                      "properties": {
                        "plan": {
                          "type": "string"
                        },
                        "subscriptionStatus": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "renewsAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "hasStripeCustomer": {
                          "type": "boolean"
                        },
                        "usage": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "period": {
                                "type": "string"
                              },
                              "seconds": {
                                "type": "number"
                              },
                              "overageSeconds": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "period",
                              "seconds",
                              "overageSeconds"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "plan",
                        "subscriptionStatus",
                        "renewsAt",
                        "hasStripeCustomer",
                        "usage"
                      ],
                      "additionalProperties": false
                    },
                    "waitlist": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "email": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string"
                          },
                          "joinedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "email",
                          "source",
                          "joinedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "deletion": {
                      "type": "object",
                      "properties": {
                        "deletion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "requestedAt": {
                                  "type": "string"
                                },
                                "deleteAt": {
                                  "type": "string"
                                },
                                "state": {
                                  "type": "string",
                                  "enum": [
                                    "scheduled",
                                    "deleting"
                                  ]
                                }
                              },
                              "required": [
                                "requestedAt",
                                "deleteAt",
                                "state"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cancelledAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "graceDays": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "deletion",
                        "cancelledAt",
                        "graceDays"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "kind",
                    "version",
                    "exportedAt",
                    "user",
                    "signIns",
                    "aiAccounts",
                    "variables",
                    "github",
                    "billing",
                    "waitlist",
                    "deletion"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/deletion": {
      "get": {
        "tags": [
          "account"
        ],
        "summary": "Whether your account is scheduled for deletion, and when",
        "operationId": "getAccountDeletion",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deletion": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "requestedAt": {
                              "type": "string"
                            },
                            "deleteAt": {
                              "type": "string"
                            },
                            "state": {
                              "type": "string",
                              "enum": [
                                "scheduled",
                                "deleting"
                              ]
                            }
                          },
                          "required": [
                            "requestedAt",
                            "deleteAt",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cancelledAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "graceDays": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "deletion",
                    "cancelledAt",
                    "graceDays"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "account"
        ],
        "summary": "Schedules your account’s deletion after the grace period and signs you out everywhere; signing in again cancels it",
        "operationId": "postAccountDeletion",
        "parameters": [],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deletion": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "requestedAt": {
                              "type": "string"
                            },
                            "deleteAt": {
                              "type": "string"
                            },
                            "state": {
                              "type": "string",
                              "enum": [
                                "scheduled",
                                "deleting"
                              ]
                            }
                          },
                          "required": [
                            "requestedAt",
                            "deleteAt",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cancelledAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "graceDays": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "deletion",
                    "cancelledAt",
                    "graceDays"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 320
                  }
                },
                "required": [
                  "confirm"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "account"
        ],
        "summary": "Cancels your account’s scheduled deletion",
        "operationId": "deleteAccountDeletion",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deletion": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "requestedAt": {
                              "type": "string"
                            },
                            "deleteAt": {
                              "type": "string"
                            },
                            "state": {
                              "type": "string",
                              "enum": [
                                "scheduled",
                                "deleting"
                              ]
                            }
                          },
                          "required": [
                            "requestedAt",
                            "deleteAt",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cancelledAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "graceDays": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "deletion",
                    "cancelledAt",
                    "graceDays"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/deletions": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "Deleted accounts’ ids in the order they were deleted, for engines to delete their side (the usage token)",
        "operationId": "getDeletions",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "userIds",
                    "next"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/billing": {
      "get": {
        "tags": [
          "billing"
        ],
        "summary": "Your plan, this month’s Keko Cloud hours, and your overage settings",
        "operationId": "getBilling",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "plan": {
                      "type": "string",
                      "enum": [
                        "free",
                        "pro"
                      ]
                    },
                    "status": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "renewsAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "cancelAtPeriodEnd": {
                      "type": "boolean"
                    },
                    "paymentFailed": {
                      "type": "boolean"
                    },
                    "period": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "start": {
                          "type": "string"
                        },
                        "end": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "start",
                        "end"
                      ],
                      "additionalProperties": false
                    },
                    "usedHours": {
                      "type": "number"
                    },
                    "includedHours": {
                      "type": "number"
                    },
                    "maxConcurrent": {
                      "type": "number"
                    },
                    "maxSize": {
                      "type": "string",
                      "enum": [
                        "small",
                        "default",
                        "large",
                        "xlarge"
                      ]
                    },
                    "blocked": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "hours_used",
                            "cap_reached",
                            "new_account"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "overage": {
                      "type": "object",
                      "properties": {
                        "available": {
                          "type": "boolean"
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "capHours": {
                          "type": "number"
                        },
                        "usedHours": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "available",
                        "enabled",
                        "capHours",
                        "usedHours"
                      ],
                      "additionalProperties": false
                    },
                    "prices": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "currency": {
                              "type": "string"
                            },
                            "proMonthly": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "overageHourly": {
                              "type": [
                                "number",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "currency",
                            "proMonthly",
                            "overageHourly"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billingEnabled": {
                      "type": "boolean"
                    },
                    "hasCustomer": {
                      "type": "boolean"
                    },
                    "plans": {
                      "type": "object",
                      "properties": {
                        "free": {
                          "type": "object",
                          "properties": {
                            "includedHours": {
                              "type": "number"
                            },
                            "maxConcurrent": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "includedHours",
                            "maxConcurrent"
                          ],
                          "additionalProperties": false
                        },
                        "pro": {
                          "type": "object",
                          "properties": {
                            "includedHours": {
                              "type": "number"
                            },
                            "maxConcurrent": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "includedHours",
                            "maxConcurrent"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "free",
                        "pro"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "plan",
                    "status",
                    "renewsAt",
                    "cancelAtPeriodEnd",
                    "paymentFailed",
                    "period",
                    "usedHours",
                    "includedHours",
                    "maxConcurrent",
                    "maxSize",
                    "blocked",
                    "overage",
                    "prices",
                    "billingEnabled",
                    "hasCustomer",
                    "plans"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/checkout": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "A Stripe Checkout page for Pro, to open in a browser",
        "operationId": "postBillingCheckout",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "linkVisits": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/portal": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "A Stripe Customer Portal page for your subscription, to open in a browser",
        "operationId": "postBillingPortal",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/overage": {
      "patch": {
        "tags": [
          "billing"
        ],
        "summary": "Turns extra Keko Cloud time past your plan’s hours on (with a monthly cap) or off",
        "operationId": "patchBillingOverage",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "plan": {
                      "type": "string",
                      "enum": [
                        "free",
                        "pro"
                      ]
                    },
                    "status": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "renewsAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "cancelAtPeriodEnd": {
                      "type": "boolean"
                    },
                    "paymentFailed": {
                      "type": "boolean"
                    },
                    "period": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "start": {
                          "type": "string"
                        },
                        "end": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "start",
                        "end"
                      ],
                      "additionalProperties": false
                    },
                    "usedHours": {
                      "type": "number"
                    },
                    "includedHours": {
                      "type": "number"
                    },
                    "maxConcurrent": {
                      "type": "number"
                    },
                    "maxSize": {
                      "type": "string",
                      "enum": [
                        "small",
                        "default",
                        "large",
                        "xlarge"
                      ]
                    },
                    "blocked": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "hours_used",
                            "cap_reached",
                            "new_account"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "overage": {
                      "type": "object",
                      "properties": {
                        "available": {
                          "type": "boolean"
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "capHours": {
                          "type": "number"
                        },
                        "usedHours": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "available",
                        "enabled",
                        "capHours",
                        "usedHours"
                      ],
                      "additionalProperties": false
                    },
                    "prices": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "currency": {
                              "type": "string"
                            },
                            "proMonthly": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "overageHourly": {
                              "type": [
                                "number",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "currency",
                            "proMonthly",
                            "overageHourly"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billingEnabled": {
                      "type": "boolean"
                    },
                    "hasCustomer": {
                      "type": "boolean"
                    },
                    "plans": {
                      "type": "object",
                      "properties": {
                        "free": {
                          "type": "object",
                          "properties": {
                            "includedHours": {
                              "type": "number"
                            },
                            "maxConcurrent": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "includedHours",
                            "maxConcurrent"
                          ],
                          "additionalProperties": false
                        },
                        "pro": {
                          "type": "object",
                          "properties": {
                            "includedHours": {
                              "type": "number"
                            },
                            "maxConcurrent": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "includedHours",
                            "maxConcurrent"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "free",
                        "pro"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "plan",
                    "status",
                    "renewsAt",
                    "cancelAtPeriodEnd",
                    "paymentFailed",
                    "period",
                    "usedHours",
                    "includedHours",
                    "maxConcurrent",
                    "maxSize",
                    "blocked",
                    "overage",
                    "prices",
                    "billingEnabled",
                    "hasCustomer",
                    "plans"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "capHours": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "post": {
        "tags": [
          "usage"
        ],
        "summary": "An engine’s machine-time reports (the usage token), each counted once by id",
        "operationId": "postUsage",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "number"
                    },
                    "duplicates": {
                      "type": "number"
                    },
                    "allowances": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "userId": {
                            "type": "string"
                          },
                          "plan": {
                            "type": "string",
                            "enum": [
                              "free",
                              "pro"
                            ]
                          },
                          "period": {
                            "type": "string"
                          },
                          "usedSeconds": {
                            "type": "number"
                          },
                          "limitSeconds": {
                            "type": "number"
                          },
                          "remainingSeconds": {
                            "type": "number"
                          },
                          "maxConcurrent": {
                            "type": "number"
                          },
                          "maxSize": {
                            "type": "string",
                            "enum": [
                              "small",
                              "default",
                              "large",
                              "xlarge"
                            ]
                          },
                          "maxRuns": {
                            "type": "number"
                          },
                          "maxClaudeSessions": {
                            "type": "number"
                          },
                          "snapshotBuildsPerDay": {
                            "type": "number"
                          },
                          "blocked": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "hours_used",
                                  "cap_reached",
                                  "new_account"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "userId",
                          "plan",
                          "period",
                          "usedSeconds",
                          "limitSeconds",
                          "remainingSeconds",
                          "maxConcurrent",
                          "maxSize",
                          "maxRuns",
                          "maxClaudeSessions",
                          "snapshotBuildsPerDay",
                          "blocked"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "accepted",
                    "duplicates",
                    "allowances"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reports": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 8,
                          "maxLength": 80,
                          "pattern": "^[\\w.:-]+$"
                        },
                        "userId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "machineId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "startedAt": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "endedAt": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "id",
                        "userId",
                        "machineId",
                        "startedAt",
                        "endedAt"
                      ]
                    }
                  }
                },
                "required": [
                  "reports"
                ]
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/usage/allowance": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "What an engine may still start for a user this month (the usage token)",
        "operationId": "getUsageAllowance",
        "parameters": [
          {
            "name": "userId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "allowance": {
                      "type": "object",
                      "properties": {
                        "userId": {
                          "type": "string"
                        },
                        "plan": {
                          "type": "string",
                          "enum": [
                            "free",
                            "pro"
                          ]
                        },
                        "period": {
                          "type": "string"
                        },
                        "usedSeconds": {
                          "type": "number"
                        },
                        "limitSeconds": {
                          "type": "number"
                        },
                        "remainingSeconds": {
                          "type": "number"
                        },
                        "maxConcurrent": {
                          "type": "number"
                        },
                        "maxSize": {
                          "type": "string",
                          "enum": [
                            "small",
                            "default",
                            "large",
                            "xlarge"
                          ]
                        },
                        "maxRuns": {
                          "type": "number"
                        },
                        "maxClaudeSessions": {
                          "type": "number"
                        },
                        "snapshotBuildsPerDay": {
                          "type": "number"
                        },
                        "blocked": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "hours_used",
                                "cap_reached",
                                "new_account"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "userId",
                        "plan",
                        "period",
                        "usedSeconds",
                        "limitSeconds",
                        "remainingSeconds",
                        "maxConcurrent",
                        "maxSize",
                        "maxRuns",
                        "maxClaudeSessions",
                        "snapshotBuildsPerDay",
                        "blocked"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "allowance"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    }
  },
  "tags": [
    {
      "name": "api",
      "x-displayName": "API"
    },
    {
      "name": "accounts",
      "x-displayName": "Accounts"
    },
    {
      "name": "waitlist",
      "x-displayName": "Waitlist"
    },
    {
      "name": "github",
      "x-displayName": "GitHub"
    },
    {
      "name": "variables",
      "x-displayName": "Variables"
    },
    {
      "name": "ai-accounts",
      "x-displayName": "AI accounts"
    },
    {
      "name": "account",
      "x-displayName": "Account"
    },
    {
      "name": "usage",
      "x-displayName": "Usage"
    },
    {
      "name": "billing",
      "x-displayName": "Billing"
    }
  ],
  "servers": [
    {
      "url": "https://api.keko.run"
    }
  ]
}
