Runbooks

Create a runbook

Writes a new runbook for the company. The script is the only thing you must supply — leave out the title or description and MagicDoor writes them by reading the script. Requires the maintenance_runbooks:write permission.

POST
https://services.magicdoor.com/maintenance/company-portal/run-books

Authorization

Authorizationstringrequired
Bearer token — Send your API token in the Authorization header as Bearer <token>. Requests without a valid token are rejected with 401 Unauthorized.

Body

application/json

scriptstringrequired

The instructions MagicDoor should follow, in plain English. At least 50 characters.

titlestring

The runbook's name. At most 150 characters. Leave it out to have MagicDoor write one from the script.

descriptionstring

What the runbook is for. At most 250 characters. Leave it out to have MagicDoor write one from the script.

defaultVendorIdstring

The vendor the runbook should send work to when nothing more specific applies. It must be one of the company's vendors.

defaultPropertyManagerIdstring

The property manager the runbook should hand requests to when nothing more specific applies. They must belong to the company.

Response

200 · The runbook that was created.

publicRunBookbooleanrequired

true when MagicDoor supplies this runbook to every company. A shared runbook can be switched on and configured for your company, but its title, description and script cannot be edited or deleted.

idstringrequired

The runbook.

titlestringrequired

The runbook's name. MagicDoor writes one from the script when you do not supply it.

descriptionstringrequired

What the runbook is for. MagicDoor writes one from the script when you do not supply it.

createdstring · date-timerequired

When the runbook was created, in the company's timezone and without an offset.

updatedstring · date-time

When the runbook was last changed, in the company's timezone and without an offset.

defaultVendorIdstring

The vendor this runbook sends work to when nothing more specific applies. Absent when none is set.

defaultPropertyManagerIdstring

The property manager this runbook hands requests to when nothing more specific applies. Absent when none is set.

enabledbooleanrequired

Whether the runbook is allowed to pick up this company's maintenance requests. A runbook your company has never configured reads as enabled.

usageCountintegerrequired

How many times this runbook has been used for this company.

lastUsedstring · date-time

When it was last used, in the company's timezone and without an offset. Absent when it has never run.

vendorIdstringdeprecated

A copy of defaultVendorId. Read defaultVendorId instead.

scriptstringrequired

The instructions MagicDoor follows when the runbook handles a request, in plain English.

lastUseMaintenanceRequestIdstring

The last maintenance request this runbook handled for the company. Absent when it has never run.

vendorOverwritesobject[]required

Per-portfolio or per-property vendor overrides. An empty array when there are none.

propertyManagerOverwritesobject[]required

Per-portfolio or per-property property manager overrides. An empty array when there are none.

actionExitCountsobjectrequired

How many times the runbook has finished each way, as a map. The keys are askQuestion, closeRequest, createWorkOrder, handOverToHuman and reselectRunBook; only the ways it has actually finished appear. An empty object when it has never run.

lastUseMaintenanceRequestobject

The last maintenance request this runbook handled, in the short row shape used by the maintenance request list. Absent when it has never run, or when that request no longer exists.

400 · The script is shorter than 50 characters, or the title or description is longer than allowed.

401 · The request carried no valid access token.

403 · The token is not a property manager token, or it lacks the `maintenance_runbooks:write` permission.

404 · `defaultVendorId` or `defaultPropertyManagerId` names someone who does not exist, or who belongs to another company.

When a new runbook starts switched off

If MagicDoor has to write the title or description for you and cannot make sense of the script, the runbook is created disabled. Check enabled on the response, and call Enable a runbook once the script reads properly.