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:
| Type | Create or update | Paged lookup | Read by ID |
|---|---|---|---|
TimeCode | POST /api/v1/time-codes | POST /api/v1/time-codes/batch | GET /api/v1/time-codes/{id} |
ExpenseCode | POST /api/v1/expense-codes | POST /api/v1/expense-codes/batch | GET /api/v1/expense-codes/{id} |
OperationalCode | POST /api/v1/operational-codes | POST /api/v1/operational-codes/batch | GET /api/v1/operational-codes/{id} |
PtoCode | POST /api/v1/pto-codes | POST /api/v1/pto-codes/batch | GET /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.
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.
| Name | Type | Format | Nullable | Description | Example |
|---|---|---|---|---|---|
type | string | constant | No | Shared endpoints only. The code type, for example ExpenseCode. | "ExpenseCode" |
systemRef | object | {system, reference} | Yes | External identity used to match an existing code during upsert. | {"system":"PM","reference":"TRAVEL"} |
attributes | object | one of the tables below | No | Code 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.
| Name | Type | Format | Nullable | Description | Example |
|---|---|---|---|---|---|
type | string | — | No | The code type. | "ExpenseCode" |
aiwynId | integer | int64 | Yes | Aiwyn ID of the code; the {id} of the read-by-ID endpoint. | 4021 |
systemRefs | array | {system, reference} | No | Every reference the code is known by, including its PM reference. | [{"system":"PM","reference":"TRAVEL"}] |
attributes | object | string values | No | The 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"} |
A time code is a task type that time entries are logged against.
| Name | Type | Format | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
pmsRef | string | — | No | systemRef.reference | Practice-management-system reference. A new code needs pmsRef or a systemRef. | "ADMIN" |
code | string | — | Yes | — | Code value that time entries reference. | "ADMIN" |
display | string | — | No | code | Name shown in Aiwyn. | "Administration" |
description | string | — | No | — | Longer description. | "Internal administration" |
billable | boolean | — | No | true | Whether time logged against the code is billable. | false |
taxable | boolean | — | No | false | Whether time logged against the code is taxable. | false |
reimbursable | boolean | — | No | false | Whether costs logged against the code are reimbursable. | false |
active | boolean | — | No | true | false deactivates the code. | true |
rateTypeId | integer | Aiwyn ID | No | — | Rate type used to price time on this code. | 12 |
customHourlyRate | number | decimal | No | — | Hourly rate that overrides the rate type. | 150.00 |
taskTypeCategoryId | integer | Aiwyn ID | No | — | Task type category. | 3 |
serviceLineId | integer | Aiwyn ID | No | — | 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.
An expense code classifies expense entries. An expense entry references one by its code or by expenseCodeId.
| Name | Type | Format | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
pmsRef | string | — | No | see below | Practice-management-system reference. | "TRAVEL" |
code | string | — | Yes | — | Code value that expense entries reference. | "TRAVEL" |
display | string | — | Yes | — | Name shown in Aiwyn. | "Travel" |
description | string | — | No | — | Longer description. | "Mileage, airfare and lodging" |
billable | boolean | — | No | true | Whether expenses on the code are billable. | true |
taxable | boolean | — | No | false | Whether expenses on the code are taxable. | false |
reimbursable | boolean | — | No | false | Whether expenses on the code are reimbursable. | true |
active | boolean | — | No | true | false deactivates the code. | true |
Without pmsRef, a new expense code takes systemRef.reference when systemRef.system is PM, and a generated reference otherwise.
An operational code classifies non-client operational time, such as internal training.
| Name | Type | Format | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
pmsRef | string | — | No | generated | Practice-management-system reference. | "TRAINING" |
code | string | — | Yes | — | Code value that operational entries reference. | "TRAINING" |
display | string | — | Yes | — | Name shown in Aiwyn. | "Internal training" |
description | string | — | No | — | Longer description. | "Courses and CPE" |
active | boolean | — | No | true | false deactivates the code. | true |
A PTO code classifies paid time off, such as vacation or sick leave. PTO codes have no display.
| Name | Type | Format | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
pmsRef | string | — | No | generated | Practice-management-system reference. | "VACATION" |
code | string | — | Yes | — | Code value that PTO entries reference. | "VACATION" |
internalNotes | string | — | No | — | Notes for your firm. | "Annual leave" |
active | boolean | — | No | true | false deactivates the code. | true |