Motivation MoneyMotivation Money
API 参考Payroll Runs

Create a draft payroll run

Creates a new payroll run in DRAFT status. The run includes all active employees (or a specific subset via employee_ids). Amounts are calculated from employee salaries.

Requires payroll:draft scope. Requires Idempotency-Key header.

Side effects: Creates audit log entry PAYROLL_CREATED.

POST
/payroll-runs
AuthorizationBearer <token>

API key: Authorization: Bearer mpk_live_<key>

In: header

Header Parameters

Idempotency-Key*string

UUID v4. Required on all write operations. Prevents duplicate execution on retry.

Formatuuid

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://motivation-money.vercel.app/api/v1/payroll-runs" \  -H "Idempotency-Key: 7f3c4d2a-8b1e-4f6a-9c2d-1a5b8e3f7d4c" \  -H "Content-Type: application/json" \  -d '{    "label": "April 2026 Payroll",    "period_start": "2026-04-01",    "period_end": "2026-04-30",    "is_adhoc": false,    "employee_ids": null,    "note": "Regular monthly payroll"  }'
{
  "data": null,
  "api_version": "2026-03-01",
  "request_id": "req_f1a2b3c4"
}
{
  "error": {
    "code": "INVALID_REQUEST_BODY",
    "message": "Request body failed validation.",
    "details": {
      "validation_errors": [
        {
          "field": "period_start",
          "message": "Required field missing"
        },
        {
          "field": "period_end",
          "message": "Must be after period_start"
        }
      ]
    },
    "recovery_hint": "Check the details.validation_errors array for field-level issues."
  }
}
{
  "error": {
    "code": "PAYROLL_RUN_OVERLAP",
    "message": "An active payroll run already exists for this period.",
    "details": {
      "existing_run_id": "run_existing123",
      "existing_run_status": "PAYING_OUT"
    },
    "recovery_hint": "Wait for the current run to complete or cancel it first."
  }
}