π POST /distribute
Distributes a specified amount from a parent account to its child accounts according to their allocation rules.
π Summary
- Method:
POST
- URL:
/distribute
- Auth: Required
- Tag:
accounts
π Headers
Authorization: Bearer <your-token>
Content-Type: application/json
π€ Request Parameters
Name | Type | Required | Description |
---|---|---|---|
uuid |
string | β | UUID of the parent account |
amount |
float | β | Amount to distribute (must be > 0) |
transaction |
string | β | Optional transaction reference (autogenerated if NULL) |
by |
string | β | Who performed the distribution (default = βSystemβ) |
π₯ Example Request
{
"uuid": "parent-acc-2023-001",
"amount": 5000,
"transaction": "dist-INV004",
"by": "System"
}
β Success Response
{
"success": true,
"status": 200,
"message": "Distributed 5000 from Needs",
"uuid": "parent-acc-2023-001",
"start_time": "2025-07-10T10:01:15.120Z",
"end_time": "2025-07-10T10:01:15.180Z",
"execution_time": 0.06
}
β Failure Response Examples
Status | Reason |
---|---|
403 |
Unauthorized to access the account |
404 |
Account not found |
500 |
Invalid amount, zero, negative, or missing account |
π§ Notes
- Automatically uses
account$distribute_to_children()
internally. - Locks the account tree for safe concurrent execution.
- Will fail if amount is missing, zero, or negative.
- If transaction reference is missing, one is auto-generated.
π Sponsors
Support my work through GitHub Sponsors!