API v1
v1
View as Markdown

Change a loan

PUT /api/v1/vaults/{vault}/possessions/{possession}/loans/{loan}

Change one loan of a possession, including marking it as returned.

What you leave out keeps its value, and what you send as null is cleared. A loan that is not returned loses its return day and the condition it came back in, and its provenance events follow what it now says. The change is written to the account log.

The same refusals apply as when recording a loan.

Parameters

Sent as JSON. Anything not listed here is ignored.

vault string Required

The vault the possession is kept in, named either by the readable name it reports as slug or by its id. A vault of another account answers 404.

possession uuid Required

The id of the possession. A possession of another vault or of another account answers 404.

loan uuid Required

The id of the loan. A loan of another possession answers 404.

direction string Optional

lent or borrowed.

status string Optional

planned, active or returned.

contact_id uuid Optional

The id of a contact of the vault.

started_on date Optional

The day the loan started, as YYYY-MM-DD.

due_on date Optional

The day it is due back, as YYYY-MM-DD. Not before started_on.

returned_on date Optional

The day it came back, as YYYY-MM-DD. Required for a returned loan, not before started_on, and ignored otherwise.

condition_out_id uuid Optional

The id of a possession condition of the account, the one it left in.

condition_back_id uuid Optional

The id of a possession condition of the account, the one it came back in. Kept only for a returned loan.

deposit_amount number Optional

A deposit left against the loan, from 0 to 9,999,999,999.99.

deposit_currency string Optional

The currency of the deposit, as a lowercase ISO code. Required with a deposit.

purpose string Optional

Why it was lent or borrowed, up to 5,000 characters. Markup is stripped.

is_in_provenance boolean Optional

Whether the loan records a change of custody in the provenance when it starts and another when it ends. False when left out.

Returns

The loan object, as it now stands. A loan of another possession or of another account answers 404.

data object

The possession loan.

data.type string

Always possession_loan. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.

data.id string

The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.

data.attributes object

Everything the record holds.

data.attributes.direction string

lent when the possession left your hands, borrowed when it came into them.

data.attributes.status string

planned, active or returned. A possession has at most one active loan.

data.attributes.is_overdue boolean

Whether the loan is active and its due day has passed, in the time zone of the person asking. It is worked out, never stored.

data.attributes.contact_id uuid

The id of the contact who has it or lent it, or null once that contact is deleted.

data.attributes.contact_name string

The name of that contact, or null once that contact is deleted.

data.attributes.started_on date

The day the loan started, as YYYY-MM-DD.

data.attributes.due_on date

The day it is due back, as YYYY-MM-DD, or null when no day was agreed.

data.attributes.returned_on date

The day it came back, as YYYY-MM-DD, or null unless the loan is returned.

data.attributes.condition_out_id uuid

The id of the possession condition it left in, or null.

data.attributes.condition_back_id uuid

The id of the possession condition it came back in, or null.

data.attributes.deposit_amount string

A deposit left against the loan, as a decimal with two places, or null.

data.attributes.deposit_currency string

The currency of the deposit, as a lowercase ISO code, or null without a deposit.

data.attributes.purpose string

Why it was lent or borrowed, or null.

data.attributes.is_in_provenance boolean

Whether the loan records a change of custody in the provenance when it starts and another when it ends.

data.attributes.created_at timestamp

When the loan was recorded, as a count of seconds since 1970.

data.links object

Where to find this record.

data.links.self string

The absolute address this record is read from.

data.links.web string

The Loans section of the possession in the application, which opens for somebody signed in rather than for a key. It is the link to give a person.

Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in X-RateLimit-Remaining.

PUT
curl https://my.monicahq.com/api/v1/vaults/dunder-mifflin/possessions/8a3d1f62-7b4e-4c95-a0e1-2f6c9b5d3e71/loans/4c7e2a91-3f58-4b06-9d1e-6a2f8c3b5e04 \
-X PUT \
-H "Authorization: Bearer $MONICA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"status": "returned",
"returned_on": "2024-06-15",
"condition_back_id": "2e6b9d14-5c87-4a30-b9f2-1d4e8a6c3f57"
}'
const response = await fetch('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/possessions/8a3d1f62-7b4e-4c95-a0e1-2f6c9b5d3e71/loans/4c7e2a91-3f58-4b06-9d1e-6a2f8c3b5e04', {
method: 'PUT',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
status: 'returned',
returned_on: '2024-06-15',
condition_back_id: '2e6b9d14-5c87-4a30-b9f2-1d4e8a6c3f57',
}),
})
const data = await response.json()
$response = Http::withToken($token)->put('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/possessions/8a3d1f62-7b4e-4c95-a0e1-2f6c9b5d3e71/loans/4c7e2a91-3f58-4b06-9d1e-6a2f8c3b5e04', [
'status' => 'returned',
'returned_on' => '2024-06-15',
'condition_back_id' => '2e6b9d14-5c87-4a30-b9f2-1d4e8a6c3f57',
]);
Response 200
{
"data": {
"type": "possession_loan",
"id": "4c7e2a91-3f58-4b06-9d1e-6a2f8c3b5e04",
"attributes": {
"direction": "lent",
"status": "returned",
"is_overdue": false,
"contact_id": "d4a8c2f1-6e39-4b75-a0d2-8f1e3c7b5a69",
"contact_name": "Pam Beesly",
"started_on": "2024-06-12",
"due_on": "2024-06-15",
"returned_on": "2024-06-15",
"condition_out_id": "2e6b9d14-5c87-4a30-b9f2-1d4e8a6c3f57",
"condition_back_id": "2e6b9d14-5c87-4a30-b9f2-1d4e8a6c3f57",
"deposit_amount": null,
"deposit_currency": null,
"purpose": "Worn at the wedding at Niagara Falls.",
"is_in_provenance": false,
"created_at": 1773446400
},
"links": {
"self": "https://my.monicahq.com/api/v1/vaults/dunder-mifflin/possessions/8a3d1f62-7b4e-4c95-a0e1-2f6c9b5d3e71/loans/4c7e2a91-3f58-4b06-9d1e-6a2f8c3b5e04",
"web": "https://my.monicahq.com/vaults/dunder-mifflin/possessions/8a3d1f62-7b4e-4c95-a0e1-2f6c9b5d3e71/loans"
}
}
}

Keys act as you, with exactly the access you have. Make one per integration so you can revoke it alone.