### Start a Custom Background Process
Source: https://forge.laravel.com/docs/resources/background-processes
Example command for starting a custom background process. Replace `php artisan reverb:start` with your specific command.
```bash
php artisan reverb:start
```
--------------------------------
### Start a Laravel Queue Worker
Source: https://forge.laravel.com/docs/resources/background-processes
Example command for starting a Laravel queue worker. Ensure the correct queue connection and worker details are specified.
```bash
php artisan queue:work redis --queue=default --tries=3
```
--------------------------------
### Install and Use growpart to Expand Partition
Source: https://forge.laravel.com/docs/knowledge-base/servers
Install the cloud-guest-utils package if it's not already present, then use the growpart command to expand the specified partition. Replace /dev/vda1 with your actual device and partition number.
```bash
# Install growpart if it is not available...
sudo apt-get update && sudo apt-get install -y cloud-guest-utils
# Grow the partition...
sudo growpart /dev/vda1 # Replace with your actual device and partition number (e.g., /dev/sda1, /dev/xvda1)
```
--------------------------------
### Install Laravel Forge SDK
Source: https://forge.laravel.com/docs/sdk
Install the Laravel Forge SDK package using Composer.
```bash
composer require laravel/forge-sdk
```
--------------------------------
### Change Directory and Run Script
Source: https://forge.laravel.com/docs/sites/commands
Execute commands within a specific directory by prefixing with 'cd'. This example changes to the 'bin' directory and then runs a script.
```bash
cd bin && ./run-command.sh
```
--------------------------------
### Manage Sites
Source: https://forge.laravel.com/docs/sdk
Retrieve lists of sites on a server, get a specific site, create new sites, update existing ones, and delete sites.
```php
$sites = $forge->serverSites($organizationSlug, $serverId);
$site = $forge->organizationSite($organizationSlug, $siteId);
$site = $forge->createSite($organizationSlug, $serverId, $data);
$site = $forge->updateSite($organizationSlug, $serverId, $siteId, $data);
$forge->deleteSite($organizationSlug, $serverId, $siteId);
```
--------------------------------
### Install Laravel Forge CLI
Source: https://forge.laravel.com/docs/cli
Install the Laravel Forge CLI as a global Composer dependency. Requires PHP 8.2+.
```bash
composer global require laravel/forge-cli
```
--------------------------------
### Initiate Site Deployment
Source: https://forge.laravel.com/docs/cli
Trigger a deployment for a specific site. If no site is specified, it may default to the current project's site.
```bash
forge deploy
forge deploy example.com
```
--------------------------------
### Create a Site Without Waiting for Provisioning
Source: https://forge.laravel.com/docs/sdk
Create a new site for a server and disable the default asynchronous waiting. The operation will return immediately.
```php
$site = $forge->createSite($organizationSlug, $serverId, $data, false);
```
--------------------------------
### Discord Webhook Payload Example
Source: https://forge.laravel.com/docs/sites/deployments
This is an example of the JSON payload sent to a Discord webhook for deployment notifications. Ensure your webhook URL is correctly configured in Forge.
```json
{
"status": "success",
"server": {
"id": 123,
"name": "my-awesome-server"
},
"site": {
"id": 456,
"name": "my-awesome-site.dev"
},
"commit_hash": "382b0f5185773fa0f67a8ed8056c7759",
"commit_url": "https://github.com/johndoe/my-awesome-site/commit/382b0f5185773fa0f67a8ed8056c7759",
"commit_author": "John Doe",
"commit_message": "deploying!"
}
```
--------------------------------
### Create a Site with Default Asynchronous Waiting
Source: https://forge.laravel.com/docs/sdk
Create a new site for a server. By default, the SDK polls the API to wait for the site provisioning to complete, with a default timeout of 30 seconds.
```php
$site = $forge->createSite($organizationSlug, $serverId, [
'domain' => 'example.com',
'type' => 'php',
]);
```
--------------------------------
### Upgrade Node.js to Latest LTS
Source: https://forge.laravel.com/docs/knowledge-base/servers
Update Node.js to the latest LTS version by adding the NodeSource repository and installing the `nodejs` package. Ensure to update package lists before installation.
```bash
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=22
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install nodejs -y
```
--------------------------------
### Get Specific Backup Instance - OpenAPI
Source: https://forge.laravel.com/docs/api-reference/backups/get-backup
This OpenAPI definition describes the GET endpoint for retrieving a specific backup instance. It outlines the required path parameters and possible responses.
```yaml
openapi: 3.1.0
info:
title: Forge
version: 0.0.1
description: Laravel Forge - API Documentation
servers:
- url: https://forge.laravel.com/api
security:
- http: []
- oauth2: []
tags:
- name: Roles
- name: Sites
- name: Organizations
- name: Storage Providers
- name: Recipes
- name: Servers
- name: Background Processes
- name: Nginx
- name: Databases
- name: Backups
- name: Monitors
- name: Firewall Rules
- name: Logs
- name: SSH Keys
- name: Scheduled Jobs
- name: Security Rules
- name: Redirect Rules
- name: Integrations
- name: Deployments
- name: Commands
- name: Teams
- name: Server Credentials
- name: User
- name: Providers
paths:
/orgs/{organization}/servers/{server}/database/backups/{backupConfiguration}/instances/{backup}:
get:
tags:
- Backups
summary: Get backup
description: |-
Get a specific backup instance associated with the backup configuration.
Processing mode: sync
operationId: organizations.servers.database.backups.instances.show
parameters:
- name: organization
in: path
required: true
description: The organization slug
schema:
type: string
- name: server
in: path
required: true
description: The server ID
schema:
type: integer
- name: backupConfiguration
in: path
required: true
description: The backup configuration ID
schema:
type: integer
- name: backup
in: path
required: true
description: The backup ID
schema:
type: integer
responses:
'200':
description: '`BackupResource`'
content:
application/vnd.api+json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/BackupResource'
required:
- data
'403':
$ref: '#/components/responses/AuthorizationException'
'404':
$ref: '#/components/responses/ModelNotFoundException'
security:
- oauth2:
- server:create-backups
components:
schemas:
BackupResource:
type: object
properties:
id:
type: string
type:
type: string
enum:
- backups
attributes:
type: object
properties:
status:
type: string
is_partial:
type: string
size:
type: integer
finished_at:
type: string
required:
- status
- is_partial
- size
- finished_at
links:
type: object
properties:
self:
$ref: '#/components/schemas/Link'
required:
- self
required:
- id
- type
- links
title: BackupResource
Link:
type: object
properties:
href:
type: string
format: uri
rel:
type: string
describedby:
type: string
title:
type: string
type:
type: string
hreflang:
anyOf:
- type: string
- type: array
items:
type: string
meta:
type: object
required:
- href
title: Link
responses:
AuthorizationException:
description: Authorization error
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error overview.
required:
- message
ModelNotFoundException:
description: Not found
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error overview.
required:
- message
securitySchemes:
http:
type: http
scheme: bearer
oauth2:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://forge.laravel.com/oauth/authorize
```
--------------------------------
### List All Servers
Source: https://forge.laravel.com/docs/cli
Lists all available servers within the current organization.
```bash
forge server:list
```
--------------------------------
### Initialize Forge SDK with API Token
Source: https://forge.laravel.com/docs/sdk
Instantiate the Forge SDK client by providing your API token. This is the first step before making any API calls.
```php
$forge = new Laravel\Forge\Forge($token);
```
--------------------------------
### OpenAPI Specification for Get Command Output
Source: https://forge.laravel.com/docs/api-reference/commands/get-command-output
This OpenAPI specification defines the GET endpoint for retrieving command output. It includes parameters for organization, server, site, and command IDs, and specifies the response structure for command output.
```yaml
openapi: 3.1.0
info:
title: Forge
version: 0.0.1
description: Laravel Forge - API Documentation
servers:
- url: https://forge.laravel.com/api
security:
- http: []
- oauth2: []
tags:
- name: Roles
- name: Sites
- name: Organizations
- name: Storage Providers
- name: Recipes
- name: Servers
- name: Background Processes
- name: Nginx
- name: Databases
- name: Backups
- name: Monitors
- name: Firewall Rules
- name: Logs
- name: SSH Keys
- name: Scheduled Jobs
- name: Security Rules
- name: Redirect Rules
- name: Integrations
- name: Deployments
- name: Commands
- name: Teams
- name: Server Credentials
- name: User
- name: Providers
paths:
/orgs/{organization}/servers/{server}/sites/{site}/commands/{command}/output:
get:
tags:
- Commands
summary: Get command output
description: |-
Get the output of a specific command run.
Processing mode: sync
operationId: organizations.servers.sites.commands.output.show
parameters:
- name: organization
in: path
required: true
description: The organization slug
schema:
type: string
- name: server
in: path
required: true
description: The server ID
schema:
type: integer
- name: site
in: path
required: true
description: The site ID
schema:
type: integer
- name: command
in: path
required: true
description: The command ID
schema:
type: integer
responses:
'200':
description: '`CommandOutputResource`'
content:
application/vnd.api+json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/CommandOutputResource'
required:
- data
'403':
$ref: '#/components/responses/AuthorizationException'
'404':
$ref: '#/components/responses/ModelNotFoundException'
security:
- oauth2:
- server:view
components:
schemas:
CommandOutputResource:
type: object
properties:
id:
type: string
type:
type: string
enum:
- commandOutputs
attributes:
type: object
properties:
output:
type: string
description: The output of the command execution.
examples:
- Now using node v22.0.0 (npm v10.5.1)
required:
- output
links:
type: object
properties:
self:
$ref: '#/components/schemas/Link'
description: A link to the resource itself
required:
- self
required:
- id
- type
- links
title: CommandOutputResource
Link:
type: object
properties:
href:
type: string
format: uri
rel:
type: string
describedby:
type: string
title:
type: string
type:
type: string
hreflang:
anyOf:
- type: string
- type: array
items:
type: string
meta:
type: object
required:
- href
title: Link
responses:
AuthorizationException:
description: Authorization error
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error overview.
required:
- message
ModelNotFoundException:
description: Not found
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error overview.
required:
- message
securitySchemes:
http:
type: http
scheme: bearer
oauth2:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://forge.laravel.com/oauth/authorize
tokenUrl: https://forge.laravel.com/oauth/token
scopes:
```
--------------------------------
### Manage Site Configuration
Source: https://forge.laravel.com/docs/sdk
Configure site-specific settings including the environment file, Nginx configuration, and PHP version.
```php
// Environment file
$forge->siteEnvironment($organizationSlug, $serverId, $siteId);
$forge->updateSiteEnvironment($organizationSlug, $serverId, $siteId, $content);
// Nginx configuration
$forge->siteNginx($organizationSlug, $serverId, $siteId);
$forge->updateSiteNginx($organizationSlug, $serverId, $siteId, $content);
// PHP version
$forge->sitePhp($organizationSlug, $serverId, $siteId);
$forge->updateSitePhp($organizationSlug, $serverId, $siteId, ['version' => 'php84']);
```
--------------------------------
### Get Background Process OpenAPI Specification
Source: https://forge.laravel.com/docs/api-reference/background-processes/get-background-process
This OpenAPI specification defines the GET endpoint for retrieving a background process. It includes parameters for organization, server, and background process IDs, and outlines the response structure for a successful retrieval.
```yaml
openapi: 3.1.0
info:
title: Forge
version: 0.0.1
description: Laravel Forge - API Documentation
servers:
- url: https://forge.laravel.com/api
security:
- http: []
- oauth2: []
tags:
- name: Roles
- name: Sites
- name: Organizations
- name: Storage Providers
- name: Recipes
- name: Servers
- name: Background Processes
- name: Nginx
- name: Databases
- name: Backups
- name: Monitors
- name: Firewall Rules
- name: Logs
- name: SSH Keys
- name: Scheduled Jobs
- name: Security Rules
- name: Redirect Rules
- name: Integrations
- name: Deployments
- name: Commands
- name: Teams
- name: Server Credentials
- name: User
- name: Providers
paths:
/orgs/{organization}/servers/{server}/background-processes/{backgroundProcess}:
get:
tags:
- Background Processes
summary: Get background process
description: |2
Processing mode: sync
operationId: organizations.servers.background-processes.show
parameters:
- name: organization
in: path
required: true
description: The organization slug
schema:
type: string
- name: server
in: path
required: true
description: The server ID
schema:
type: integer
- name: backgroundProcess
in: path
required: true
description: The background process ID
schema:
type: integer
responses:
'200':
description: '`BackgroundProcessResource`'
content:
application/vnd.api+json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/BackgroundProcessResource'
required:
- data
'403':
$ref: '#/components/responses/AuthorizationException'
'404':
$ref: '#/components/responses/ModelNotFoundException'
security:
- oauth2:
- server:view
components:
schemas:
BackgroundProcessResource:
type: object
properties:
id:
type: string
type:
type: string
enum:
- backgroundProcesses
attributes:
type: object
properties:
command:
type: string
description: The command that the background process is running.
examples:
- php artisan queue:work database
user:
type: string
description: The user that the background process is running as.
examples:
- forge
directory:
type:
- string
- 'null'
description: The directory that the background process is running in.
examples:
- /home/forge/forge.laravel.com
processes:
type: integer
description: The number of processes that the background process is running.
examples:
- 3
status:
type: string
description: The status of the background process.
enum:
- installing
- installed
- removing
- restarting
- starting
- stopping
examples:
- running
created_at:
type: string
format: date-time
description: The date and time the background process was created.
examples:
- '2025-07-29T09:00:00Z'
required:
- command
- user
- directory
- processes
- status
- created_at
required:
- id
- type
title: BackgroundProcessResource
responses:
AuthorizationException:
description: Authorization error
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Error overview.
required:
- message
ModelNotFoundException:
description: Not found
content:
application/json:
schema:
type: object
properties:
message:
type: string
```
--------------------------------
### Install Composer Dependencies
Source: https://forge.laravel.com/docs/sites/the-basics
This command is used by Laravel Forge to install Composer dependencies for PHP sites. It's typically run after a site is created and added to the default deploy script for future deployments. Ensure your project has a composer.lock file if this option is enabled.
```bash
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
```
--------------------------------
### Create a New Server
Source: https://forge.laravel.com/docs/sdk
Create a new server within a specified organization. Requires the organization slug and an array of server configuration parameters, including provider, name, size, and region.
```php
use Laravel\Forge\ServerProviders;
use Laravel\Forge\InstallableServices;
$server = $forge->createServer($organizationSlug, [
'provider' => ServerProviders::DIGITAL_OCEAN,
'credential_id' => 1,
'name' => 'test-via-api',
'type' => 'app',
'size' => '01',
'database' => 'test123',
'database_type' => InstallableServices::POSTGRES,
'php_version' => InstallableServices::PHP_84,
'region' => 'ams2',
]);
```
--------------------------------
### Site Configuration
Source: https://forge.laravel.com/docs/sdk
Manage site configuration files like environment, Nginx, and PHP version.
```APIDOC
### Site Configuration
#### Environment File
Manage the environment file for a site.
- **organizationSlug** (string): The slug of the organization.
- **serverId** (integer): The ID of the server.
- **siteId** (integer): The ID of the site.
- **content** (string): The new content for the environment file.
```php
// Get environment file content
$forge->siteEnvironment($organizationSlug, $serverId, $siteId);
// Update environment file content
$forge->updateSiteEnvironment($organizationSlug, $serverId, $siteId, $content);
```
#### Nginx Configuration
Manage the Nginx configuration file for a site.
- **organizationSlug** (string): The slug of the organization.
- **serverId** (integer): The ID of the server.
- **siteId** (integer): The ID of the site.
- **content** (string): The new content for the Nginx configuration.
```php
// Get Nginx configuration
$forge->siteNginx($organizationSlug, $serverId, $siteId);
// Update Nginx configuration
$forge->updateSiteNginx($organizationSlug, $serverId, $siteId, $content);
```
#### PHP Version
Manage the PHP version for a site.
- **organizationSlug** (string): The slug of the organization.
- **serverId** (integer): The ID of the server.
- **siteId** (integer): The ID of the site.
- **versionData** (array): An array specifying the new PHP version (e.g., `['version' => 'php84']`).
```php
// Get current PHP version
$forge->sitePhp($organizationSlug, $serverId, $siteId);
// Update PHP version
$forge->updateSitePhp($organizationSlug, $serverId, $siteId, ['version' => 'php84']);
```
```
--------------------------------
### Get Backup Configuration OpenAPI Spec
Source: https://forge.laravel.com/docs/api-reference/backups/get-backup-configuration
This OpenAPI specification defines the GET endpoint for retrieving a specific backup configuration. It outlines the required path parameters, including organization, server ID, and backup configuration ID, as well as the structure of the successful response.
```yaml
https://forge.laravel.com/api/docs.openapi get /orgs/{organization}/servers/{server}/database/backups/{backupConfiguration}
openapi: 3.1.0
info:
title: Forge
version: 0.0.1
description: Laravel Forge - API Documentation
servers:
- url: https://forge.laravel.com/api
security:
- http: []
- oauth2: []
tags:
- name: Roles
- name: Sites
- name: Organizations
- name: Storage Providers
- name: Recipes
- name: Servers
- name: Background Processes
- name: Nginx
- name: Databases
- name: Backups
- name: Monitors
- name: Firewall Rules
- name: Logs
- name: SSH Keys
- name: Scheduled Jobs
- name: Security Rules
- name: Redirect Rules
- name: Integrations
- name: Deployments
- name: Commands
- name: Teams
- name: Server Credentials
- name: User
- name: Providers
paths:
/orgs/{organization}/servers/{server}/database/backups/{backupConfiguration}:
get:
tags:
- Backups
summary: Get backup configuration
description: |-
Get a specific backup configuration for the server.
Processing mode: sync
operationId: organizations.servers.database.backups.show
parameters:
- name: organization
in: path
required: true
description: The organization slug
schema:
type: string
- name: server
in: path
required: true
description: The server ID
schema:
type: integer
- name: backupConfiguration
in: path
required: true
description: The backup configuration ID
schema:
type: integer
responses:
'200':
description: '`BackupConfigurationResource`'
content:
application/vnd.api+json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/BackupConfigurationResource'
required:
- data
'403':
$ref: '#/components/responses/AuthorizationException'
'404':
$ref: '#/components/responses/ModelNotFoundException'
security:
- oauth2:
- server:view
components:
schemas:
BackupConfigurationResource:
type: object
properties:
id:
type: string
type:
type: string
enum:
- backupConfigurations
attributes:
type: object
properties:
name:
type: string
storage_provider_id:
type:
- integer
- 'null'
provider:
type: string
bucket:
type:
- string
- 'null'
directory:
type: string
schedule:
type: string
displayable_schedule:
type: string
next_run_time:
type: string
status:
type: string
day_of_week:
type:
- integer
- 'null'
time:
type:
- string
- 'null'
cron_schedule:
type:
- string
- 'null'
database_ids:
type: array
items: {}
retention:
type: integer
notify_email:
type:
- string
- 'null'
required:
- name
- storage_provider_id
- provider
- bucket
- directory
- schedule
- displayable_schedule
- next_run_time
- status
- day_of_week
- time
- cron_schedule
- database_ids
- retention
- notify_email
links:
type: object
properties:
self:
$ref: '#/components/schemas/Link'
required:
- self
required:
- id
- type
- links
title: BackupConfigurationResource
Link:
type: object
properties:
href:
type: string
format: uri
rel:
type: string
describedby:
type: string
title:
type: string
type:
type: string
hreflang:
anyOf:
- type: string
- type: array
items:
```
--------------------------------
### Get command output
Source: https://forge.laravel.com/docs/api-reference/commands/get-command-output
Retrieves the output of a specific command run. This operation is synchronous.
```APIDOC
## GET /orgs/{organization}/servers/{server}/sites/{site}/commands/{command}/output
### Description
Get the output of a specific command run.
Processing mode: sync
### Method
GET
### Endpoint
/orgs/{organization}/servers/{server}/sites/{site}/commands/{command}/output
### Parameters
#### Path Parameters
- **organization** (string) - Required - The organization slug
- **server** (integer) - Required - The server ID
- **site** (integer) - Required - The site ID
- **command** (integer) - Required - The command ID
### Responses
#### Success Response (200)
- **data** (CommandOutputResource) - Contains the command output details.
- **id** (string)
- **type** (string) - enum: commandOutputs
- **attributes** (object)
- **output** (string) - The output of the command execution.
- **links** (object)
- **self** (Link) - A link to the resource itself
#### Response Example
```json
{
"data": {
"id": "123",
"type": "commandOutputs",
"attributes": {
"output": "Now using node v22.0.0 (npm v10.5.1)"
},
"links": {
"self": "https://forge.laravel.com/api/servers/1/sites/1/commands/1/output"
}
}
}
```
#### Error Responses
- **403** - AuthorizationException: Indicates insufficient permissions.
- **404** - ModelNotFoundException: Indicates that the specified resource was not found.
```
--------------------------------
### Manage Site Deployments
Source: https://forge.laravel.com/docs/sdk
Handle site deployments, including managing webhooks, deployment scripts, and push-to-deploy configurations.
```php
$webhooks = $forge->webhooks($organizationSlug, $serverId, $siteId);
$forge->createWebhook($organizationSlug, $serverId, $siteId, $data);
$script = $forge->deploymentScript($organizationSlug, $serverId, $siteId);
$forge->updateDeploymentScript($organizationSlug, $serverId, $siteId, $content);
$deployment = $forge->createDeployment($organizationSlug, $serverId, $siteId);
$forge->createPushToDeploy($organizationSlug, $serverId, $siteId, $data);
$forge->deletePushToDeploy($organizationSlug, $serverId, $siteId);
```
--------------------------------
### Get Background Process Log
Source: https://forge.laravel.com/docs/api-reference/background-processes/get-background-process-log
Fetches the log for a specific background process. The processing mode is synchronous.
```APIDOC
## GET /orgs/{organization}/servers/{server}/background-processes/{backgroundProcess}/log
### Description
Retrieves the log content for a specific background process. Processing mode: sync.
### Method
GET
### Endpoint
/orgs/{organization}/servers/{server}/background-processes/{backgroundProcess}/log
### Parameters
#### Path Parameters
- **organization** (string) - Required - The organization slug
- **server** (integer) - Required - The server ID
- **backgroundProcess** (integer) - Required - The background process ID
### Responses
#### Success Response (200)
- **data** (BackgroundProcessLogResource) - The background process log resource.
### Response Example
```json
{
"data": {
"id": "string",
"type": "backgroundProcessLogs",
"attributes": {
"content": "The content of the log."
},
"links": {
"self": "A link to the resource itself"
}
}
}
```
#### Error Response (403)
- **message** (string) - Error overview.
#### Error Response (404)
- **message** (string) - Error overview.
```
--------------------------------
### Enter Tinker Environment
Source: https://forge.laravel.com/docs/cli
Access the Tinker REPL (Read-Eval-Print Loop) for a specific Laravel site on the remote server.
```bash
forge tinker
forge tinker example.com
```
--------------------------------
### Check current kmod version
Source: https://forge.laravel.com/docs/knowledge-base/cve-2026-31431
SSH into your server and run this command to check the currently installed kmod version before applying the fix.
```bash
dpkg -l kmod
```
--------------------------------
### Restart a Background Process with ID
Source: https://forge.laravel.com/docs/resources/background-processes
Example of restarting a background process with a specific ID. Replace '{id}' with the actual process identifier.
```bash
sudo -S supervisorctl restart daemon-65654:*
```
--------------------------------
### Create Backup Configuration
Source: https://forge.laravel.com/docs/api-reference/backups/get-backup-configuration
Allows members to create database backup configurations for servers.
```APIDOC
## Create Backup Configuration
### Description
Allows members to create database backup configurations.
### Method
POST
### Endpoint
/servers/{server_id}/database-backups
### Parameters
#### Path Parameters
- **server_id** (integer) - Required - The ID of the server.
#### Request Body
- **database** (string) - Required - The name of the database.
- **name** (string) - Required - The name of the backup configuration.
- **frequency** (string) - Required - The frequency of the backup (e.g., "daily", "weekly").
- **time** (string) - Required - The time of the backup (e.g., "03:00").
### Response
#### Success Response (201)
- **id** (integer) - The ID of the created backup configuration.
- **database** (string) - The name of the database.
- **name** (string) - The name of the backup configuration.
- **frequency** (string) - The frequency of the backup.
- **time** (string) - The time of the backup.
- **created_at** (string) - The timestamp when the backup configuration was created.
```
--------------------------------
### Resource Relationships Example
Source: https://forge.laravel.com/docs/api-reference/relationships
This JSON structure shows how relationships are represented within a resource response. It indicates that a resource has a relationship to 'tags'.
```json
// ...
{
"relationships": {
"tags": {
"data": [
{
"type": "tags",
"id": ""
}
]
}
}
},
// ...
```
--------------------------------
### Manage Servers
Source: https://forge.laravel.com/docs/sdk
Retrieve lists of servers, create new servers, delete existing ones, and perform actions like rebooting. Also includes fetching archived servers.
```php
$servers = $forge->servers($organizationSlug);
$server = $forge->server($organizationSlug, $serverId);
$server = $forge->createServer($organizationSlug, $data);
$forge->deleteServer($organizationSlug, $serverId);
// Server actions, such as reboot
$forge->createServerAction($organizationSlug, $serverId, [
'action' => 'reboot',
]);
// Archived servers
$archivedServers = $forge->archivedServers($organizationSlug);
```
--------------------------------
### Upgrade npm to Latest Version
Source: https://forge.laravel.com/docs/knowledge-base/servers
Update npm to the latest version globally using the command `sudo npm install npm@latest -g`.
```bash
sudo npm install npm@latest -g
```
--------------------------------
### Pull Site Environment Variables
Source: https://forge.laravel.com/docs/cli
Download the environment file for a given site to your local machine. You can specify a destination path for the file.
```bash
forge env:pull
forge env:pull pestphp.com
forge env:pull pestphp.com .env
```
--------------------------------
### Manage Recipes with Forge SDK
Source: https://forge.laravel.com/docs/sdk
This snippet demonstrates how to manage organization-specific and Forge-provided recipes. You can list, create, and run recipes using the SDK.
```php
// Organization recipes
$recipes = $forge->recipes($organizationSlug);
$recipe = $forge->createRecipe($organizationSlug, $data);
$run = $forge->createRecipeRun($organizationSlug, $recipeId, $data);
// Forge-provided recipes
$forgeRecipes = $forge->forgeRecipes();
```
--------------------------------
### View Site Logs
Source: https://forge.laravel.com/docs/cli
Access the log files for a specific site. The `--follow` option allows for real-time log monitoring.
```bash
forge site:logs
forge site:logs --follow # View logs in realtime
forge site:logs example.com
forge site:logs example.com --follow # View logs in realtime
```
--------------------------------
### Create Background Process
Source: https://forge.laravel.com/docs/api-reference/background-processes/create-background-process
Initiates a new background process. Requires specifying the command to execute, the user under which to run it, the working directory, the number of processes, and the initial status.
```APIDOC
## POST /api/background-processes
### Description
Creates a new background process.
### Method
POST
### Endpoint
/api/background-processes
### Parameters
#### Request Body
- **command** (string) - Required - The command to execute for the background process.
- **user** (string) - Required - The user that the background process will run as.
- **directory** (string) - Required - The directory that the background process is running in.
- **processes** (integer) - Required - The number of processes that the background process is running.
- **status** (string) - Required - The status of the background process. Possible values: installing, installed, removing, restarting, starting, stopping.
- **created_at** (string) - Required - The date and time the background process was created.
### Request Example
{
"command": "php artisan queue:work",
"user": "forge",
"directory": "/home/forge/forge.laravel.com",
"processes": 3,
"status": "running",
"created_at": "2025-07-29T09:00:00Z"
}
### Response
#### Success Response (200)
- **id** (integer) - The unique identifier of the created background process.
- **type** (string) - The type of the resource.
- **command** (string) - The command executed by the background process.
- **user** (string) - The user running the background process.
- **directory** (string) - The directory where the background process is running.
- **processes** (integer) - The number of processes.
- **status** (string) - The current status of the background process.
- **created_at** (string) - The date and time the background process was created.
#### Response Example
{
"id": 1,
"type": "background-process",
"command": "php artisan queue:work",
"user": "forge",
"directory": "/home/forge/forge.laravel.com",
"processes": 3,
"status": "running",
"created_at": "2025-07-29T09:00:00Z"
}
### Error Handling
- **AuthorizationException**: Returned if the request is not authorized.
- **ModelNotFoundException**: Returned if the specified resource is not found.
- **ValidationException**: Returned if the request body fails validation.
```
--------------------------------
### Get Organization Slug
Source: https://forge.laravel.com/docs/sdk
Retrieve the list of organizations for the authenticated user and extract the slug from the first organization. This slug is required for most resource-scoped API calls.
```php
$organizations = $forge->organizations();
$organizationSlug = $organizations[0]->slug;
```
--------------------------------
### Create a database restore from backup
Source: https://forge.laravel.com/docs/api-reference/backups/create-a-database-restore-from-backup
Restore the given database from the backup. Processing mode: async
```APIDOC
## POST /orgs/{organization}/servers/{server}/database/backups/{backupConfiguration}/instances/{backup}/restores
### Description
Restore the given database from the backup.
Processing mode: async
### Method
POST
### Endpoint
`/orgs/{organization}/servers/{server}/database/backups/{backupConfiguration}/instances/{backup}/restores`
### Parameters
#### Path Parameters
- **organization** (string) - Required - The organization slug
- **server** (integer) - Required - The server ID
- **backupConfiguration** (integer) - Required - The backup configuration ID
- **backup** (integer) - Required - The backup ID
#### Request Body
- **database_id** (integer) - Required - The ID of the database to restore.
### Responses
#### Success Response (202)
This response indicates that the restore operation has been successfully initiated.
#### Error Response (403)
- **message** (string) - Description: Authorization error.
#### Error Response (404)
- **message** (string) - Description: Not found.
#### Error Response (422)
- **message** (string) - Description: Validation error overview.
- **errors** (object) - Description: A detailed description of each field that failed validation.
```