简介
Forge API 允许您通过简单的 REST API 创建和与 Laravel Forge 上的服务器和站点进行交互。
身份验证
为了使用 API,您应该通过将您的 API 密钥作为承载令牌值包含在您的请求中来验证您的请求。
授权:承载 API_KEY_HERE
您可以在 API 仪表板 中生成 API 密钥。
标头
确保您在每个请求上都设置了以下内容类型标头
Accept: application/json
Content-Type: application/json
URI
Forge API 托管在以下基本 URI 上
https://forge.laravel.net.cn/api/v1
错误
Forge 使用传统的 HTTP 响应代码来指示 API 请求的成功或失败。下表包含典型响应代码的摘要
代码 | 描述 |
---|---|
200 | 一切正常。 |
400 | 给出了有效数据,但请求失败。 |
401 | 没有给出有效的 API 密钥。 |
404 | 找不到请求资源。 |
422 | 有效负载缺少必需的参数或给出了无效数据。 |
429 | 尝试次数过多。 |
500 | 由于 Forge 中的内部错误,请求失败。 |
503 | Forge 处于维护状态。 |
用户
显示
响应
{
"user": {
"id": 1,
"name": "Mohamed Said",
"email": "[email protected]",
"card_last_four": "1881",
"connected_to_github": true,
"connected_to_gitlab": true,
"connected_to_bitbucket_two": true,
"connected_to_digitalocean": true,
"connected_to_linode": true,
"connected_to_vultr": true,
"connected_to_aws": true,
"connected_to_hetzner": true,
"ready_for_billing": true,
"stripe_is_active": 1,
"stripe_price": "yearly-basic-199-trial",
"subscribed": 1,
"can_create_servers": true,
"2fa_enabled": false
}
}
HTTP 请求
GET /api/v1/user
服务器
创建服务器
有效负载
{
"provider": "ocean2",
"ubuntu_version": "22.04",
"type": "web",
"credential_id": 1,
"name": "test-via-api",
"size": "01",
"database": "test123",
"php_version": "php82",
"region": "ams2",
"recipe_id": null
}
响应
{
"server": {
"id": 16,
"credential_id": 1,
"name": "test-via-api",
"type": "web",
"size": "01",
"region": "ams2",
"php_version": "php82",
"php_cli_version": "php82",
"opcache_status": "enabled",
"database_type": "mysql8",
"ip_address": null,
"private_ip_address": null,
"blackfire_status": null,
"papertrail_status": null,
"revoked": false,
"created_at": "2016-12-15 15:04:05",
"is_ready": false,
"network": []
},
"sudo_password": "baracoda",
"database_password": "spotted_eagle_ray"
}
HTTP 请求
POST /api/v1/servers
参数
键 | 描述 |
---|---|
ubuntu_version | 要创建服务器的 Ubuntu 版本。有效值为 "20.04" 和 "22.04" 。如果未定义值,则默认使用 "22.04" 。建议始终指定版本,因为默认值可能会随时更改。 |
类型 | 要创建的服务器类型。有效值为 app 、web 、loadbalancer 、cache 、database 、worker 、meilisearch 。如果未定义值,则默认使用 app 。 |
提供商 | 服务器提供商。有效值为 ocean2 (Digital Ocean)、linode4 、vultr2 、aws 、hetzner 和 custom 。 |
disk_size | 磁盘大小(以 GB 为单位)。提供商为 aws 时有效。最小值为 8GB。示例:20 。 |
圈子 | 要创建服务器所在的圆圈的 ID。 |
credential_id | 仅当提供者不是 custom 时才需要。 |
region | 创建服务器所在的区域的名称。如果您正在构建自定义 VPS 服务器,则不需要此值。 有效的区域标识符. |
ip_address | 服务器的 IP 地址。仅当提供者为 custom 时才需要。 |
private_ip_address | 服务器的私有 IP 地址。仅当提供者为 custom 时才需要。 |
php_version | 有效值为 php83 、php82 、php81 、php80 、php74 、php73 、php72 、php82 、php70 和 php56 。 |
database | Forge 在构建服务器时应创建的数据库的名称。如果省略,将使用 forge 。 |
database_type | 有效值为 mysql8 、mariadb106 、mariadb1011 、mariadb114 、postgres 、postgres13 、postgres14 、postgres15 或 postgres16 。 |
network | 服务器应该能够连接到的服务器 ID 数组。 |
recipe_id | 在配置后运行的食谱的可选 ID。 |
aws_vpc_id | 现有 VPC 的 ID |
aws_subnet_id | 现有子网的 ID |
aws_vpc_name | 创建新 VPC 时 |
hetzner_network_id | 现有 VPC 的 ID |
ocean2_vpc_uuid | 现有 VPC 的 UUID |
ocean2_vpc_name | 创建新 VPC 时 |
vultr2_network_id | 现有私有网络的 ID |
vultr2_network_name | 创建新 VPC 时 |
服务器状态
服务器大约需要 10 分钟才能配置。服务器准备好使用后,服务器上的 is_ready
参数将为 true
。您不应该反复 ping Forge API 以询问服务器是否已准备好。相反,请考虑每 2 分钟 ping 一次端点。
有效大小
查看 区域端点 以了解可用的大小和区域 ID。
自定义 VPS
在创建自定义 VPS 时,此端点的响应将包含一个 provision_command
属性
{
"provision_command": "wget -O forge.sh https://..."
}
列出服务器
响应
{
"servers": [
{
"id": 1,
"credential_id": 1,
"name": "test-via-api",
"size": "s-1vcpu-1gb",
"region": "Amsterdam 2",
"php_version": "php82",
"php_cli_version": "php82",
"opcache_status": "enabled",
"database_type": "mysql8",
"ip_address": "37.139.3.148",
"private_ip_address": "10.129.3.252",
"blackfire_status": null,
"papertrail_status": null,
"revoked": false,
"created_at": "2016-12-15 18:38:18",
"is_ready": true,
"network": []
}
]
}
HTTP 请求
GET /api/v1/servers
获取服务器
响应
{
"server": {
"id": 1,
"credential_id": 1,
"name": "test-via-api",
"size": "s-1vcpu-1gb",
"region": "Amsterdam 2",
"php_version": "php82",
"php_cli_version": "php82",
"opcache_status": "enabled",
"database_type": "mysql8",
"ip_address": "37.139.3.148",
"private_ip_address": "10.129.3.252",
"blackfire_status": null,
"papertrail_status": null,
"revoked": false,
"created_at": "2016-12-15 18:38:18",
"is_ready": true,
"network": []
}
}
HTTP 请求
GET /api/v1/servers/{id}
更新服务器
有效负载
{
"name": "renamed-server",
"ip_address": "192.241.143.108",
"private_ip_address": "10.136.8.40",
"max_upload_size": 123,
"max_execution_time": 30,
"network": [2, 3],
"timezone": "Europe/London",
"tags": ["london-server"]
}
响应
{
"server": {
"id": 16,
"credential_id": 1,
"name": "test-via-api",
"size": "s-1vcpu-1gb",
"region": "Amsterdam 2",
"php_version": "php82",
"php_cli_version": "php82",
"opcache_status": "enabled",
"database_type": "mysql8",
"ip_address": null,
"private_ip_address": null,
"blackfire_status": null,
"papertrail_status": null,
"revoked": false,
"created_at": "2016-12-15 15:04:05",
"is_ready": false,
"network": [2, 3],
"tags": ["london-server"]
}
}
HTTP 请求
PUT /api/v1/servers/{id}
更新数据库密码
有效负载
{
"password": "maeve"
}
HTTP 请求
PUT /api/v1/servers/{serverId}/database-password
此端点将更新 Forge 的主数据库密码副本,该密码应用于验证新数据库和数据库用户的创建。这通常仅在您使用在 Forge 添加数据库管理之前构建的 Forge 服务器时才需要。
删除服务器
HTTP 请求
DELETE /api/v1/servers/{id}
重启服务器
HTTP 请求
POST /api/v1/servers/{id}/reboot
撤销 Forge 对服务器的访问权限
HTTP 请求
POST /api/v1/servers/{id}/revoke
重新连接已撤销的服务器
响应
{
"public_key": "CONTENT_OF_THE_PUBLIC_KEY"
}
HTTP 请求
POST /api/v1/servers/{id}/reconnect
此端点将返回一个 SSH 密钥,您需要将其添加到服务器。密钥添加到服务器后,您可以“重新激活”它。
重新激活已撤销的服务器
HTTP 请求
POST /api/v1/servers/{id}/reactivate
获取最近的事件
响应
[
{
"server_id": 18,
"ran_as": "forge",
"server_name": "billowing-cliff",
"description": "Deploying PHP Info Page.",
"created_at": "2017-04-28 18:08:44"
}
]
HTTP 请求
GET /api/v1/servers/events
参数
键 | 描述 |
---|---|
server_id | 可以选择指定 server_id 以获取仅此服务器的最近事件。 |
获取服务器事件
响应
{
"events": [
{
"server_id": 18,
"ran_as": "forge",
"server_name": "billowing-cliff",
"description": "Deploying PHP Info Page.",
"created_at": "2017-04-28 18:08:44"
}
]
}
HTTP 请求
GET /api/v1/servers/{id}/events
获取服务器事件输出
响应
{
"output": "Some command output."
}
HTTP 请求
GET /api/v1/servers/{id}/events/{event}
服务
启动服务
HTTP 请求
POST /api/v1/servers/{id}/services/start
有效负载
{
"service": "service-name"
}
停止服务
HTTP 请求
POST /api/v1/servers/{id}/services/stop
有效负载
{
"service": "service-name"
}
重启服务
HTTP 请求
POST /api/v1/servers/{id}/services/restart
有效负载
{
"service": "service-name"
}
重启 MySQL
HTTP 请求
POST /api/v1/servers/{id}/mysql/reboot
停止 MySQL
HTTP 请求
POST /api/v1/servers/{id}/mysql/stop
重启 Nginx
HTTP 请求
POST /api/v1/servers/{id}/nginx/reboot
停止 Nginx
HTTP 请求
POST /api/v1/servers/{id}/nginx/stop
测试 Nginx
响应
{
"result": "nginx: [emerg] a duplicate listen 0.0.0.0:80 in \/etc\/nginx\/sites-enabled\/default:6\nnginx: configuration file \/etc\/nginx\/nginx.conf test failed\n"
}
HTTP 请求
GET /api/v1/servers/{id}/nginx/test
重启 Postgres
HTTP 请求
POST /api/v1/servers/{id}/postgres/reboot
停止 Postgres
HTTP 请求
POST /api/v1/servers/{id}/postgres/stop
重启 PHP
有效负载
{
"version": "php74"
}
HTTP 请求
POST /api/v1/servers/{id}/php/reboot
安装 Blackfire
有效负载
{
"server_id": "...",
"server_token": "..."
}
HTTP 请求
POST /api/v1/servers/{id}/blackfire/install
删除 Blackfire
HTTP 请求
DELETE /api/v1/servers/{id}/blackfire/remove
安装 Papertrail
有效负载
{
"host": "192.241.143.108"
}
HTTP 请求
POST /api/v1/servers/{id}/papertrail/install
删除 Papertrail
HTTP 请求
DELETE /api/v1/servers/{id}/papertrail/remove
守护进程
创建守护进程
有效负载
{
"command": "COMMAND",
"user": "root",
"directory": "/home/forge/foo.com"
}
响应
{
"daemon": {
"id": 2,
"command": "php artisan queue:work",
"user": "forge",
"directory": "/home/forge/foo.com",
"processes": 1,
"startsecs": 1,
"stopwaitsecs": 10,
"stopsignal": "SIGTERM",
"status": "installing",
"created_at": "2022-02-14 09:29:18"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/daemons
列出守护进程
响应
{
"daemons": [
{
"id": 2,
"command": "php artisan queue:work",
"user": "forge",
"directory": "/home/forge/foo.com",
"processes": 1,
"startsecs": 1,
"stopwaitsecs": 10,
"stopsignal": "SIGTERM",
"status": "installing",
"created_at": "2022-02-14 09:29:18"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/daemons
获取守护进程
响应
{
"daemon": {
"id": 2,
"command": "php artisan queue:work",
"user": "forge",
"directory": "/home/forge/foo.com",
"processes": 1,
"startsecs": 1,
"stopwaitsecs": 10,
"stopsignal": "SIGTERM",
"status": "installing",
"created_at": "2022-02-14 09:29:18"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/daemons/{daemonId}
删除守护进程
HTTP 请求
DELETE /api/v1/servers/{serverId}/daemons/{daemonId}
重启守护进程
HTTP 请求
POST /api/v1/servers/{serverId}/daemons/{daemonId}/restart
防火墙规则
创建规则
有效负载
{
"name": "rule name",
"ip_address": "192.168.1.1",
"port": 88,
"type": "allow"
}
响应
{
"rule": {
"id": 4,
"name": "rule",
"port": 123,
"type": "allow",
"ip_address": null,
"status": "installing",
"created_at": "2016-12-16 15:50:17"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/firewall-rules
可用的规则类型
您可以指定 allow
或 deny
作为规则类型。
列出规则
响应
{
"rules": [
{
"id": 4,
"name": "rule",
"port": 123,
"type": "allow",
"ip_address": null,
"status": "installing",
"created_at": "2016-12-16 15:50:17"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/firewall-rules
获取规则
响应
{
"rule": {
"id": 4,
"name": "rule",
"port": 123,
"type": "allow",
"ip_address": null,
"status": "installing",
"created_at": "2016-12-16 15:50:17"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/firewall-rules/{ruleId}
删除规则
HTTP 请求
DELETE /api/v1/servers/{serverId}/firewall-rules/{ruleId}
计划任务
创建任务
有效负载
{
"command": "COMMAND_THE_JOB_RUNS",
"frequency": "custom",
"user": "root",
"minute": "*",
"hour": "*",
"day": "*",
"month": "*",
"weekday": "*"
}
响应
{
"job": {
"id": 2,
"command": "COMMAND_THE_JOB_RUNS",
"user": "root",
"frequency": "Nightly",
"cron": "0 0 * * *",
"status": "installing",
"created_at": "2016-12-16 15:56:59"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/jobs
参数
键 | 描述 |
---|---|
频率 | 任务运行的频率。有效值为 minutely 、hourly 、nightly 、weekly 、monthly 、reboot 和 custom |
分钟 | 如果频率为 custom ,则需要此参数。 |
小时 | 如果频率为 custom ,则需要此参数。 |
天 | 如果频率为 custom ,则需要此参数。 |
月 | 如果频率为 custom ,则需要此参数。 |
星期 | 如果频率为 custom ,则需要此参数。 |
列出任务
响应
{
"jobs": [
{
"id": 2,
"command": "COMMAND_THE_JOB_RUNS",
"user": "root",
"frequency": "nightly",
"cron": "0 0 * * *",
"status": "installing",
"created_at": "2016-12-16 15:56:59"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/jobs
获取任务
响应
{
"job": {
"id": 2,
"command": "COMMAND_THE_JOB_RUNS",
"user": "root",
"frequency": "Nightly",
"cron": "0 0 * * *",
"status": "installing",
"created_at": "2016-12-16 15:56:59"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/jobs/{jobId}
删除任务
HTTP 请求
DELETE /api/v1/servers/{serverId}/jobs/{jobId}
获取任务输出
响应
{
"output": "The output of the job will be returned here."
}
HTTP 请求
GET /api/v1/servers/{serverId}/jobs/{jobId}/output
PHP
列出 PHP 版本
响应
[
{
"id": 29,
"version": "php74",
"status": "installed",
"displayable_version": "PHP 7.4",
"binary_name": "php7.4",
"used_as_default": false,
"used_on_cli": false
},
{
"id": 30,
"version": "php73",
"status": "installed",
"displayable_version": "PHP 7.3",
"binary_name": "php7.3",
"used_as_default": true,
"used_on_cli": true
},
{
"id": 31,
"version": "php72",
"status": "installed",
"displayable_version": "PHP 7.2",
"binary_name": "php7.2",
"used_as_default": false,
"used_on_cli": false
},
{
"id": 32,
"version": "php71",
"status": "installed",
"displayable_version": "PHP 7.1",
"binary_name": "php7.1",
"used_as_default": false,
"used_on_cli": false
},
{
"id": 33,
"version": "php56",
"status": "installed",
"displayable_version": "PHP 5.6",
"binary_name": "php5.6",
"used_as_default": false,
"used_on_cli": false
}
]
HTTP 请求
GET /api/v1/servers/{serverId}/php
安装 PHP 版本
HTTP 请求
POST /api/v1/servers/{serverId}/php
有效负载
{
"version": "php74"
}
可用版本
键 | 描述 |
---|---|
php83 |
PHP 8.3 |
php82 |
PHP 8.2 |
php81 |
PHP 8.1 |
php80 |
PHP 8.0 |
php74 |
PHP 7.4 |
php73 |
PHP 7.3 |
php72 |
PHP 7.2 |
php71 |
PHP 7.1 |
php70 |
PHP 7.0 |
php56 |
PHP 5.6 |
升级 PHP 修补程序版本
您必须提供要修补的版本。
HTTP 请求
POST /api/v1/servers/{serverId}/php/update
有效负载
{
"version": "php74"
}
启用 OPCache
HTTP 请求
POST /api/v1/servers/{serverId}/php/opcache
禁用 OPCache
HTTP 请求
DELETE /api/v1/servers/{serverId}/php/opcache
数据库
创建数据库
有效负载
{
"name": "forge",
"user": "forge",
"password": "dolores"
}
响应
{
"database": {
"id": 1,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:12:22"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/databases
参数
键 | 描述 |
---|---|
用户 | 此字段是可选的。如果传递,它将用于创建一个新的数据库用户,该用户可以访问新创建的数据库。 |
密码 | 此字段仅在提供 user 值时才需要。 |
同步数据库
HTTP 请求
POST /api/v1/servers/{serverId}/databases/sync
列出数据库
响应
{
"databases": [
{
"id": 1,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:12:22"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/databases
获取数据库
响应
{
"database": {
"id": 1,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:12:22"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/databases/{databaseId}
删除数据库
HTTP 请求
DELETE /api/v1/servers/{serverId}/databases/{databaseId}
数据库用户
创建用户
有效负载
{
"name": "forge",
"password": "dolores",
"databases": [1]
}
响应
{
"user": {
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/database-users
参数
键 | 描述 |
---|---|
数据库 | 一个数据库 ID 数组,引用用户有权访问的数据库。 |
密码 | 分配给用户的密码。 |
列出用户
响应
{
"users": [
{
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/database-users
获取用户
响应
{
"user": {
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/database-users/{userId}
更新用户
有效负载
{
"databases": [2]
}
响应
{
"user": {
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
}
HTTP 请求
PUT /api/v1/servers/{serverId}/database-users/{userId}
此端点可用于更新数据库用户可以访问的数据库。
删除用户
HTTP 请求
DELETE /api/v1/servers/{serverId}/database-users/{userId}
MySQL 数据库
/mysql
端点现已弃用,建议使用新的 /databases
端点。
创建数据库
有效负载
{
"name": "forge",
"user": "forge",
"password": "dolores"
}
响应
{
"database": {
"id": 1,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:12:22"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/mysql
参数
键 | 描述 |
---|---|
用户 | 此字段是可选的。如果传递,它将用于创建一个新的 MySQL 用户,该用户可以访问新创建的数据库。 |
密码 | 此字段仅在提供 user 值时才需要。 |
列出数据库
响应
{
"databases": [
{
"id": 1,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:12:22"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/mysql
获取数据库
响应
{
"database": {
"id": 1,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:12:22"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/mysql/{databaseId}
删除数据库
HTTP 请求
DELETE /api/v1/servers/{serverId}/mysql/{databaseId}
MySQL 数据库用户
/mysql-users
端点现已弃用,建议使用新的 /database-users
端点。
创建用户
有效负载
{
"name": "forge",
"password": "dolores",
"databases": [1]
}
响应
{
"user": {
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/mysql-users
参数
键 | 描述 |
---|---|
数据库 | 一个数据库 ID 数组,引用用户有权访问的数据库。 |
列出用户
响应
{
"users": [
{
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/mysql-users
获取用户
响应
{
"user": {
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/mysql-users/{userId}
更新用户
有效负载
{
"databases": [2]
}
响应
{
"user": {
"id": 2,
"name": "forge",
"status": "installing",
"created_at": "2016-12-16 16:19:01",
"databases": [
1
]
}
}
HTTP 请求
PUT /api/v1/servers/{serverId}/mysql-users/{userId}
此端点可用于更新 MySQL 用户可以访问的数据库。
删除用户
HTTP 请求
DELETE /api/v1/servers/{serverId}/mysql-users/{userId}
Nginx 模板
创建模板
有效负载
{
"name": "My Nginx Template",
"content": "server { listen {{ PORT }}; location = / { ... } }"
}
响应
{
"template": {
"id": 1,
"server_id": 50,
"name": "My Nginx Template",
"content": "server { listen {{ PORT }}; location = / { ... } }"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/nginx/templates
变量
Nginx 模板支持多个变量,这些变量将在创建站点时被替换为真实数据。有关变量的更多信息,请参阅 Nginx 模板文档。
列出 Nginx 模板
响应
{
"templates": [
{
"id": 1,
"server_id": 50,
"name": "My Nginx Template",
"content": "server { listen {{ PORT }}; location = / { ... } }"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/nginx/templates/default
获取默认 Nginx 模板
当创建站点时没有选择自定义 Nginx 模板,Forge 将使用此 Nginx 配置。
响应
{
"template": {
"server_id": 50,
"name": "Forge Default",
"content": "..."
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/nginx/templates/{templateId}
获取 Nginx 模板
响应
{
"template": {
"id": 1,
"server_id": 50,
"name": "My Nginx Template",
"content": "server { listen {{ PORT }}; location = / { ... } }"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/nginx/templates/{templateId}
更新 Nginx 模板
请求
{
"name": "My New Name",
"content": "My new content"
}
响应
{
"template": {
"id": 1,
"server_id": 50,
"name": "My New Name",
"content": "My new content"
}
}
HTTP 请求
PUT /api/v1/servers/{serverId}/nginx/templates/{templateId}
删除 Nginx 模板
HTTP 请求
DELETE /api/v1/servers/{serverId}/nginx/templates/{templateId}
站点
创建站点
有效负载
{
"domain": "site.com",
"project_type": "php",
"aliases": ["alias1.com", "alias2.com"],
"directory": "/test",
"isolated": true,
"username": "laravel",
"database": "site-com-db",
"php_version": "php81",
"nginx_template": 1
}
响应
{
"site": {
"id": 2,
"name": "site.com",
"aliases": ["alias1.com", "alias2.com"],
"directory": "/test",
"wildcards": false,
"isolated": true,
"username": "forge",
"status": "installing",
"repository": null,
"repository_provider": null,
"repository_branch": null,
"repository_status": null,
"quick_deploy": false,
"project_type": "php",
"app": null,
"php_version": "php81",
"app_status": null,
"slack_channel": null,
"telegram_chat_id": null,
"telegram_chat_title": null,
"created_at": "2016-12-16 16:38:08",
"deployment_url": "...",
"tags": []
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites
可用的站点类型
键 | 描述 |
---|---|
php |
PHP / Laravel / Symfony |
octane |
Laravel Octane |
html |
静态 HTML / Nuxt.js / Next.js |
symfony |
Symfony <= 3.x |
symfony_dev |
Symfony <= 3.x (开发版) |
Nginx 模板
您可以省略 nginx_template
键以使用 default
模板,或提供 nginx_template: "default"
。
列出站点
响应
{
"sites": [
{
"id": 2,
"name": "site.com",
"username": "laravel",
"directory": "/test",
"wildcards": false,
"status": "installing",
"repository": null,
"repository_provider": null,
"repository_branch": null,
"repository_status": null,
"quick_deploy": false,
"project_type": "php",
"app": null,
"php_version": "php81",
"app_status": null,
"slack_channel": null,
"telegram_chat_id": null,
"telegram_chat_title": null,
"deployment_url": "...",
"created_at": "2016-12-16 16:38:08",
"tags": []
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites
获取站点
响应
{
"site": {
"id": 2,
"name": "site.com",
"aliases": ["alias1.com"],
"username": "laravel",
"directory": "/test",
"wildcards": false,
"status": "installing",
"repository": null,
"repository_provider": null,
"repository_branch": null,
"repository_status": null,
"quick_deploy": false,
"project_type": "php",
"app": null,
"php_version": "php81",
"app_status": null,
"slack_channel": null,
"telegram_chat_id": null,
"telegram_chat_title": null,
"deployment_url": "...",
"created_at": "2016-12-16 16:38:08",
"tags": []
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}
更新站点
有效负载
{
"directory": "/some/path",
"name": "site-new-name.com",
"php_version": "php81",
"aliases": ["alias1.com", "alias2.com"],
"wildcards": true
}
响应
{
"site": {
"id": 2,
"name": "site-new-name.com",
"aliases": ["alias1.com", "alias2.com"],
"username": "laravel",
"directory": "/some/path",
"wildcards": false,
"status": "installing",
"repository": null,
"repository_provider": null,
"repository_branch": null,
"repository_status": null,
"quick_deploy": false,
"project_type": "php",
"app": null,
"app_status": null,
"slack_channel": null,
"telegram_chat_id": null,
"telegram_chat_title": null,
"deployment_url": "...",
"created_at": "2016-12-16 16:38:08",
"tags": []
}
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}
此端点用于更新给定站点的“web 目录”、主名称、别名或是否使用通配符子域。
更改站点 PHP 版本
有效负载
{
"version": "php74"
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/php
添加站点别名
有效负载
{
"aliases": ["alias1.com", "alias2.com"]
}
响应
{
"site": {
"id": 2,
"name": "site.com",
"aliases": ["alias1.com", "alias2.com"],
"username": "laravel",
"directory": "/",
"wildcards": false,
"status": "installing",
"repository": null,
"repository_provider": null,
"repository_branch": null,
"repository_status": null,
"quick_deploy": false,
"project_type": "php",
"app": null,
"app_status": null,
"slack_channel": null,
"telegram_chat_id": null,
"telegram_chat_title": null,
"deployment_url": "...",
"created_at": "2016-12-16 16:38:08",
"tags": []
}
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/aliases
使用此端点添加额外的站点别名并保留现有别名。
删除站点
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}
负载均衡
响应
{
"nodes": [
{
"server_id": 2,
"weight": 5,
"down": false,
"backup": false,
"port": 80
}, {
"server_id": 3,
"weight": 1,
"down": false,
"backup": true,
"port": 80
}, {
"server_id": 4,
"weight": 1,
"down": true,
"backup": false,
"port": 80
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/balancing
更新负载均衡
有效负载
{
"servers": [{
"id": 2,
"weight": 5
}, {
"id": 3,
"backup": true
}, {
"id": 4,
"down": true
}],
"method": "least_conn"
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/balancing
如果服务器是负载均衡器,则可以使用此端点指定负载均衡器应将流量发送到的服务器。
负载均衡方法
键 | 描述 |
---|---|
round_robin |
请求均匀分布在所有服务器上 |
least_conn |
请求被发送到具有最少活动连接的服务器 |
ip_hash |
发送请求的服务器由客户端 IP 地址确定 |
站点日志
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/logs
响应
{
"content": "[2020-08-18 10:32:56] local.INFO: Test \n"
}
SSL 证书
创建证书
有效负载
{
"type": "new",
"domain": "domain.com",
"country": "US",
"state": "NY",
"city": "New York",
"organization": "Company Name",
"department": "IT"
}
响应
{
"certificate": {
"domain": "domain.com",
"request_status": "creating",
"created_at": "2016-12-17 07:02:35",
"id": 3,
"existing": false,
"active": false
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/certificates
安装现有证书
有效负载
{
"type": "existing",
"key": "PRIVATE_KEY_HERE",
"certificate": "CERTIFICATE_HERE"
}
响应
{
"certificate": {
"domain": "domain.com",
"request_status": "creating",
"created_at": "2016-12-17 07:02:35",
"id": 3,
"existing": false,
"active": false
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/certificates
克隆现有证书
有效负载
{
"type": "clone",
"certificate_id": 1
}
响应
{
"certificate": {
"domain": "domain.com",
"request_status": "creating",
"created_at": "2016-12-17 07:02:35",
"id": 3,
"existing": false,
"active": false
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/certificates
获取 Let's Encrypt 证书
dns_provider
对象仅在通配符子域的情况下需要。
有效负载
{
"domains": ["www.site.com"],
"dns_provider": {
"type": "xxx",
"cloudflare_api_token": "xxx",
"route53_key": "xxx",
"route53_secret": "xxx",
"digitalocean_token": "xxx",
"dnssimple_token": "xxx",
"linode_token": "xxx",
"ovh_endpoint": "xxx",
"ovh_app_key": "xxx",
"ovh_app_secret": "xxx",
"ovh_consumer_key": "xxx",
"google_credentials_file": "xxx",
}
}
响应
{
"certificate": {
"domain": "www.test.com",
"type": "letsencrypt",
"request_status": "created",
"status": "installing",
"created_at": "2017-02-09 17:14:34",
"id": 1,
"existing": true,
"active": false
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/certificates/letsencrypt
DNS 提供商类型
类型 | 额外字段 |
---|---|
cloudflare |
cloudflare_api_token . |
route53 |
route53_key 和 route53_secret |
digitalocean |
digitalocean_token |
dnssimple |
dnssimple_token |
linode |
linode_token |
ovh |
ovh_endpoint 、ovh_app_key 、ovh_app_secret 和 ovh_consumer_key |
google |
google_credentials_file |
列出证书
响应
{
"certificates": [
{
"domain": "domain.com",
"request_status": "creating",
"created_at": "2016-12-17 07:02:35",
"id": 3,
"existing": false,
"active": false
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/certificates
获取证书
响应
{
"certificate": {
"domain": "domain.com",
"request_status": "creating",
"created_at": "2016-12-17 07:02:35",
"id": 3,
"existing": false,
"active": false
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/certificates/{id}
获取签名请求
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/certificates/{id}/csr
此端点可用于获取完整的证书签名请求内容。
安装证书
有效负载
{
"certificate": "certificate content",
"add_intermediates": false
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/certificates/{id}/install
激活证书
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/certificates/{id}/activate
删除证书
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/certificates/{id}
SSH 密钥
创建密钥
有效负载
{
"name": "test-key",
"key": "KEY_CONTENT_HERE",
"username": "forge"
}
响应
{
"key": {
"id": 9,
"name": "test-key",
"username": "forge",
"status": "installing",
"created_at": "2016-12-16 16:31:16"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/keys
列出密钥
响应
{
"keys": [
{
"id": 9,
"name": "test-key",
"username": "forge",
"status": "installing",
"created_at": "2016-12-16 16:31:16"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/keys
获取密钥
响应
{
"key": {
"id": 9,
"name": "test-key",
"username": "forge",
"status": "installing",
"created_at": "2016-12-16 16:31:16"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/keys/{keyId}
删除密钥
HTTP 请求
DELETE /api/v1/servers/{serverId}/keys/{keyId}
工作进程
创建工作进程
您可以将 php
作为 php_version
值传递,以使用服务器的默认 PHP CLI 版本。
有效负载
{
"connection": "sqs",
"timeout": 90,
"sleep": 60,
"tries": null,
"processes": 1,
"stopwaitsecs": 600,
"daemon": true,
"force": false,
"php_version": "php72",
"queue": "hotfix"
}
响应
{
"worker": {
"id": 1,
"connection": "rule",
"command": "php7.2 /home/forge/default/artisan queue:work rule --sleep=60 --daemon --quiet --timeout=90",
"queue": null,
"timeout": 90,
"sleep": 60,
"tries": null,
"processes": 1,
"stopwaitsecs": 600,
"environment": null,
"php_version": "php72",
"daemon": 1,
"force": 0,
"status": "installing",
"created_at": "2016-12-17 07:15:03"
}
}
队列选项
queue
密钥可以留空以使用默认队列。
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/workers
列出工作进程
响应
{
"workers": [
{
"id": 1,
"connection": "rule",
"command": "php7.2 /home/forge/default/artisan queue:work rule --sleep=60 --daemon --quiet --timeout=90",
"queue": null,
"timeout": 90,
"sleep": 60,
"tries": null,
"processes": 1,
"stopwaitsecs": null,
"environment": null,
"php_version": "php72",
"daemon": 1,
"force": 0,
"status": "installing",
"created_at": "2016-12-17 07:15:03"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/workers
获取工作进程
响应
{
"worker": {
"id": 1,
"connection": "rule",
"command": "php7.2 /home/forge/default/artisan queue:work rule --sleep=60 --daemon --quiet --timeout=90",
"queue": null,
"timeout": 90,
"sleep": 60,
"tries": null,
"processes": 1,
"stopwaitsecs": null,
"environment": null,
"php_version": "php72",
"daemon": 1,
"force": 0,
"status": "installing",
"created_at": "2016-12-17 07:15:03"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/workers/{id}
删除工作进程
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/workers/{id}
重启工作进程
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/workers/{id}/restart
获取工作进程输出
响应
{
"output": "The output of the worker will be returned here."
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId/}/workers/{workerId}/output
重定向规则
创建规则
有效负载
{
"from": "/docs",
"to": "/docs/1.1",
"type": "redirect"
}
响应
{
"redirect_rule": {
"id": 15,
"from": "/docs",
"to": "/docs/1.1",
"type": "redirect",
"created_at": "2018-03-07 16:33:20"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/redirect-rules
类型 | 描述 |
---|---|
重定向 | 创建临时 302 重定向 |
永久 | 创建永久 301 重定向 |
列出重定向规则
响应
{
"redirect_rules": [
{
"id": 15,
"from": "/docs",
"to": "/docs/1.1",
"type": "redirect",
"created_at": "2018-03-07 16:33:20"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/redirect-rules
获取规则
响应
{
"redirect_rule": {
"id": 15,
"from": "/docs",
"to": "/docs/1.1",
"type": "redirect",
"created_at": "2018-03-07 16:33:20"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/redirect-rules/{id}
删除规则
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/redirect-rules/{id}
安全规则
创建安全规则
有效负载
{
"name": "Access Restricted",
"path": null,
"credentials": [
{
"username": "taylor.otwell",
"password": "password123"
}, {
"username": "james.brooks",
"password": "secret123"
}
]
}
响应
{
"security_rule": {
"id": 15,
"name": "Access Restricted",
"path": null,
"created_at": "2020-07-30 10:11:10",
"credentials": [
{
"id": 20,
"username": "taylor.otwell",
"created_at": "2020-07-30 10:11:10"
}, {
"id": 21,
"username": "james.brooks",
"created_at": "2020-07-30 10:11:10"
}
]
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/security-rules
您可以将 path
留空以保护站点中的所有路由。
列出安全规则
响应
{
"security_rules": [
{
"id": 15,
"name": "Access Restricted",
"path": null,
"created_at": "2020-07-30 10:11:10",
"credentials": [
{
"id": 20,
"username": "taylor.otwell",
"created_at": "2020-07-30 10:11:10"
}, {
"id": 21,
"username": "james.brooks",
"created_at": "2020-07-30 10:11:10"
}
]
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/security-rules
获取安全规则
响应
{
"security_rule": {
"id": 15,
"name": "Access Restricted",
"path": null,
"created_at": "2020-07-30 10:11:10",
"credentials": [
{
"id": 20,
"username": "taylor.otwell",
"created_at": "2020-07-30 10:11:10"
}, {
"id": 21,
"username": "james.brooks",
"created_at": "2020-07-30 10:11:10"
}
]
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/security-rules/{id}
删除安全规则
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/security-rules/{id}
部署
启用快速部署
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/deployment
禁用快速部署
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/deployment
获取部署脚本
此请求的响应是一个字符串。
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/deployment/script
更新部署脚本
有效负载
{
"content": "CONTENT_OF_THE_SCRIPT",
"auto_source": false
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/deployment/script
参数
键 | 描述 |
---|---|
内容 |
部署脚本的内容。此字段是必需的。 |
auto_source |
是否自动将环境变量源到部署脚本中。 |
立即部署
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/deployment/deploy
重置部署状态
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/deployment/reset
获取部署日志
此请求的响应是一个字符串。
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/deployment/log
部署历史记录
列出部署
响应
{
"deployments": [
{
"id": 71,
"server_id": 196,
"site_id": 110,
"type": 4,
"commit_hash": "1aa50f0e4c49fed3a2335e866b03d4178ab93c4e",
"commit_author": "Dries Vints",
"commit_message": "Merge branch '8.x'\n\n# Conflicts:\n#\tCHANGELOG.md",
"started_at": "2020-11-05 12:56:05",
"ended_at": "2020-11-05 12:56:11",
"status": "failed",
"displayable_type": "Deployment API"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/deployment-history
获取部署
响应
{
"deployment": {
"id": 71,
"server_id": 196,
"site_id": 110,
"type": 4,
"commit_hash": "1aa50f0e4c49fed3a2335e866b03d4178ab93c4e",
"commit_author": "Dries Vints",
"commit_message": "Merge branch '8.x'\n\n# Conflicts:\n#\tCHANGELOG.md",
"started_at": "2020-11-05 12:56:05",
"ended_at": "2020-11-05 12:56:11",
"status": "failed",
"displayable_type": "Deployment API"
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/deployment-history/{deploymentId}
获取部署输出
响应
{
"output": "Thu 05 Nov 2020 12:42:30 PM UTC\nFrom github.com:laravel\/laravel\n * branch master -> FETCH_HEAD\nAlready up to date.\nInstalling dependencies from lock file (including require-dev)\nVerifying lock file contents can be installed on current platform.\nNothing to install, update or remove\nGenerating optimized autoload files\n> Illuminate\\Foundation\\ComposerScripts::postAutoloadDump\n> @php artisan package:discover --ansi\nDiscovered Package: [32mfideloper\/proxy[39m\nDiscovered Package: [32mfruitcake\/laravel-cors[39m\nDiscovered Package: [32mlaravel\/tinker[39m\nDiscovered Package: [32mnesbot\/carbon[39m\nDiscovered Package: [32mnunomaduro\/collision[39m\n[32mPackage manifest generated successfully.[39m\n73 packages you are using are looking for funding.\nUse the `composer fund` command to find out more!\nRestarting FPM...\n\n Illuminate\\Database\\QueryException \n\n SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')\n\n at vendor\/laravel\/framework\/src\/Illuminate\/Database\/Connection.php:671\n 667▕ \/\/ If an exception occurs when attempting to run a query, we'll format the error\n 668▕ \/\/ message to include the bindings with SQL, which will make this exception a\n 669▕ \/\/ lot more helpful to the developer instead of just the database's errors.\n 670▕ catch (Exception $e) {\n ➜ 671▕ throw new QueryException(\n 672▕ $query, $this->prepareBindings($bindings), $e\n 673▕ );\n 674▕ }\n 675▕\n\n [2m+33 vendor frames [22m\n 34 artisan:37\n Illuminate\\Foundation\\Console\\Kernel::handle()\n"
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/deployment-history/{deploymentId}/output
配置文件
获取 Nginx 配置
此请求的响应是一个字符串。
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/nginx
更新 Nginx 配置
有效负载
{
"content": "CONTENT"
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/nginx
获取 .env 文件
此请求的响应是一个字符串。
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/env
更新 .env 文件
有效负载
{
"content": "CONTENT"
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/env
Git 项目
安装新项目
有效负载
{
"provider": "github",
"repository": "username/repository",
"branch": "master",
"composer": true
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/git
参数
键 | 描述 |
---|---|
提供商 | 仓库提供商。有效值为 github 、gitlab 、gitlab-custom 、bitbucket 和 custom 。 |
composer | 是否安装 Composer 依赖项。有效值为 true 或 false 。 |
更新仓库
有效负载
{
"provider": "github",
"repository": "username/repository",
"branch": "master"
}
HTTP 请求
PUT /api/v1/servers/{serverId}/sites/{siteId}/git
删除项目
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/git
创建部署密钥
响应
{
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDM9Uq4P4rrJCwFHqfvA5vJ6CfvlVZNpGeopmxXRKmN7yjyaMDXEBHSoOwftTsaqNE+Y1M12yctCUyyFpHxVHOhvqiT6XRsYVDSASMYm7rZWQjt\/zXJSdl80NvY\/2m5dSbLWfr9CoHcRROx3Ja213b8Qc9BOQfINbsT4OsGPrOlvpHyCFWDgu4wQvmVcmaGa2soJr92TaGTkJv6T73BjUXD8ZdfYmCkX5y3L2cXgUiNhcDTDm9G+tQebfdr77CRhGcOUi473MsSDuEPCV7RtDHSVA5\/SSSReZyOW3MocObl3LPyq18gmiX9kUO5bVCAev7Yf5QCB2SJFUl5StZ9Wn1yLtY+P02fFZNr+GrmqbAlhv2rTf8UqOBzal46j8oGYbBaRC4BvUKzmxjM7VbUVGO3+8DJIiJYSZoEr+9ptQbs+0YVo1lVah8O1TGm1uoh1LEV36d3GzHbeUjfN71Oqrq5929gt3Ppt\/phxSli7VAQgBIKYvhtWlVxeAz\/EekxMCYSmWT8ZtGOLWlFLQMNEFn5wP\/+CW5VxzQaQbvzsW4EEkBFH5BW0BRt99FQlbhJ7RZmRYD+v1r8Du8Er9I8WGj8f\/cP8PmxlfvVVPokrxvWr4E7GU5mNHIFQTz7hAq4DIxbaR96IEcd6INxa1wfoWgib+9YW77edyX1C1iF2bGGIw== [email protected]"
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/deploy-key
删除部署密钥
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/deploy-key
站点命令
执行命令
有效负载
{
"command": "ls -la"
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/commands
列出命令历史记录
响应
{
"commands": [
{
"id": 68,
"server_id": 34,
"site_id": 48,
"user_id": 1,
"event_id": 730,
"command": "ls -lah",
"status": "finished",
"created_at": "2021-04-16 14:46:55",
"updated_at": "2021-04-16 14:47:00",
"profile_photo_url": "https:\/\/unavatar.vercel.app\/james%40brooks.page?fallback=https%3A%2F%2Fui-avatars.com%2Fapi%3Fname%3DJames%2BBrooks%26color%3D7F9CF4%26background%3DEBF4FF",
"user_name": "James Brooks"
},
{
"id": 69,
"server_id": 34,
"site_id": 48,
"user_id": 1,
"event_id": 731,
"command": "echo 'Hello!'",
"status": "finished",
"created_at": "2021-04-16 14:48:01",
"updated_at": "2021-04-16 14:48:07",
"profile_photo_url": "https:\/\/unavatar.vercel.app\/james%40brooks.page?fallback=https%3A%2F%2Fui-avatars.com%2Fapi%3Fname%3DJames%2BBrooks%26color%3D7F9CF4%26background%3DEBF4FF",
"user_name": "James Brooks"
}
]
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/commands
获取命令
响应
{
"command": {
"id": 69,
"server_id": 34,
"site_id": 48,
"user_id": 1,
"event_id": 731,
"command": "echo 'Hello!'",
"status": "finished",
"created_at": "2021-04-16 14:48:01",
"updated_at": "2021-04-16 14:48:07",
"profile_photo_url": "https:\/\/unavatar.vercel.app\/james%40brooks.page?fallback=https%3A%2F%2Fui-avatars.com%2Fapi%3Fname%3DJames%2BBrooks%26color%3D7F9CF4%26background%3DEBF4FF",
"user_name": "James Brooks"
},
"output": "Hello!"
}
HTTP 请求
GET /api/v1/servers/{serverId}/sites/{siteId}/commands/{commandId}
WordPress
安装
有效负载
{
"database": "forge",
"user": 1
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/wordpress
卸载 WordPress
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/wordpress
此端点将卸载 WordPress 并将站点恢复到默认状态。
phpMyAdmin
安装
有效负载
{
"database": "forge",
"user": 1
}
HTTP 请求
POST /api/v1/servers/{serverId}/sites/{siteId}/phpmyadmin
卸载 phpMyAdmin
HTTP 请求
DELETE /api/v1/servers/{serverId}/sites/{siteId}/phpmyadmin
此端点将卸载 phpMyAdmin 并将站点恢复到默认状态。
Webhooks
列出
响应
{
"webhooks": [
{
"id": 10,
"url": "http://domain.com",
"created_at": "2018-10-10 17:01:18"
}
]
}
HTTP 请求
GET /api/v1/servers/{server_id}/sites/{site_id}/webhooks
显示
响应
{
"webhook": {
"id": 10,
"url": "http://domain.com",
"created_at": "2018-10-10 17:01:18"
}
}
HTTP 请求
GET /api/v1/servers/{server_id}/sites/{site_id}/webhooks/{id}
创建
响应
{
"url": "http://domain.com"
}
HTTP 请求
POST /api/v1/servers/{server_id}/sites/{site_id}/webhooks
删除
响应
{
"url": "http://domain.com"
}
HTTP 请求
DELETE /api/v1/servers/{server_id}/sites/{site_id}/webhooks/{id}
食谱
创建食谱
有效负载
{
"name": "Recipe Name",
"user": "root",
"script": "SCRIPT_CONTENT"
}
响应
{
"recipe": {
"id": 1,
"name": "Recipe Name",
"user": "root",
"script": "SCRIPT_CONTENT",
"created_at": "2016-12-16 16:24:05"
}
}
HTTP 请求
POST /api/v1/recipes
列出食谱
响应
{
"recipes": [
{
"id": 1,
"name": "Recipe Name",
"user": "root",
"script": "SCRIPT_CONTENT",
"created_at": "2016-12-16 16:24:05"
}
]
}
HTTP 请求
GET /api/v1/recipes
获取食谱
响应
{
"recipe": {
"id": 1,
"name": "Recipe Name",
"user": "root",
"script": "SCRIPT_CONTENT",
"created_at": "2016-12-16 16:24:05"
}
}
HTTP 请求
GET /api/v1/recipes/{recipeId}
更新食谱
有效负载
{
"name": "Recipe Name",
"user": "root",
"script": "SCRIPT_CONTENT"
}
响应
{
"recipe": {
"id": 1,
"name": "Recipe Name",
"user": "root",
"script": "SCRIPT_CONTENT",
"created_at": "2016-12-16 16:24:05"
}
}
HTTP 请求
PUT /api/v1/recipes/{recipeId}
删除食谱
HTTP 请求
DELETE /api/v1/recipes/{recipeId}
运行食谱
有效负载
{
"servers": [1,2],
"notify": true
}
HTTP 请求
POST /api/v1/recipes/{recipeId}/run
区域
列出
响应
{
"regions": {
"ocean2": [
{
"id": "ams2",
"name": "Amsterdam 2",
"sizes": [
{
"id": "01",
"size": "s-1vcpu-1gb",
"name": "1GB RAM - 1 CPU Core - 25GB SSD"
}
]
}
],
"linode": [],
"vultr": [],
"aws": []
}
}
HTTP 请求
GET /api/v1/regions
凭据
列出
响应
{
"credentials": [
{
"id": 1,
"type": "ocean2",
"name": "Personal"
}
]
}
HTTP 请求
GET /api/v1/credentials
备份
列出备份配置
HTTP 请求
GET /api/v1/servers/{serverId}/backup-configs
响应
{
"backups": [
{
"id": 10,
"day_of_week": null,
"time": null,
"provider" : "spaces",
"provider_name": "DigitalOcean Spaces",
"status": "installed",
"databases": [{
"id": 100,
"name": "forge",
"status": "installed",
"created_at": "2020-01-01 10:00:00"
}],
"backups": [
{
"id": 144,
"backup_id": 10,
"status": "success",
"restore_status": null,
"archive_path": "s3://backup-configs/server/db/backup-10-20200101123601.tar.gz",
"duration": 4,
"date": "1st Jan 12:36 PM"
}
],
"last_backup_time": "3 days ago"
}
]
}
创建备份配置
有效负载
{
"provider": "spaces",
"credentials": {
"endpoint": "https://my-endpoint.com",
"region": "region-key",
"bucket": "bucket-name",
"access_key": "",
"secret_key": ""
},
"frequency": {
"type": "weekly",
"time": "12:30",
"day": 1
},
"directory": "backups/server/db",
"email": "[email protected]",
"retention": 7,
"databases": [
24
]
}
响应
{
"backup": {
"id": 10,
"day_of_week": null,
"time": null,
"provider" : "spaces",
"provider_name": "DigitalOcean Spaces",
"status": "installing",
"databases": [
{
"id": 24,
"name": "forge",
"status": "installed",
"created_at": "2020-01-13 15:47:33"
}
],
"backups": [],
"last_backup_time": null
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/backup-configs
可用提供商
键 | 描述 |
---|---|
s3 |
Amazon S3 |
spaces |
DigitalOcean Spaces |
custom |
自定义(与 S3 兼容,例如 MinIO) |
当提供 custom
提供商时,您 **必须** 也提供 endpoint
。
频率选项
hourly
daily
- 您必须提供 24 小时格式的time
weekly
- 您必须提供 24 小时格式的time
和day
选项 0(星期日) - 6(星期六)custom
- 您必须提供custom
值,作为有效的 cron 表达式
更新备份配置
有效负载
{
"provider": "spaces",
"credentials": {
"endpoint": "https://my-endpoint.com",
"region": "region-key",
"bucket": "bucket-name",
"access_key": "",
"secret_key": ""
},
"frequency": {
"type": "weekly",
"time": "12:30",
"day": 1
},
"directory": "backups/server/db",
"email": "[email protected]",
"retention": 7,
"databases": [
24,
25
]
}
响应
{
"backup": {
"id": 10,
"day_of_week": null,
"time": null,
"provider" : "spaces",
"provider_name": "DigitalOcean Spaces",
"status": "updating",
"databases": [
{
"id": 24,
"name": "forge",
"status": "installed",
"created_at": "2020-01-13 15:47:33"
}
],
"backups": [],
"last_backup_time": null
}
}
更新的有效负载和选项与创建时相同。
获取备份配置
响应
{
"backup": {
"id": 10,
"day_of_week": null,
"time": null,
"provider" : "spaces",
"provider_name": "DigitalOcean Spaces",
"status": "installed",
"databases": [
{
"id": 24,
"name": "forge",
"status": "installed",
"created_at": "2020-01-13 15:47:33"
}
],
"backups": [],
"last_backup_time": null
}
}
HTTP 请求
GET /api/v1/servers/{serverId}/backup-configs/{backupConfigurationId}
运行备份配置
手动运行备份配置。
HTTP 请求
POST /api/v1/servers/{serverId}/backup-configs/{backupConfigurationId}
删除备份配置
HTTP 请求
DELETE /api/v1/servers/{serverId}/backup-configs/{backupConfigurationId}
恢复备份
有效负载
{
"database": 7
}
如果没有提供 database
值,Forge 将恢复第一个可用的数据库。
HTTP 请求
POST /api/v1/servers/{serverId}/backup-configs/{backupConfigurationId}/backups/{backupId}
删除备份
HTTP 请求
DELETE /api/v1/servers/{serverId}/backup-configs/{backupConfigurationId}/backups/{backupId}
监控
列出监控器
HTTP 请求
GET /api/v1/servers/{serverId}/monitors
响应
{
"monitors": [
{
"id": 3,
"status": "installed",
"type": "free_memory",
"operator": "lte",
"threshold": 70,
"minutes": 5,
"state": "ALERT",
"state_changed_at": "2020-03-01 12:45:00"
},
{
"id": 7,
"status": "installed",
"type": "disk",
"operator": "lte",
"threshold": 25,
"minutes": 0,
"state": "OK",
"state_changed_at": "2020-03-01 12:45:00"
}
]
}
创建监控器
有效负载
{
"type": "cpu_load",
"operator": "gte",
"threshold": "1.3",
"minutes": "5",
"notify": "[email protected]"
}
响应
{
"monitor": {
"id": 8,
"status": "installed",
"type": "disk",
"operator": "lte",
"threshold": 25,
"minutes": 0,
"state": "OK",
"state_changed_at": "2020-03-01 12:45:00"
}
}
HTTP 请求
POST /api/v1/servers/{serverId}/monitors
可用监控器
监控器以百分比值工作。
键 | 描述 |
---|---|
disk |
已使用的磁盘空间 |
used_memory |
已使用的内存量 |
cpu_load |
CPU 负载 |
运算符
gte
- 大于或等于lte
- 小于或等于
获取监控器
HTTP 请求
GET /api/v1/servers/{serverId}/monitors/{monitorId}
响应
{
"monitor": {
"id": 3,
"status": "installed",
"type": "free_memory",
"operator": "lte",
"threshold": 70,
"minutes": 5,
"state": "ALERT",
"state_changed_at": "2020-03-01 12:45:00"
}
}
删除监控器
HTTP 请求
DELETE /api/v1/servers/{serverId}/monitors/{monitorId}
服务器日志
获取日志
HTTP 请求
GET /api/v1/servers/{serverId}/logs
响应
{
"path": "\/var\/log\/mysql\/error.log",
"content": "2020-08-18T10:22:01.238990Z 0 [System] [MY-010931] [Server] \/usr\/sbin\/mysqld: ready for connections. Version: '8.0.21' socket: '\/var\/run\/mysqld\/mysqld.sock' port: 3306 MySQL Community Server - GPL.\n2020-08-18T10:22:01.359309Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.21).\n2020-08-18T10:22:03.644177Z 0 [System] [MY-010910] [Server] \/usr\/sbin\/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL.\n2020-08-18T10:22:04.183385Z 0 [System] [MY-010116] [Server] \/usr\/sbin\/mysqld (mysqld 8.0.21) starting as process 42752\n2020-08-18T10:22:04.193962Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.\n2020-08-18T10:22:04.530305Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.\n2020-08-18T10:22:04.662877Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: \/var\/run\/mysqld\/mysqlx.sock\n2020-08-18T10:22:04.749019Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.\n2020-08-18T10:22:04.749453Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.\n2020-08-18T10:22:04.775994Z 0 [System] [MY-010931] [Server] \/usr\/sbin\/mysqld: ready for connections. Version: '8.0.21' socket: '\/var\/run\/mysqld\/mysqld.sock' port: 3306 MySQL Community Server - GPL.\n"
}
文件类型
您必须指定以下 file
类型之一
nginx_access
nginx_error
database
php7x
(其中x
是有效的版本号,例如php71
)或php56