Post the entry this line is, and hold the line against it
const url = 'https://example.com/v1/entities/example/lines/example/book';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"legs":[{"account":"example","commodity":"example","amount":"-12.00","memo":"example","tax_code":"example"}],"narration":"example","reason":"example","dt":"example","origin":"example","memo":"example","tax_code":"example","code":"","comment":"","id":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/entities/example/lines/example/book \ --header 'Content-Type: application/json' \ --data '{ "legs": [ { "account": "example", "commodity": "example", "amount": "-12.00", "memo": "example", "tax_code": "example" } ], "narration": "example", "reason": "example", "dt": "example", "origin": "example", "memo": "example", "tax_code": "example", "code": "", "comment": "", "id": "example" }'Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The entity this path is relative to
The entity this path is relative to
Request Bodyrequired
Section titled “Request Bodyrequired”Post the entry this line is, and hold the line against the cash posting it creates, in one call.
The entry goes through the ordinary posting path with all its checks, and is posted, not drafted: since
issue 0003 there is no two-step approval, and a booked line is in the books immediately. To change it
later, use reexplain, which reverses or corrects it.
object
The contra side; sums to minus the line’s amount
One contra leg of a booking: what the line was for.
The cash leg is not supplied and cannot be: it is the statement line itself, on the line’s own account for the line’s own amount. These legs are the other side, and must sum to the negative of the line.
object
Account path (preferred) or stable account id
Signed decimal amount in whole commodity units, as a string; never a JSON number. Converted by the commodity’s declared precision, so more decimal places than the currency has is refused rather than rounded.
Why this is what the line is; kept in the record
Hledger transaction code
Responses
Section titled “Responses”Successful Response
object
What has become of one statement line.
status is derived from the live explanation, never stored, so there is exactly one answer.
unexplained_micros is the remainder, reported in every state including a fully explained line, where it
is "0". history is every explanation ever written for this line, oldest first.
object
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
Unexplained | partly_explained | booked | linked | ignored | superseded_input
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
One thing somebody said about a line. The chain of these is the line’s history.
object
Booked | linked | ignored
object
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
One thing somebody said about a line. The chain of these is the line’s history.
object
Booked | linked | ignored
object
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
The entries this line is booked or linked to, oldest first
An entry a statement line is explained by, with the mirror that already reverses it, if any.
object
object
Signed integer micro-units (millionths) as a base-10 string; never a JSON number.
object
object
Example
{ "line": { "amount_micros": "-12000000", "allocated_micros": "-12000000", "unexplained_micros": "-12000000", "explanation": { "allocations": [ { "amount_micros": "-12000000" } ], "allocated_micros": "-12000000" }, "history": [ { "allocations": [ { "amount_micros": "-12000000" } ], "allocated_micros": "-12000000" } ], "entries": [ { "postings": [ { "amount_micros": "-12000000" } ] } ] }}Bad Request
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Unauthorized
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Forbidden
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Not Found
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Conflict
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Precondition Failed
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Unprocessable Content
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Internal Server Error
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}Service Unavailable
object
Example generated
{ "error": { "code": "example", "message": "example", "retryable": true, "details": [ {} ], "request_id": "example", "next_action": {} }}