Skip to content

Time-management code

Time-management codes classify the time, expense, operational and PTO entries your staff log. There are four code types: TimeCode, ExpenseCode, OperationalCode and PtoCode.

Each type has its own endpoints:

TypeCreate or updatePaged lookupRead by ID
TimeCodePOST /api/v1/time-codesPOST /api/v1/time-codes/batchGET /api/v1/time-codes/{id}
ExpenseCodePOST /api/v1/expense-codesPOST /api/v1/expense-codes/batchGET /api/v1/expense-codes/{id}
OperationalCodePOST /api/v1/operational-codesPOST /api/v1/operational-codes/batchGET /api/v1/operational-codes/{id}
PtoCodePOST /api/v1/pto-codesPOST /api/v1/pto-codes/batchGET /api/v1/pto-codes/{id}

The same records can also be managed through the shared code endpoints with type set on each record: POST /api/v1/codes and POST /api/v1/codes/batch/{type}.

OperationalCode and PtoCode can also carry custom fields your firm defines. GET /api/v1/codes/schema/{type} lists every field of a type for your tenant, custom fields included.

Code record envelope

A create or update request wraps each code's attributes in a record. On the per-type endpoints the path decides the type, so records carry no type; on the shared endpoints each record names its type.

NameTypeFormatNullableDescriptionExample
typestringconstantNoShared endpoints only. The code type, for example ExpenseCode."ExpenseCode"
systemRefobject{system, reference}YesExternal identity used to match an existing code during upsert.{"system":"PM","reference":"TRAVEL"}
attributesobjectone of the tables belowNoCode fields. Attributes left out of an update keep their values.—

A record updates the code its systemRef names: the same system and reference, the code with that Aiwyn ID when system is aiwyn, or else the code whose pmsRef is the reference. Without a systemRef, it updates the code whose pmsRef is attributes.pmsRef. When nothing matches, a new code is created. Time codes kept as task types, and some older expense and operational codes, appear in the lookup but aren't matched by an upsert, so sending one creates a new code.

A paged lookup returns type, pageSize, page, returned and records. Each record, and the response of a read by ID, has this shape. A read by ID finds the codes the paged lookup lists, under the same aiwynId; for time codes both return active codes only. An older code and a newer one can share an aiwynId: the lookup then lists both, and a read by ID returns the older.

NameTypeFormatNullableDescriptionExample
typestring—NoThe code type."ExpenseCode"
aiwynIdintegerint64YesAiwyn ID of the code; the {id} of the read-by-ID endpoint.4021
systemRefsarray{system, reference}NoEvery reference the code is known by, including its PM reference.[{"system":"PM","reference":"TRAVEL"}]
attributesobjectstring valuesNoThe code's fields. Values are strings, for example "true" for a boolean. ExpenseCode, OperationalCode and PtoCode also return record metadata such as createdAt, updatedAt and version.{"code":"TRAVEL","active":"true"}

TimeCode

A time code is a task type that time entries are logged against.

NameTypeFormatRequiredDefaultDescriptionExample
pmsRefstring—NosystemRef.referencePractice-management-system reference. A new code needs pmsRef or a systemRef."ADMIN"
codestring—Yes—Code value that time entries reference."ADMIN"
displaystring—NocodeName shown in Aiwyn."Administration"
descriptionstring—No—Longer description."Internal administration"
billableboolean—NotrueWhether time logged against the code is billable.false
taxableboolean—NofalseWhether time logged against the code is taxable.false
reimbursableboolean—NofalseWhether costs logged against the code are reimbursable.false
activeboolean—Notruefalse deactivates the code.true
rateTypeIdintegerAiwyn IDNo—Rate type used to price time on this code.12
customHourlyRatenumberdecimalNo—Hourly rate that overrides the rate type.150.00
taskTypeCategoryIdintegerAiwyn IDNo—Task type category.3
serviceLineIdintegerAiwyn IDNo—Service line.7

The paged lookup and read by ID return reimbursable as false. For time codes created through the API they don't return rateTypeId, customHourlyRate, taskTypeCategoryId or serviceLineId; the values sent are kept. A deactivated time code is no longer returned by either.

ExpenseCode

An expense code classifies expense entries. An expense entry references one by its code or by expenseCodeId.

NameTypeFormatRequiredDefaultDescriptionExample
pmsRefstring—Nosee belowPractice-management-system reference."TRAVEL"
codestring—Yes—Code value that expense entries reference."TRAVEL"
displaystring—Yes—Name shown in Aiwyn."Travel"
descriptionstring—No—Longer description."Mileage, airfare and lodging"
billableboolean—NotrueWhether expenses on the code are billable.true
taxableboolean—NofalseWhether expenses on the code are taxable.false
reimbursableboolean—NofalseWhether expenses on the code are reimbursable.true
activeboolean—Notruefalse deactivates the code.true

Without pmsRef, a new expense code takes systemRef.reference when systemRef.system is PM, and a generated reference otherwise.

OperationalCode

An operational code classifies non-client operational time, such as internal training.

NameTypeFormatRequiredDefaultDescriptionExample
pmsRefstring—NogeneratedPractice-management-system reference."TRAINING"
codestring—Yes—Code value that operational entries reference."TRAINING"
displaystring—Yes—Name shown in Aiwyn."Internal training"
descriptionstring—No—Longer description."Courses and CPE"
activeboolean—Notruefalse deactivates the code.true

PtoCode

A PTO code classifies paid time off, such as vacation or sick leave. PTO codes have no display.

NameTypeFormatRequiredDefaultDescriptionExample
pmsRefstring—NogeneratedPractice-management-system reference."VACATION"
codestring—Yes—Code value that PTO entries reference."VACATION"
internalNotesstring—No—Notes for your firm."Annual leave"
activeboolean—Notruefalse deactivates the code.true