- Create or update expense entries (upsert)
🔐 Required role:
TM_ENTRY_C📖 Data dictionary: Time-management entry
Create or update expense entries (upsert)
Every record is saved with type ExpenseEntry, so records carry no type; attributes.type is always Expense, and a type sent in attributes is replaced. Maximum 100 records per request.
A record updates the entry its systemRef names: the same system and reference, the entry with that Aiwyn ID when system is aiwyn, or else the entry whose pmsRef is the reference. Without a systemRef, it updates the entry whose pmsRef is attributes.pmsRef. When nothing matches, a new entry is created. Attributes left out of an update keep their values. A record with any field other than systemRef and attributes is rejected with 400.
| Attribute | Type | Required | Default | Description |
|---|---|---|---|---|
pmsRef | string | No | see below | Reference in your practice management system. |
loggedDate | date-time | Yes | — | Date of the expense; see below. |
loggedStaffId | Aiwyn ID or {system, reference} | Yes | — | Staff member who incurred the expense. |
clientId | Aiwyn ID or {system, reference} | Yes | — | Client the expense is for. |
jobId | Aiwyn ID or {system, reference} | No | — | Project. |
code | string | No | — | Expense code code; an active code is preferred when several share it. |
expenseCodeId | integer | No | — | Aiwyn ID of the expense code; wins over code. |
value | number | Yes | — | Expense amount. |
units | number | No | 1 | Send 1. |
costPerUnit | number | Yes | — | Send the expense amount. |
billedPerUnit | number | No | 0 | Send the expense amount. |
billedAmount | number | Yes | — | Amount already billed. 0 for a new expense. |
writeOffAmount | number | Yes | — | Amount written off. 0 for a new expense. |
billable | boolean | Yes | — | Whether the expense is billable. |
posted | boolean | No | true | Whether the expense is posted. |
approved | boolean | No | true | Whether the expense is approved. |
notes | string | No | — | Expense description. |
internalNotes | string | No | — | Note for your firm. |
active | boolean | No | true | false deactivates the expense. |
Without pmsRef, a new entry takes systemRef.reference when systemRef.system is PM, and a generated reference otherwise. loggedDate is an ISO-8601 date-time with Z or an offset, for example 2026-06-17T00:00:00Z; an offset is converted to UTC. A date alone, or a date-time without Z or an offset, fails with VALIDATION_ERROR.
No rate is resolved for an expense; it is stored as sent. Send what the firm portal stores: units 1, costPerUnit and billedPerUnit equal to value, and 0 for billedAmount and writeOffAmount. Select the expense code with code or expenseCodeId.
A record fails with INACTIVE_CLIENT, INACTIVE_PROJECT or INACTIVE_RESOURCE when the client, project or staff member is inactive, REFERENCE_MISMATCH when the project belongs to another client, LOCKED when the entry is already on an invoice, CONVERSION_ERROR for an unknown code, UNRESOLVED_REFERENCE when a {system, reference} matches no staff member, client or project (an Aiwyn ID is stored as sent, without a check), BUILD_ERROR when a required attribute is missing, and VALIDATION_ERROR for a negative units, a blank reference in loggedStaffId, clientId or jobId, or an invalid loggedDate.
Reading an expense entry back (paged lookup or GET /api/v1/expense-entries/{id}) does not return units, costPerUnit, billedPerUnit, billedAmount, writeOffAmount, pmsRef, its stored systemRefs or custom fields: they come back empty or as their defaults. The values you send are stored.
Custom fields your firm defines for ExpenseEntry are accepted too; list them with GET /api/v1/entries/schema/ExpenseEntry.
Each record succeeds or fails on its own: 200, 207 or 422 say whether all, some or none succeeded — see Batch writes: per-record results.
- Sandbox (requires Cloudflare Access headers)https://api.sandbox.aiwyn.app/api/v1/expense-entries
- Staging (requires Cloudflare Access headers)https://api.staging.aiwyn.app/api/v1/expense-entries
- Production (your live firm data; no Cloudflare Access headers)https://api.aiwyn.ai/api/v1/expense-entries
curl -i -X POST \
https://api.sandbox.aiwyn.app/api/v1/expense-entries \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'CF-Access-Client-Id: YOUR_API_KEY_HERE' \
-H 'CF-Access-Client-Secret: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"records": [
{
"systemRef": {
"system": "PM",
"reference": "expense-001"
},
"attributes": {
"loggedDate": "2026-06-17T00:00:00Z",
"loggedStaffId": {
"system": "PM",
"reference": "12345"
},
"clientId": {
"system": "PM",
"reference": "37584"
},
"jobId": {
"system": "PM",
"reference": "AIWYN_29059"
},
"code": "TRAVEL",
"value": 123.45,
"units": 1,
"costPerUnit": 123.45,
"billedPerUnit": 123.45,
"billedAmount": 0,
"writeOffAmount": 0,
"billable": true,
"notes": "Client site travel"
}
}
]
}'{ "data": { "summary": {}, "records": [ … ] }, "error": {}, "meta": { "success": true, "message": "string", "timestamp": "2019-08-24T14:15:22Z", "version": "string" } }