Monica
Log in
API v1
v1
View as Markdown

Change the template of many records

POST /api/v1/vaults/{vault}/record-kinds/{recordKind}/template-changes

Move every non-archived record of one template in a vault onto another template, or onto the published version of the same one.

The records move in the background. The answer is the change, running, and GET /vaults/{vault}/template-changes/{templateChange} says how far it is.

Each record moves as a single contact does: its state is kept in its version history first, values with no matching field are set aside and never deleted, and reminders on them pause. A record that changed, was archived or was deleted after you confirmed is skipped. The change writes one entry in the account log.

Parameters

Sent as JSON. Anything not listed here is ignored.

vault uuid Required

The id of the vault.

recordKind string Required

contacts for people, or the id of an entity type, as GET /entity-types gives it.

from uuid Required

The id of the template the records leave, as the statistics give it.

version integer Optional

Take only the records on this version of the source template. Leave it out to take every version.

to uuid Required

The id of the template the records move onto, at the version it publishes now. Send the same template as from to update records on older versions to the published one.

Returns

The change, running. A vault, an entity type or a template of another account answers 404. A destination that describes another kind of record, is turned off or has no published version, and a batch with nothing left to move, answer 422 with the reason on to.

data object

The change.

data.type string

Always template_change.

data.id uuid

The id of the change.

data.attributes object

What the change is and how far it is.

data.attributes.status string

running while some records are still waiting, then finished.

data.attributes.record_kind string

contacts, or the id of the entity type.

data.attributes.from uuid

The id of the template the records leave.

data.attributes.to uuid

The id of the template the records move onto.

data.attributes.to_version integer

The number of the version they move onto.

data.attributes.counts object

How many records the change took and what became of them.

data.attributes.counts.total integer

How many records the change took.

data.attributes.counts.done integer

How many of them have been dealt with so far.

data.attributes.counts.moved integer

How many moved. Written once the change has finished, 0 before.

data.attributes.counts.skipped integer

How many were left as they were, because they changed, were archived or were deleted after the preview. Written once the change has finished.

data.attributes.counts.failed integer

How many could not be moved. Nothing was changed on them. Written once the change has finished.

data.attributes.not_moved array

The first hundred records that were skipped or failed.

data.attributes.created_at timestamp

When the change was confirmed.

data.attributes.ended_at timestamp

When the last record was dealt with. Null while the change runs.

data.links object

Where the change lives.

data.links.self string

The URL of the change.

Rate limit

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

POST
curl https://my.monicahq.com/api/v1/vaults/9f1c2b7a-4e3d-4a6b-8c5d-2e7f1a9b3c4d/record-kinds/5b8e2f1a-7c3d-4e9a-b6f0-1d2c3e4f5a6b/template-changes \
-X POST \
-H "Authorization: Bearer $MONICA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"from": "3e7a1c9b-2d4f-4a6e-8b0c-5f9d1e3a7c2b",
"to": "8b3c2d1e-4f5a-4b6c-9d7e-0f1a2b3c4d5e"
}'
const response = await fetch('https://my.monicahq.com/api/v1/vaults/9f1c2b7a-4e3d-4a6b-8c5d-2e7f1a9b3c4d/record-kinds/5b8e2f1a-7c3d-4e9a-b6f0-1d2c3e4f5a6b/template-changes', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
from: '3e7a1c9b-2d4f-4a6e-8b0c-5f9d1e3a7c2b',
to: '8b3c2d1e-4f5a-4b6c-9d7e-0f1a2b3c4d5e',
}),
})
const data = await response.json()
$response = Http::withToken($token)->post('https://my.monicahq.com/api/v1/vaults/9f1c2b7a-4e3d-4a6b-8c5d-2e7f1a9b3c4d/record-kinds/5b8e2f1a-7c3d-4e9a-b6f0-1d2c3e4f5a6b/template-changes', [
'from' => '3e7a1c9b-2d4f-4a6e-8b0c-5f9d1e3a7c2b',
'to' => '8b3c2d1e-4f5a-4b6c-9d7e-0f1a2b3c4d5e',
]);
Response 202
{
"data": {
"type": "template_change",
"id": "6a1d3f8c-9b2e-4c7a-a5d0-3e8f1b4c9d27",
"attributes": {
"status": "running",
"record_kind": "5b8e2f1a-7c3d-4e9a-b6f0-1d2c3e4f5a6b",
"from": "3e7a1c9b-2d4f-4a6e-8b0c-5f9d1e3a7c2b",
"to": "8b3c2d1e-4f5a-4b6c-9d7e-0f1a2b3c4d5e",
"to_version": 3,
"counts": {
"total": 4,
"done": 0,
"moved": 0,
"skipped": 0,
"failed": 0
},
"not_moved": [],
"created_at": 1764079200,
"ended_at": null
},
"links": {
"self": "https://my.monicahq.com/api/v1/vaults/9f1c2b7a-4e3d-4a6b-8c5d-2e7f1a9b3c4d/template-changes/6a1d3f8c-9b2e-4c7a-a5d0-3e8f1b4c9d27"
}
}
}

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