Exchange is excluded from this API/CLI release. Any historical Exchange API or CLI example in this guide is unavailable; native portal behavior is outside this exclusion. See [current release scope](/developers/guides/release-scope?lang=en).

# Workspace billing and ownership claims

Monthly invoice planning holds a durable company claim before reading billable periods. Ownership administration uses the same company boundary. This prevents a paused invoice planner from resuming with a stale plan after ownership changes. The claim covers the complete native invoicing operation; supplier calls remain outside SQL transactions.

A short cache lock coordinates ordinary requests. The SQL claim remains authoritative if that cache lock expires. Claims never expire automatically: a stopped process must not silently turn into permission for another planner. A normal return or handled exception releases only that operation's own claim. Claim acquisition, release and operator recovery are recorded in the security audit log. An application rollback preserves unresolved claims.

## Customers and API agents

- `workspace_billing_busy`: another operation currently owns the company cache lock. Wait for its original operation to finish, then retry the intended action with the appropriate current version.
- `workspace_billing_requires_reconciliation`: a durable claim still exists after ordinary cache coordination. Ask a Binadit operator to inspect the original producer and accounting outcome.
- `workspace_billing_claim_lost`: a producer's original claim changed. It cannot submit another invoice effect or mark periods billed. Preserve the original operation for reconciliation.

A claim refusal does not cancel an order, refund money, transfer ownership or stop an already accepted supplier request. Do not work around it with another company ID, an extra invoice, a new payment or changed billing dates. Continue to inspect the original operation and invoice. Service credentials do not obtain server access or claim recovery rights.

## Operator inspection

These are SSH/operator Artisan commands, separate from the customer CLI. Run them in the deployed portal directory with its configured PHP runtime and application user. They do not accept provider credentials.

```sh
php artisan workspace:billing-fences --account=123
php artisan workspace:billing-fences --after-account=0
```

The inventory contains at most 100 active claims per page, with the next `--after-account` cursor when needed. It shows company, exact claim UUID, purpose, recorded producer host/PID and start time. Inspection performs no supplier or accounting action.

For monthly invoicing, a purpose such as `invoice:202611` corresponds to the existing company reference `WS-123-202611`. Inspect that original invoice and its accounting/payment journals. An uncertain supplier response remains uncertain after a process stops. Recovery must preserve its original reference and records.

## Stopped-producer recovery

Establish that the recorded producer has finished or drain it through the normal worker/service procedure on its recorded host. Do not interrupt an in-flight supplier request just to clear a claim. An idle but still alive PHP worker also cannot have its claim released; use the appropriate controlled worker/FPM lifecycle after draining work.

Then use the exact claim and company shown by inspection:

```sh
php artisan workspace:billing-fences --account=123 \
  --confirm-account=123 --release-claim=ORIGINAL_CLAIM_UUID
```

The command requires the same recorded host, a positive producer PID, an exact current claim match, and a POSIX process check that proves the original local process no longer exists. A live process, another host, an unknown process state, insufficient process visibility, missing POSIX support or changed claim causes refusal. It sends no signal and provides no force or expiry override. PID reuse conservatively prevents recovery until an operator establishes the correct service state.

Successful recovery clears only the stopped producer's company claim and audits that decision. It does not create, delete, pay, cancel or rewrite an invoice; it does not change ownership or billing periods. Resolve any original uncertain accounting outcome before retrying the normal operation. Do not manually delete the claim table or rewrite its owner: that could let a paused producer continue after another operation starts.
