Add an account to the chart
const url = 'https://example.com/v1/entities/example/accounts';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"path":"example","type":"example","commodities":["example"],"is_cash":false,"code":"example","tax_code":"example","id":"example","reason":"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/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).
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”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
Colon-separated, e.g. ‘expenses:professional-services:audit’
Asset | liability | equity | income | expense
The currencies this account may hold; every account declares at least one
True only for an account a bank statement is reconciled against
Responses
Section titled “Responses”Successful Response
The reply to an account command: the account as it now stands, and its audit action.
object
object
object
The account.created / account.archived action’s event sequence
object
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
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": {} }}