Skip to content

Create or update expense codes (upsert)

Request

🔐 Required role: TM_CODE_C

📖 Data dictionary: Time-management code

Create or update expense codes (upsert)

Expense codes classify expense entries; an entry references one by its code or by expenseCodeId.

Every record is saved with type ExpenseCode, so records carry no type. Maximum 100 records per request.

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. Attributes left out of an update keep their values. A record with any field other than systemRef and attributes is rejected with 400. Some older expense codes appear in the lookup but aren't matched here, so sending one creates a new expense code.

AttributeTypeRequiredDefaultDescription
pmsRefstringNosee belowReference in your practice management system.
codestringYes—Code value that expense entries reference.
displaystringYes—Name shown in Aiwyn.
descriptionstringNo—Longer description.
billablebooleanNotrueWhether expenses on the code are billable.
taxablebooleanNofalseWhether expenses on the code are taxable.
reimbursablebooleanNofalseWhether expenses on the code are reimbursable.
activebooleanNotruefalse deactivates the code.

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

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-codes \
  -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": "TRAVEL"
        },
        "attributes": {
          "pmsRef": "TRAVEL",
          "code": "TRAVEL",
          "display": "Travel",
          "description": "Mileage, airfare and lodging",
          "billable": true,
          "reimbursable": true,
          "taxable": false,
          "active": true
        }
      }
    ]
  }'

Responses

All expense codes 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" } }