{
 "openapi": "3.1.0",
 "info": {
  "title": "Hillstribe API",
  "version": "1.0.0",
  "description": "Programmatic access to Hillstribe managed services — n8n, OpenClaw, and more.",
  "contact": {
   "email": "support@hillstribe.tech"
  }
 },
 "servers": [
  {
   "url": "https://app.hillstribe.tech",
   "description": "Production"
  }
 ],
 "security": [
  {
   "cookieAuth": []
  }
 ],
 "components": {
  "securitySchemes": {
   "cookieAuth": {
    "type": "apiKey",
    "in": "cookie",
    "name": "authjs.session-token"
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     }
    },
    "required": [
     "error"
    ]
   },
   "InstanceStatus": {
    "type": "string",
    "enum": [
     "PROVISIONING",
     "RUNNING",
     "STOPPED",
     "DEPROVISIONING",
     "MIGRATING",
     "ERROR",
     "DELETED"
    ]
   },
   "Instance": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "slug": {
      "type": "string"
     },
     "status": {
      "$ref": "#/components/schemas/InstanceStatus"
     },
     "url": {
      "type": "string",
      "nullable": true
     },
     "n8nVersion": {
      "type": "string"
     },
     "createdAt": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "MigrationJob": {
    "type": "object",
    "properties": {
     "jobId": {
      "type": "string"
     },
     "step": {
      "type": "string",
      "enum": [
       "BACKUP",
       "COMMIT_MANIFEST",
       "HEALTH_CHECK",
       "DNS_SWAP",
       "DONE",
       "FAILED"
      ]
     },
     "error": {
      "type": "string",
      "nullable": true
     }
    }
   }
  }
 },
 "paths": {
  "/api/me": {
   "get": {
    "summary": "Get current user",
    "operationId": "getMe",
    "tags": [
     "Account"
    ],
    "responses": {
     "200": {
      "description": "User profile and subscription",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "user": {
           "type": "object",
           "properties": {
            "id": {
             "type": "string"
            },
            "email": {
             "type": "string"
            },
            "name": {
             "type": "string",
             "nullable": true
            },
            "role": {
             "type": "string"
            }
           }
          },
          "subscription": {
           "type": "object",
           "nullable": true,
           "properties": {
            "id": {
             "type": "string"
            },
            "status": {
             "type": "string"
            }
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Unauthorized",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/api/check-slug": {
   "get": {
    "summary": "Check slug availability",
    "operationId": "checkSlug",
    "tags": [
     "Provisioning"
    ],
    "parameters": [
     {
      "name": "slug",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Availability result",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "available": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/instance/status": {
   "get": {
    "summary": "List user instances",
    "operationId": "getInstanceStatus",
    "tags": [
     "Instances"
    ],
    "responses": {
     "200": {
      "description": "All active instances",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "instances": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Instance"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Unauthorized"
     }
    }
   }
  },
  "/api/provision/free": {
   "post": {
    "summary": "Provision free n8n instance",
    "operationId": "provisionN8nFree",
    "tags": [
     "n8n"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "slug"
        ],
        "properties": {
         "slug": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{1,28}[a-z0-9]$"
         },
         "n8nVersion": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Instance provisioning started",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Validation error"
     },
     "409": {
      "description": "Slug taken or already has free instance"
     },
     "403": {
      "description": "Email address not confirmed yet (`code: \"EMAIL_UNVERIFIED\"`). Confirm it via the link from `/api/auth/verify-email/resend`."
     }
    }
   }
  },
  "/api/provision/openclaw": {
   "post": {
    "summary": "Provision free OpenClaw instance",
    "operationId": "provisionOpenClawFree",
    "tags": [
     "OpenClaw"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "slug"
        ],
        "properties": {
         "slug": {
          "type": "string"
         },
         "version": {
          "type": "string",
          "default": "latest"
         },
         "anthropicApiKey": {
          "type": "string",
          "nullable": true
         },
         "openaiApiKey": {
          "type": "string",
          "nullable": true
         },
         "geminiApiKey": {
          "type": "string",
          "nullable": true
         },
         "openrouterApiKey": {
          "type": "string",
          "nullable": true
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OpenClaw instance provisioning started",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "url": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "409": {
      "description": "Slug taken or already has free instance"
     },
     "403": {
      "description": "Email address not confirmed yet (`code: \"EMAIL_UNVERIFIED\"`). Confirm it via the link from `/api/auth/verify-email/resend`."
     }
    }
   }
  },
  "/api/checkout": {
   "post": {
    "summary": "Create Stripe checkout session",
    "operationId": "createCheckout",
    "tags": [
     "Billing"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "planId"
        ],
        "properties": {
         "planId": {
          "type": "string"
         },
         "addonIds": {
          "type": "array",
          "items": {
           "type": "string"
          }
         },
         "slug": {
          "type": "string"
         },
         "customDomain": {
          "type": "string",
          "nullable": true
         },
         "n8nVersion": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Stripe checkout URL",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "403": {
      "description": "Email address not confirmed yet (`code: \"EMAIL_UNVERIFIED\"`). Confirm it via the link from `/api/auth/verify-email/resend`."
     }
    }
   }
  },
  "/api/billing/portal": {
   "post": {
    "summary": "Create Stripe billing portal session",
    "operationId": "createBillingPortal",
    "tags": [
     "Billing"
    ],
    "responses": {
     "200": {
      "description": "Stripe portal URL",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/instance/{id}/start": {
   "post": {
    "summary": "Start an instance",
    "operationId": "startInstance",
    "tags": [
     "Instances"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Instance starting",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Instance not found"
     },
     "409": {
      "description": "Instance not stopped (also returned while the instance is scheduled for deletion)"
     }
    }
   }
  },
  "/api/instance/{id}/stop": {
   "post": {
    "summary": "Stop an instance",
    "operationId": "stopInstance",
    "tags": [
     "Instances"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Instance stopped"
     },
     "409": {
      "description": "Instance not running"
     }
    }
   }
  },
  "/api/instance/{id}/upgrade": {
   "post": {
    "summary": "Upgrade instance version",
    "operationId": "upgradeInstance",
    "tags": [
     "Instances"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "newVersion"
        ],
        "properties": {
         "newVersion": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Upgrade started"
     },
     "400": {
      "description": "Unsupported version"
     }
    }
   }
  },
  "/api/instance/{id}/migrate": {
   "post": {
    "summary": "Migrate instance to another region",
    "operationId": "migrateInstance",
    "tags": [
     "Instances"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "toClusterId"
        ],
        "properties": {
         "toClusterId": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Migration result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MigrationJob"
        }
       }
      }
     },
     "400": {
      "description": "Migration failed or invalid request"
     },
     "409": {
      "description": "Conflict (also returned while the instance is scheduled for deletion)"
     }
    }
   }
  },
  "/api/instance/{id}/delete": {
   "post": {
    "summary": "Schedule an instance for deletion",
    "operationId": "deleteInstance",
    "tags": [
     "Instances"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Stopped and scheduled",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "deleteScheduledAt": {
           "type": "string",
           "format": "date-time"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Wrong, expired or used code. `code` is `invalid`, `expired` or `too_many_attempts` (5 wrong guesses burn the code)."
     },
     "404": {
      "description": "Not found"
     },
     "409": {
      "description": "Already being deleted"
     }
    },
    "description": "Requires the code from `POST /api/user/action-code` with `purpose: \"instance.delete\"`. The instance is stopped immediately and permanently deleted (with all data) after 24 hours. Undo with `POST /api/instance/{id}/delete/cancel` until then.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "code"
        ],
        "properties": {
         "code": {
          "type": "string",
          "pattern": "^\\d{6}$"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/notifications": {
   "get": {
    "summary": "Get notifications",
    "operationId": "getNotifications",
    "tags": [
     "Notifications"
    ],
    "responses": {
     "200": {
      "description": "Notifications list with unread count"
     }
    }
   }
  },
  "/api/notifications/read": {
   "post": {
    "summary": "Mark all notifications read",
    "operationId": "markNotificationsRead",
    "tags": [
     "Notifications"
    ],
    "responses": {
     "200": {
      "description": "All marked read"
     }
    }
   }
  },
  "/api/activity": {
   "get": {
    "summary": "Get activity log",
    "operationId": "getActivity",
    "tags": [
     "Activity"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer",
       "default": 1
      }
     },
     {
      "name": "category",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "AUTH",
        "INSTANCE",
        "BILLING",
        "ADMIN",
        "SYSTEM"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Paginated activity log"
     }
    }
   }
  },
  "/api/provision/abcdesktop": {
   "post": {
    "summary": "Provision free abcdesktop instance",
    "operationId": "provisionAbcdesktopFree",
    "tags": [
     "abcdesktop"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "slug"
        ],
        "properties": {
         "slug": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{1,28}[a-z0-9]$"
         },
         "version": {
          "type": "string",
          "description": "abcdesktop platform version (e.g. 3.4)"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Instance provisioning started",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Validation error"
     },
     "401": {
      "description": "Unauthorized"
     },
     "409": {
      "description": "Subdomain taken or instance already exists"
     },
     "403": {
      "description": "Email address not confirmed yet (`code: \"EMAIL_UNVERIFIED\"`). Confirm it via the link from `/api/auth/verify-email/resend`."
     }
    }
   }
  },
  "/api/auth/forgot-password": {
   "post": {
    "tags": [
     "Account"
    ],
    "summary": "Request a password reset email",
    "description": "Always returns 200, whether or not the email has an account. At most 3 reset emails per account per hour; links expire after 1 hour. OAuth-only accounts get no email.",
    "security": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "email"
        ],
        "properties": {
         "email": {
          "type": "string",
          "format": "email"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/auth/reset-password": {
   "post": {
    "tags": [
     "Account"
    ],
    "summary": "Set a new password with a reset token",
    "security": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "token",
         "password"
        ],
        "properties": {
         "token": {
          "type": "string"
         },
         "password": {
          "type": "string",
          "minLength": 8
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Password too short, or token invalid/expired/used"
     }
    }
   }
  },
  "/api/auth/verify-email": {
   "get": {
    "tags": [
     "Account"
    ],
    "summary": "Confirm an email address (link target from the email)",
    "security": [],
    "parameters": [
     {
      "name": "token",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "307": {
      "description": "Redirects to /dashboard?verified=1, or ?verified=invalid"
     }
    }
   }
  },
  "/api/auth/verify-email/resend": {
   "post": {
    "tags": [
     "Account"
    ],
    "summary": "Send a new verification email to the signed-in user",
    "description": "Limited to one every 5 minutes.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Unauthorized"
     },
     "429": {
      "description": "A link was sent less than 5 minutes ago"
     }
    }
   }
  },
  "/api/user/email-prefs": {
   "get": {
    "tags": [
     "Account"
    ],
    "summary": "Get email notification preferences",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "product": {
           "type": "boolean",
           "description": "Instance lifecycle emails"
          },
          "billing": {
           "type": "boolean",
           "description": "Top-ups, renewals, payment reminders, price changes"
          },
          "loginAlerts": {
           "type": "boolean",
           "description": "New sign-in alerts"
          }
         }
        }
       }
      }
     }
    }
   },
   "patch": {
    "tags": [
     "Account"
    ],
    "summary": "Update email notification preferences",
    "description": "Send any subset of the fields. Security emails (verification, password reset, password changed) can't be turned off.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "product": {
          "type": "boolean",
          "description": "Instance lifecycle emails"
         },
         "billing": {
          "type": "boolean",
          "description": "Top-ups, renewals, payment reminders, price changes"
         },
         "loginAlerts": {
          "type": "boolean",
          "description": "New sign-in alerts"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Updated preferences",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "product": {
           "type": "boolean",
           "description": "Instance lifecycle emails"
          },
          "billing": {
           "type": "boolean",
           "description": "Top-ups, renewals, payment reminders, price changes"
          },
          "loginAlerts": {
           "type": "boolean",
           "description": "New sign-in alerts"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/user/action-code": {
   "post": {
    "tags": [
     "Account"
    ],
    "operationId": "requestActionCode",
    "summary": "Email a 6-digit confirmation code for a critical action",
    "description": "Step-up verification. The code is valid for 10 minutes, works once, and only for the given purpose and target. Requesting a new code invalidates earlier ones. At most 3 codes per action per 10 minutes.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "purpose"
        ],
        "properties": {
         "purpose": {
          "type": "string",
          "enum": [
           "instance.delete",
           "password.change"
          ]
         },
         "targetId": {
          "type": "string",
          "description": "Instance id. Required for `instance.delete`."
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Code sent",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "expiresInSec": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Unknown action, or password change on an OAuth account"
     },
     "401": {
      "description": "Unauthorized"
     },
     "404": {
      "description": "Instance not found"
     },
     "409": {
      "description": "Instance already being deleted"
     },
     "429": {
      "description": "Too many codes requested"
     },
     "502": {
      "description": "Email could not be sent"
     }
    }
   }
  },
  "/api/instance/{id}/delete/cancel": {
   "post": {
    "tags": [
     "Instances"
    ],
    "operationId": "cancelInstanceDelete",
    "summary": "Cancel a scheduled instance deletion",
    "description": "Only during the 24-hour grace period. The instance stays stopped; start it with `/api/instance/{id}/start`.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Deletion cancelled",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Not found"
     },
     "409": {
      "description": "Not scheduled for deletion, or already being removed"
     }
    }
   }
  },
  "/api/user/password": {
   "patch": {
    "tags": [
     "Account"
    ],
    "operationId": "changePassword",
    "summary": "Change the account password",
    "description": "Requires the current password and the code from `POST /api/user/action-code` with `purpose: \"password.change\"`. Not available for Google accounts.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "currentPassword",
         "newPassword",
         "code"
        ],
        "properties": {
         "currentPassword": {
          "type": "string"
         },
         "newPassword": {
          "type": "string",
          "minLength": 8
         },
         "code": {
          "type": "string",
          "pattern": "^\\d{6}$"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Password changed",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Validation error, wrong current password, or wrong/expired code"
     },
     "401": {
      "description": "Unauthorized"
     }
    }
   }
  }
 },
 "tags": [
  {
   "name": "Account"
  },
  {
   "name": "Provisioning"
  },
  {
   "name": "n8n"
  },
  {
   "name": "OpenClaw"
  },
  {
   "name": "Instances"
  },
  {
   "name": "Billing"
  },
  {
   "name": "Notifications"
  },
  {
   "name": "Activity"
  },
  {
   "name": "abcdesktop",
   "description": "Managed abcdesktop cloud desktops"
  }
 ]
}
