API reference

Approvals

A person's go-ahead for a payment, bound to its amount and destination, expiring, and stale the moment either changes.

Guides: Record payments and apply them

List approvals

GET/v1/approvals

client.approvals.list()

Approvals asked for in these books, the newest first: what waits for a decision, and what was decided.

Parameters

NameTypeDescription
statusQuerystring or null

Only pending, approved, rejected or cancelled ones.

subject_idQuerystring or null

An id. Which resource it names is given by the field beside it.

limitQueryinteger

Page size, 1–200.

Default 50
cursorQuerystring or null

The next_cursor of the previous page.

Response

200ApprovalPage

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/approvals" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Get an approval

GET/v1/approvals/{approval_id}

client.approvals.get()

One approval: what it approves, who decided, and whether it stands.

Parameters

NameTypeDescription
approval_idPath · Requiredstring

An id that starts with appr_.

Response

200ApprovalOut

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/approvals/{approval_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Approve or reject

POST/v1/approvals/{approval_id}/decide· Idempotent

client.approvals.decide()

Approve or reject, once. Needs money.approve, or an approval limit in the approval's currency that covers its amount (the Approver add-on); anyone else is refused with role. An approval past its expiry is refused with conflict: ask for another. So is a change the assistant proposed, which its person decides in the conversation.

Parameters

NameTypeDescription
approval_idPath · Requiredstring

An id that starts with appr_.

Request body

ApprovalDecide

Response

200ApprovalOut

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/approvals/{approval_id}/decide" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"decision":"…"}'

Objects

The objects these operations take and return.

ApprovalPage

NameTypeDescription
dataRequiredarray of ApprovalOut
has_moreRequiredboolean
next_cursorRequiredstring or null

ApprovalOut

NameTypeDescription
actionRequiredstring

What it lets happen: payment.send or agent.change.

amountRequiredstring or null
can_decideRequiredboolean

Whether the caller may decide it here: pending, and theirs to approve (money.approve, or an approval limit in its currency that covers its amount).

created_atRequiredstring (date-time)
currencyRequiredstring or null
decided_atRequiredstring (date-time) or null
decisionsRequiredarray of DecisionOut
expires_atRequiredstring (date-time) or null
idRequiredstring

An id that starts with appr_.

requested_byRequiredstring or null

An id that starts with usr_.

standsRequiredboolean

Approved, unexpired, and the subject is still what it was when asked: false once a payment's amount or destination changes.

statusRequiredstring

pending, approved, rejected or cancelled.

subject_idRequiredstring

An id. Which resource it names is given by the field beside it.

subject_typeRequiredstring

What is approved: payment, or agent_action (a change the assistant proposed).

ApprovalDecide

NameTypeDescription
commentstring or null
decisionRequiredstring

approve or reject.

DecisionOut

NameTypeDescription
actor_idRequiredstring or null

An id that starts with usr_.

commentRequiredstring or null
decisionRequiredstring
recorded_atRequiredstring (date-time)