Skip to content

Add an account to the chart

POST
/v1/entities/{entity_id}/accounts
curl --request POST \
--url https://example.com/v1/entities/example/accounts \
--header 'Content-Type: application/json' \
--data '{ "path": "example", "type": "example", "commodities": [ "example" ], "is_cash": false, "code": "example", "tax_code": "example", "id": "example", "reason": "example" }'

Write one new account and return it as it now stands, so the caller can book to it without re-reading.

A path already in the chart is a 409, not a second account with the same name. Two accounts that print identically in every report is not a useful state, and the caller who hit it wanted the account it already has.

Writes an account.created audit action recording who extended the chart and why (issue 0006).

entity_id
required
Entity Id

The entity this path is relative to

string

The entity this path is relative to

Media typeapplication/json
AccountCreationSubmission

Add one account to the chart.

The chart is authored, not derived: an account written here is permanent, every future report carries it, and the only way out is to archive it. So this asks for everything an account needs and infers nothing.

type cannot be read off the path. assets:... usually is an asset, but a chart may put a contra-asset under assets or a recovery under expenses, and a guess that lands an account on the wrong side of the balance sheet is wrong in every statement afterwards.

is_cash defaults to false. A cash account is one a bank statement is reconciled against, which is a fact about the real world rather than the books, and should not be acquired by leaving a field out.

reason is optional. The account.created audit action keeps whatever is given (issue 0006). Adding an account is structure rather than an assertion about what happened, so “an account was added” is the whole content of the act, and is what the action records when no reason is given. Retiring an account is a decision about the books, so POST /accounts/{id}/archive does require a reason.

object
path
required
Path

Colon-separated, e.g. ‘expenses:professional-services:audit’

string
>= 1 characters <= 255 characters
type
required
Type

Asset | liability | equity | income | expense

string
commodities
required
Commodities

The currencies this account may hold; every account declares at least one

Array<string>
>= 1 items
is_cash
Is Cash

True only for an account a bank statement is reconciled against

boolean
code
Any of:
string
<= 255 characters
tax_code
Any of:
string
<= 255 characters
id
Any of:
string
reason
Any of:
string
>= 1 characters

Successful Response

Media typeapplication/json
ChartChangeResponse

The reply to an account command: the account as it now stands, and its audit action.

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
account
required
Account
object
id
required
Id
string
path
required
Path
string
type
required
Type
string
code
required
Any of:
string
tax_code
required
Any of:
string
is_cash
required
Is Cash
boolean
archived
required
Archived
boolean
version
required
Version
integer
commodities
required
Commodities
Array<string>
links
required
Links
object
key
additional properties
string
version
required
Version
integer
audit_seq
required
Audit Seq

The account.created / account.archived action’s event sequence

integer
links
required
Links
object
key
additional properties
string

Example generated

{
"entity_id": "example",
"legal_name": "example",
"base_currency": "example",
"snapshot_seq": 1,
"account": {
"id": "example",
"path": "example",
"type": "example",
"code": "example",
"tax_code": "example",
"is_cash": true,
"archived": true,
"version": 1,
"commodities": [
"example"
],
"links": {
"additionalProperty": "example"
}
},
"version": 1,
"audit_seq": 1,
"links": {
"additionalProperty": "example"
}
}

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": {}
}
}