API reference

Counterparties

The vendors and customers money moves between.

Guides: Keep track of vendors and customers

List the counterparties with their activity

GET/v1/counterparties

client.counterparties.list()

Everyone money moved to or from, by name, with how many transactions name them and how much went each way. Ones merged into another are left out: they are that other one now.

Parameters

NameTypeDescription
limitQueryinteger

Page size, 1–200.

Default 50
cursorQuerystring or null

The next_cursor of the previous page.

qQuerystring or null

Only counterparties whose name contains this, ignoring case.

roleQuerystring or null

Only those holding this role: customers, vendors, investors…

One of customer, vendor, employee, investor, lender, founder

Response

200CounterpartyPage

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/counterparties" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Add a counterparty

POST/v1/counterparties· Idempotent

client.counterparties.create()

Add a counterparty no feed has named yet.

Refused with counterparty_conflict when one by the same name exists ("Acme, Inc." and "Acme" are the same name); edit that one instead.

Request body

NewCounterparty

Response

201CounterpartyOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X POST "https://api.ledgerit.ai/v1/counterparties" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name":"…"}'

Get a counterparty

GET/v1/counterparties/{counterparty_id}

client.counterparties.get()

One counterparty, with their activity in these books. One that was merged answers too, with merged_into_id naming where it went.

Parameters

NameTypeDescription
counterparty_idPath · Requiredstring

An id that starts with party_.

Response

200CounterpartyOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/counterparties/{counterparty_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Change a counterparty

PATCH/v1/counterparties/{counterparty_id}· Idempotent

client.counterparties.update()

Rename a counterparty, mark them a customer or vendor, or record their terms. A rename keeps the slug, so the next sync still finds them under the name the bank prints.

Parameters

NameTypeDescription
counterparty_idPath · Requiredstring

An id that starts with party_.

Request body

CounterpartyChanges

Response

200CounterpartyOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X PATCH "https://api.ledgerit.ai/v1/counterparties/{counterparty_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'

Delete a counterparty

DELETE/v1/counterparties/{counterparty_id}

client.counterparties.delete()

Remove a counterparty, and any merged into them. Their transactions stay in the books and name nobody; a later sync that sees the same merchant adds them again.

Parameters

NameTypeDescription
counterparty_idPath · Requiredstring

An id that starts with party_.

Response

204No content

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X DELETE "https://api.ledgerit.ai/v1/counterparties/{counterparty_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Merge a counterparty into another

POST/v1/counterparties/{counterparty_id}/merge· Idempotent

client.counterparties.merge()

Merge a counterparty into another: one company the bank printed two ways. Answers with the one kept.

Its transactions, rules, provider ids and drafts move to the one kept, which becomes a customer or vendor if this one was and takes whatever this one knew that it did not. This one stays as an alias: posted lines keep naming it, the list leaves it out, and the next sync that prints its name files to the one kept. A merge is not undone.

Merging again into the same one answers the same. Refused with counterparty_not_mergeable into itself, into one that was itself merged, or away from one with invoices, bills, payments, credit notes, open items, payment destinations or financing — merge the other way round.

Parameters

NameTypeDescription
counterparty_idPath · Requiredstring

An id that starts with party_.

Request body

MergeCounterparty

Response

200CounterpartyOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X POST "https://api.ledgerit.ai/v1/counterparties/{counterparty_id}/merge" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"into_id":"…"}'

Get a counterparty's activity month by month

GET/v1/counterparties/{counterparty_id}/months

client.counterparties.months()

A counterparty's activity month by month: how many transactions, how much paid to them and how much received. The figures add up to the totals on the counterparty.

Parameters

NameTypeDescription
counterparty_idPath · Requiredstring

An id that starts with party_.

Response

200CounterpartyMonthsOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/counterparties/{counterparty_id}/months" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Objects

The objects these operations take and return.

CounterpartyPage

NameTypeDescription
dataRequiredarray of CounterpartyOut
has_moreRequiredboolean
next_cursorRequiredstring or null

NewCounterparty

NameTypeDescription
countrystring or null
default_account_idstring or null

An id that starts with gla_.

emailstring or null
is_customerbooleanDefault false
is_vendorbooleanDefault false
nameRequiredstring
notesstring or null
payment_terms_daysinteger or null
regionstring or null
tax_classificationstring or null
w9_received_onstring (date) or null
websitestring or null

Their website; their logo is looked for there.

CounterpartyOut

NameTypeDescription
billingRequiredBillingCadenceOut or null

How often they bill, when their bills (or, with none, their charges) keep a monthly, quarterly or yearly rhythm; null when they keep none.

categoriesRequiredarray of CounterpartyCategoryOut

Every GL account their transactions are filed to, the most used first. A split transaction counts under none; one still waiting for review is not counted.

countryRequiredstring or null
created_atRequiredstring (date-time)
default_account_idRequiredstring or null

An id that starts with gla_.

emailRequiredstring or null
first_transaction_onRequiredstring (date) or null

The date of the earliest transaction naming them; null with none.

found_logo_urlRequiredstring or null

The logo found on their website, whether or not an upload is shown instead: what they show once an uploaded logo is removed. Null for none.

idRequiredstring

An id that starts with party_.

is_customerRequiredboolean
is_vendorRequiredboolean
last_transaction_onRequiredstring (date) or null
logo_sourceRequiredstring or null

Where logo_url comes from: uploaded, a logo a person uploaded for them, which wins; found, the icon of their website, found by LedgerIt; null for none.

One of uploaded, found
logo_urlRequiredstring or null

Their logo, square PNG; null for none.

merged_atRequiredstring (date-time) or null

When it was merged, or null.

merged_into_idRequiredstring or null

An id that starts with party_.

nameRequiredstring
notesRequiredstring or null
payment_terms_daysRequiredinteger or null
regionRequiredstring or null
rolesRequiredarray of string

What they are to these books: customer, vendor, employee, investor, lender or founder. is_customer and is_vendor say the first two.

One of customer, vendor, employee, investor, lender, founder
slugRequiredstring
tax_classificationRequiredstring or null
total_inRequiredstring
total_outRequiredstring
transaction_countRequiredinteger
updated_atRequiredstring (date-time)
w9_received_onRequiredstring (date) or null
websiteRequiredstring or null

Their website, as a full URL with its scheme.

CounterpartyChanges

Only the fields sent change. Everything but name and the two roles is cleared by sending null; those three are typed without null and default to None only so that leaving one out means "unchanged".

NameTypeDescription
countrystring or null
default_account_idstring or null

An id that starts with gla_.

emailstring or null
is_customerboolean
is_vendorboolean
namestring
notesstring or null
payment_terms_daysinteger or null
regionstring or null
tax_classificationstring or null
w9_received_onstring (date) or null
websitestring or null

Their website. Changing it looks for their logo there again.

MergeCounterparty

NameTypeDescription
into_idRequiredstring

The counterparty to merge this one into. It is the one kept.

CounterpartyMonthsOut

NameTypeDescription
dataRequiredarray of CounterpartyMonthOut

Every month from their first transaction to their last, oldest first; a month with nothing in it is there with zeros. Counts what transaction_count, total_out and total_in on the counterparty count.

BillingCadenceOut

How often a vendor bills these books, learned from what it billed (decision 0152): its last bills fell exactly this many months apart.

NameTypeDescription
every_monthsRequiredinteger

Months between its bills: 1, 3, 12 (monthly, quarterly, yearly).

next_expected_onRequiredstring (date)

When its next bill is due. In the past when it is late; the books' daily check asks about a late one so the month's cost can be accrued.

usual_amountRequiredstring

What a bill usually comes to, in the books' currency: the median of the bills that set its rhythm.

usual_dayRequiredinteger

The day of the month its bill usually lands.

CounterpartyCategoryOut

A GL account this counterparty's transactions are filed to, and how many.

NameTypeDescription
account_idRequiredstring

The GL account they are filed to.

transaction_countRequiredinteger

Transactions naming them filed to it, counted as transaction_count is.

CounterpartyMonthOut

One calendar month of a counterparty's activity.

NameTypeDescription
monthRequiredstring (date)

The first day of the month.

total_inRequiredstring

Received from them that month, in the books' currency, as a positive figure.

total_outRequiredstring

Paid to them that month, in the books' currency, as a positive figure.

transaction_countRequiredinteger

Transactions naming them that month.