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

NameInTypeRequiredDescription
categorypathstringrequired

Request body

application/json: object

FieldTypeRequiredDescription
amount_centsintegerrequiredThe amount in cents. Zero ends the budget from that month.
effective_fromstringrequiredThe first month the amount applies

Responses

StatusMeaningBody
200The budget row that was setobject
400Request rejectedError
404Request rejectedError
429Too 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))