# Calling the AFT! REST API directly to trigger a job

If you need to trigger an AFT! job from a script or tool that cannot run the aft start command, you can call the REST API directly. All you need is an API key and the name of the script you want to run.

Create the API key in the AFT! web UI under **API Keys**, and make sure its IP allow-list includes the machine making the request.

##### Windows (PowerShell)

Minimal example:

```powershell
$headers = @{ "X-API-Key" = "your-api-key-here" }
$body    = @{ scriptName = "My Backup Job" } | ConvertTo-Json

Invoke-RestMethod -Method POST `
    -Uri "https://127.0.0.1:44399/v1/jobs" `
    -Headers $headers `
    -ContentType "application/json" `
    -Body $body `
    -SkipCertificateCheck
```

With parameters:

```powershell
$headers = @{ "X-API-Key" = "your-api-key-here" }
$body    = @{
    scriptName = "My Backup Job"
    params     = @{ destination = "/archive/2026"; character = "goofy" }
} | ConvertTo-Json -Depth 3

Invoke-RestMethod -Method POST `
    -Uri "https://127.0.0.1:44399/v1/jobs" `
    -Headers $headers `
    -ContentType "application/json" `
    -Body $body `
    -SkipCertificateCheck
```

##### Linux/MacOS

Minimal example:

```bash
curl -sk -X POST https://127.0.0.1:44399/v1/jobs \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"scriptName":"My Backup Job"}'
```

With parameters:

```bash
curl -sk -X POST https://127.0.0.1:44399/v1/jobs \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"scriptName":"My Backup Job","params":{"destination":"/archive/2026","character":"goofy"}}'
```

##### Request-body reference

<table border="1" id="bkmrk-field-type-descripti" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 18.9511%;"></col><col style="width: 17.2867%;"></col><col style="width: 63.7621%;"></col></colgroup><tbody><tr><td>**Field**</td><td>**Type**</td><td>**Description**</td></tr><tr><td>`scriptName`</td><td>*string*</td><td>Name of the stored script to run (case-insensitive). Use this in new integrations.</td></tr><tr><td>`scriptId`</td><td>*string*</td><td>Script ID. Kept for backward compatibility with AFT! v3 integrations; prefer `scriptName`.</td></tr><tr><td>`filePath`</td><td>*string*</td><td>Path to a `.syncjs` file on disk. Alternative to `scriptName`/`scriptId`.</td></tr><tr><td>`params`</td><td>*object*</td><td>Named parameters passed to the script as a flat key/value object.</td></tr></tbody></table>

Exactly one of `scriptName`, `scriptId`, or `filePath` must be provided. On success the API returns `201 Created` with a job info object containing the job ID, which you can use to poll `GET /v1/adm/jobs/{id}` for status.

<p class="callout info">The `-SkipCertificateCheck` / `-sk` flags are needed when AFT! is using a self-signed TLS certificate, which is the default for local installations.</p>