Skip to content

Create or update time codes (upsert)

Request

🔐 Required role: TM_CODE_C

📖 Data dictionary: Time-management code

Create or update time codes (upsert)

Time codes are the task types that time entries are logged against.

Every record is saved with type TimeCode, 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. Time codes kept as task types appear in the lookup but aren't matched here, so sending one creates a new time code.

AttributeTypeRequiredDefaultDescription
pmsRefstringNosystemRef.referenceReference in your practice management system.
codestringYes—Code value that time entries reference.
displaystringNocodeName shown in Aiwyn.
descriptionstringNo—Longer description.
billablebooleanNotrueWhether time logged against the code is billable.
taxablebooleanNofalseWhether time logged against the code is taxable.
reimbursablebooleanNofalseWhether costs logged against the code are reimbursable.
activebooleanNotruefalse deactivates the code.
rateTypeIdintegerNo—Aiwyn ID of the rate type used to price time on this code.
customHourlyRatenumberNo—Hourly rate that overrides the rate type.
taskTypeCategoryIdintegerNo—Aiwyn ID of the task type category.
serviceLineIdintegerNo—Aiwyn ID of the service line.

A new time code needs code, and pmsRef or a systemRef. The paged lookup and GET /api/v1/time-codes/{id} return reimbursable as false, and for time codes created here they don't return rateTypeId, customHourlyRate, taskTypeCategoryId or serviceLineId; the values you send are kept. A deactivated time code is no longer returned by either.

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/time-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": "ADMIN"
        },
        "attributes": {
          "pmsRef": "ADMIN",
          "code": "ADMIN",
          "display": "Administration",
          "billable": false,
          "active": true
        }
      }
    ]
  }'

Responses

All time 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" } }