PUT /v1/budgets/{category}
Set a category's budget from a month on. Setting the same month again replaces that month's amount. Months before this one cannot be changed.
Auth. Send the token in the X-Ledger-Token header.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
category | path | string | required |
Request body
application/json: object
| Field | Type | Required | Description |
|---|---|---|---|
amount_cents | integer | required | The amount in cents. Zero ends the budget from that month. |
effective_from | string | required | The first month the amount applies |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | The budget row that was set | object |
400 | Request rejected | Error |
404 | Request rejected | Error |
429 | Too many requests from this client address. Wait the number of seconds in Retry-After, then try again. | Error |
Example response
{
"category": "string",
"amount_cents": 0,
"effective_from": "string"
}
Code samples
Set KEY to your own token first.
curl
curl \
-X PUT \
-H X-Ledger-Token:$KEY \
-H "Content-Type: application/json" \
-d '{"amount_cents": 0, "effective_from": "string"}' \
"https://api.sasek.org/ledger/v1/budgets/{category}"
JavaScript
const res = await fetch("https://api.sasek.org/ledger/v1/budgets/{category}", {
method: "PUT",
headers: { "X-Ledger-Token": KEY, "Content-Type": "application/json" },
body: JSON.stringify({
"amount_cents": 0,
"effective_from": "string"
}),
});
const data = await res.json();
Python
import json
import os
import urllib.request
payload = {'amount_cents': 0, 'effective_from': 'string'}
request = urllib.request.Request(
"https://api.sasek.org/ledger/v1/budgets/{category}",
method="PUT",
headers={
"X-Ledger-Token": os.environ["KEY"],
"Content-Type": "application/json",
},
data=json.dumps(payload).encode(),
)
with urllib.request.urlopen(request) as response:
print(json.load(response))