Skip to content
Limit concurrent runs

Limit concurrent runs

This guide limits how many copies of your application run at the same time on one device. At the end, your application reports each copy when it starts, sends process heartbeats while it runs and reports the exit when it closes. Seatify refuses a new copy when the device is at the limit.

Before you start

  • Your application claims and validates licenses. See Add your application.
  • The policy binds devices and has a process interval. The process interval turns on process tracking. Set a process limit per device to limit the copies. See Concurrent runs.

The examples call https://license.seatify.dev. In curl, the keys, the fingerprint and the process ID are the variables $SEATIFY_PUBLISHABLE_KEY, $LICENSE_KEY, $DEVICE_FINGERPRINT and $PROCESS_ID. In the other languages, they are variables of your application.

Choose a process ID

Each copy of your application sends a process ID. The ID identifies the copy on the device. Send the same ID in the spawn, in each heartbeat and in the exit.

The process ID from the operating system works:

LanguageProcess ID
SwiftProcessInfo.processInfo.processIdentifier
C#Environment.ProcessId
Goos.Getpid()
JavaScript (Node.js)process.pid

Send the ID as a string, such as "4242". A number fails with the status 400. A runtime without a process ID can send its own identifier. For example, it can create a random UUID when it starts.

The process ID is case-sensitive. The operating system can give the ID of a stopped copy to a new copy. If the old copy stopped without an exit, Seatify treats the two as one process. The new copy then takes no extra slot.

Steps

Claim the license

The device must claim the license before the first spawn. A spawn from a device that has not claimed fails with not_claimed. See Claim the license.

The claim answer shows whether the policy tracks processes. process_heartbeat.tracked is true when the policy has a process interval.

Spawn the process

Spawn the process each time your application starts, after the validation. Send the stored license key, the fingerprint and the process ID.

curl https://license.seatify.dev/v1/processes/spawn \
  -H "Seatify-Publishable-Key: $SEATIFY_PUBLISHABLE_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "key": "$LICENSE_KEY",
  "device": { "fingerprint": "$DEVICE_FINGERPRINT" },
  "process": { "pid": "$PROCESS_ID" }
}
EOF

A successful spawn answers with valid set to true:

{
  "valid": true,
  "status": "active",
  "expired": false,
  "reason": null,
  "license": {
    "id": "<license id>",
    "name": "Studio team",
    "expires_at": "2026-12-20T00:00:00Z",
    "activated_at": "2026-01-22T01:50:56Z"
  },
  "entitlements": [],
  "limits": {
    "max_devices": 50,
    "max_seats": 25,
    "max_processes": 4
  },
  "device": {
    "id": "<device binding id>",
    "expires_at": "2026-09-26T07:45:15Z"
  },
  "heartbeat": {
    "required": true,
    "interval_seconds": 3600,
    "grace_seconds": 1800
  },
  "process": {
    "id": "<process id>",
    "pid": "4242",
    "expires_at": "2026-09-26T06:22:15Z"
  },
  "process_heartbeat": {
    "tracked": true,
    "interval_seconds": 300,
    "grace_seconds": 120
  }
}

The process.expires_at field shows when the lease of the process ends. The limits.max_processes field is the limit that applies to this device. The list of entitlements is empty in a spawn answer. Read the entitlements from the claim or the validation.

A spawn with a process ID that is already running returns the same process. It does not use another slot.

If valid is false, the reason field names the cause. For process_limit_reached, see When the limit is reached. For the other reasons, see Handle the answer.

Send process heartbeats

Send a process heartbeat every process_heartbeat.interval_seconds while your application runs. Send the same body as in the spawn.

curl https://license.seatify.dev/v1/processes/heartbeat \
  -H "Seatify-Publishable-Key: $SEATIFY_PUBLISHABLE_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "key": "$LICENSE_KEY",
  "device": { "fingerprint": "$DEVICE_FINGERPRINT" },
  "process": { "pid": "$PROCESS_ID" }
}
EOF

Each heartbeat starts the lease of the process again. The lease lasts for the process interval plus the process grace. The answer shows the new end of the lease in process.expires_at.

Process heartbeats do not replace license heartbeats. If the policy requires heartbeats, send both. See Send heartbeats.

If the lease has ended, the heartbeat fails with process_not_spawned. Spawn the process again. The spawn checks the limit again. If the heartbeat fails with not_claimed, claim the license again, and then spawn again.

Report the exit

Report the exit when your application closes. Send the same body as in the spawn.

curl https://license.seatify.dev/v1/processes/exit \
  -H "Seatify-Publishable-Key: $SEATIFY_PUBLISHABLE_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "key": "$LICENSE_KEY",
  "device": { "fingerprint": "$DEVICE_FINGERPRINT" },
  "process": { "pid": "$PROCESS_ID" }
}
EOF

The answer has exited set to true:

{
  "exited": true,
  "reason": null
}

The slot is free immediately. The exit also works on an expired or suspended license. If your application stops without an exit, the slot is free when the lease ends.

When the limit is reached

A spawn fails with process_limit_reached when all slots of the device are taken. The refused spawn does not change the running processes.

  1. Do not start the work of the copy. Tell the user that the limit of copies on this device is reached. You can show the limit from limits.max_processes.
  2. Let the user close another copy, and then spawn again.

A copy that stopped without an exit keeps its slot until its lease ends. This takes at most the process interval plus the process grace.

Handle the answer

The License API answers every licensing outcome with the status 200, a refusal too. Your application decides on valid, or on exited for an exit. The reason field names the cause of a refusal.

ReasonAnswered byWhat your application does
license_not_foundSpawn, heartbeat, exitAsk the user to enter the key again.
product_mismatchSpawn, heartbeat, exitThe key belongs to another product. Ask the user for the right key.
expiredSpawn, heartbeatTell the user that the license has expired.
suspendedSpawn, heartbeatTell the user that the license is suspended.
process_tracking_not_enabledSpawn, heartbeatThe policy has no process interval. Stop reporting processes.
not_claimedSpawn, heartbeat, exitClaim the license again, and then spawn again. After an exit, no action is needed.
process_limit_reachedSpawnSee When the limit is reached.
process_not_spawnedHeartbeat, exitSpawn the process again. After an exit, no action is needed.

Other statuses mean that the request itself is wrong:

StatusCause
400The body is not valid. The errors field names each field that is wrong, such as a missing device or process. A body that cannot be read has no errors field. A process ID sent as a number causes this.
401The publishable key is missing or not valid.
429Your application sent too many requests. Try again later.

Signed responses

Every answer with the status 200 is signed. Your application can check the signature before it trusts the answer. See Verify signed responses.

Next steps