Skip to content

Post the entry this line is, and hold the line against it

POST
/v1/entities/{entity_id}/lines/{line_id}/book
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" }'
line_id
required
Line Id
string
entity_id
required
Entity Id

The entity this path is relative to

string

The entity this path is relative to

Media typeapplication/json
LineBookSubmission

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
legs
required
Legs

The contra side; sums to minus the line’s amount

Array<object>
>= 1 items
LineLeg

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
required
Account

Account path (preferred) or stable account id

string
>= 1 characters <= 255 characters
commodity
required
Commodity
string
>= 1 characters <= 64 characters
amount
required
Amount

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.

string
/^-?[0-9]+(\.[0-9]+)?$/
memo
Any of:
string
<= 4096 characters
tax_code
Any of:
string
<= 255 characters
narration
required
Narration
string
>= 1 characters <= 4096 characters
reason
required
Reason

Why this is what the line is; kept in the record

string
>= 1 characters
dt
Any of:
string
origin
Any of:
string
memo
Any of:
string
<= 4096 characters
tax_code
Any of:
string
<= 255 characters
code
Code

Hledger transaction code

string
"" <= 255 characters
comment
Comment
string
"" <= 4096 characters
id
Any of:
string

Successful Response

Media typeapplication/json
LineResponse
object
entity_id
required
Entity Id
string
legal_name
required
Legal Name
string
base_currency
required
Base Currency
string
snapshot_seq
required
Snapshot Seq
integer
line
required
Line

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
line_id
required
Line Id
string
statement_id
required
Statement Id
string
statement_live
required
Statement Live
boolean
line_no
required
Line No
integer
source_key
required
Source Key
string
dt
required
Dt
string
amount_micros
required
Amount Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
commodity
required
Commodity
string
account_id
required
Account Id
string
description
required
Description
string
reference
required
Any of:
string
raw
required
Raw
string
status
required
Status

Unexplained | partly_explained | booked | linked | ignored | superseded_input

string
allocated_micros
required
Allocated Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
unexplained_micros
required
Unexplained Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
explanation
required
Any of:
LineExplanation

One thing somebody said about a line. The chain of these is the line’s history.

object
explanation_id
required
Explanation Id
string
line_id
required
Line Id
string
kind
required
Kind

Booked | linked | ignored

string
reason
required
Reason
string
entry_id
required
Any of:
string
correction_id
required
Any of:
string
supersedes_id
required
Any of:
string
allocations
required
Allocations
Array<object>
LineAllocation
object
allocation_id
required
Allocation Id
string
posting_id
required
Posting Id
string
entry_id
required
Entry Id
string
amount_micros
required
Amount Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
allocated_micros
required
Allocated Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
created_at
required
Created At
string
created_by
required
Created By
string
history
required
History
Array<object>
LineExplanation

One thing somebody said about a line. The chain of these is the line’s history.

object
explanation_id
required
Explanation Id
string
line_id
required
Line Id
string
kind
required
Kind

Booked | linked | ignored

string
reason
required
Reason
string
entry_id
required
Any of:
string
correction_id
required
Any of:
string
supersedes_id
required
Any of:
string
allocations
required
Allocations
Array<object>
LineAllocation
object
allocation_id
required
Allocation Id
string
posting_id
required
Posting Id
string
entry_id
required
Entry Id
string
amount_micros
required
Amount Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
allocated_micros
required
Allocated Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
created_at
required
Created At
string
created_by
required
Created By
string
entries
Entries

The entries this line is booked or linked to, oldest first

Array<object>
LineEntry

An entry a statement line is explained by, with the mirror that already reverses it, if any.

object
id
required
Id
string
dt
required
Dt
string
narration
required
Narration
string
status
required
Status
string
origin
required
Origin
string
version
required
Version
integer
code
required
Code
string
comment
required
Comment
string
tags
required
Tags
Array<Array<string>>
created_at
required
Created At
string
created_by
required
Created By
string
postings
required
Postings
Array<object>
Posting
object
id
required
Id
string
seq
required
Seq
integer
account_id
required
Account Id
string
account_path
required
Account Path
string
commodity
required
Commodity
string
amount_micros
required
Amount Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
memo
required
Any of:
string
tax_code
required
Any of:
string
links
required
Links
object
key
additional properties
string
reversed_by
Any of:
string
links
required
Links
object
key
additional properties
string
result
Any of:
object
key
additional properties
any

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

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Unauthorized

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Forbidden

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Not Found

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Conflict

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Precondition Failed

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Unprocessable Content

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Internal Server Error

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Service Unavailable

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}