Create background process
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Custom command runner',
'command' => 'php artisan custom:command',
'user' => 'forge',
'processes' => 1,
'site_id' => 12345,
'directory' => '/home/forge/my-site.com/current/',
'startsecs' => 10,
'stopwaitsecs' => 10,
'stopsignal' => 'SIGTERM'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Custom command runner",
"command": "php artisan custom:command",
"user": "forge",
"processes": 1,
"site_id": 12345,
"directory": "/home/forge/my-site.com/current/",
"startsecs": 10,
"stopwaitsecs": 10,
"stopsignal": "SIGTERM"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Custom command runner',
command: 'php artisan custom:command',
user: 'forge',
processes: 1,
site_id: 12345,
directory: '/home/forge/my-site.com/current/',
startsecs: 10,
stopwaitsecs: 10,
stopsignal: 'SIGTERM'
})
};
fetch('https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes"
payload := strings.NewReader("{\n \"name\": \"Custom command runner\",\n \"command\": \"php artisan custom:command\",\n \"user\": \"forge\",\n \"processes\": 1,\n \"site_id\": 12345,\n \"directory\": \"/home/forge/my-site.com/current/\",\n \"startsecs\": 10,\n \"stopwaitsecs\": 10,\n \"stopsignal\": \"SIGTERM\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"data": {
"id": "<string>",
"type": "backgroundProcesses",
"attributes": {
"command": "php artisan queue:work database",
"user": "forge",
"directory": "/home/forge/forge.laravel.com",
"processes": 3,
"status": "running",
"created_at": "2025-07-29T09:00:00Z"
}
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Background Processes
Create background process
Create a new background process from a template.
Processing mode: async
POST
/
orgs
/
{organization}
/
servers
/
{server}
/
background-processes
Create background process
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Custom command runner',
'command' => 'php artisan custom:command',
'user' => 'forge',
'processes' => 1,
'site_id' => 12345,
'directory' => '/home/forge/my-site.com/current/',
'startsecs' => 10,
'stopwaitsecs' => 10,
'stopsignal' => 'SIGTERM'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Custom command runner",
"command": "php artisan custom:command",
"user": "forge",
"processes": 1,
"site_id": 12345,
"directory": "/home/forge/my-site.com/current/",
"startsecs": 10,
"stopwaitsecs": 10,
"stopsignal": "SIGTERM"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Custom command runner',
command: 'php artisan custom:command',
user: 'forge',
processes: 1,
site_id: 12345,
directory: '/home/forge/my-site.com/current/',
startsecs: 10,
stopwaitsecs: 10,
stopsignal: 'SIGTERM'
})
};
fetch('https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/background-processes"
payload := strings.NewReader("{\n \"name\": \"Custom command runner\",\n \"command\": \"php artisan custom:command\",\n \"user\": \"forge\",\n \"processes\": 1,\n \"site_id\": 12345,\n \"directory\": \"/home/forge/my-site.com/current/\",\n \"startsecs\": 10,\n \"stopwaitsecs\": 10,\n \"stopsignal\": \"SIGTERM\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"data": {
"id": "<string>",
"type": "backgroundProcesses",
"attributes": {
"command": "php artisan queue:work database",
"user": "forge",
"directory": "/home/forge/forge.laravel.com",
"processes": 3,
"status": "running",
"created_at": "2025-07-29T09:00:00Z"
}
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Body
application/json
The name of the background process.
Example:
"Custom command runner"
The command to run.
Example:
"php artisan custom:command"
The user to run the background process as.
Available options:
root, forge Example:
"forge"
The number of processes to run.
Required range:
x >= 1Example:
1
The site to associate the background process with.
Example:
12345
The directory to run the background process from.
Example:
"/home/forge/my-site.com/current/"
The number of seconds to wait before starting the process.
Required range:
x >= 0Example:
10
The number of seconds to wait before stopping the process.
Required range:
x >= 0Example:
10
The signal to send to stop the process.
Example:
"SIGTERM"
Response
BackgroundProcessResource
Show child attributes
Show child attributes
Was this page helpful?