Skip to content

Create or update expense entries (upsert)

Request

🔐 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.

AttributeTypeRequiredDefaultDescription
pmsRefstringNosee belowReference in your practice management system.
loggedDatedate-timeYes—Date of the expense; see below.
loggedStaffIdAiwyn ID or {system, reference}Yes—Staff member who incurred the expense.
clientIdAiwyn ID or {system, reference}Yes—Client the expense is for.
jobIdAiwyn ID or {system, reference}No—Project.
codestringNo—Expense code code; an active code is preferred when several share it.
expenseCodeIdintegerNo—Aiwyn ID of the expense code; wins over code.
valuenumberYes—Expense amount.
unitsnumberNo1Send 1.
costPerUnitnumberYes—Send the expense amount.
billedPerUnitnumberNo0Send the expense amount.
billedAmountnumberYes—Amount already billed. 0 for a new expense.
writeOffAmountnumberYes—Amount written off. 0 for a new expense.
billablebooleanYes—Whether the expense is billable.
postedbooleanNotrueWhether the expense is posted.
approvedbooleanNotrueWhether the expense is approved.
notesstringNo—Expense description.
internalNotesstringNo—Note for your firm.
activebooleanNotruefalse 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.

Security
(BearerAuth and CfAccessClientId and CfAccessClientSecret) or BearerAuth
Bodyapplication/jsonrequired
recordsArray of objectsrequired

Records

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"
        }
      }
    ]
  }'

Responses

All expense entries processed successfully

Bodyapplication/json
dataobject
errorobject or null
metaobject
Response
{ "data": { "summary": {}, "records": [ … ] }, "error": {}, "meta": { "success": true, "message": "string", "timestamp": "2019-08-24T14:15:22Z", "version": "string" } }