Skip to content

Create or update time management entry records (upsert)

Request

🔐 Required role: TM_ENTRY_C

📖 Data dictionary: Time entry

Create or update time management entry records (upsert)

Records are created if they don't exist, or updated if matched by top-level systemRef. Maximum 100 records per request.

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. A type that is not an entry type returns 400.

TimeEntry — hours, rate and amounts

  • units is the hours worked. value is the amount in currency, not the hours.
  • Omit billedPerUnit when your system does not know the firm's billing rates (a time-entry tool, for example). Aiwyn then resolves the rate card rate for the logged staff, the work code and the logged date exactly as the firm portal does, and computes value, billedPerUnit and costPerUnit from units. The entry also gets an audit transaction. value is still required by the schema: send 0, it is overwritten.
  • Send billedPerUnit only when your system is the source of truth for rates (a practice management system). The record is then stored exactly as sent, nothing is computed.
  • A billable work code with no active rate card rate for that staff type and date fails the record with RATE_NOT_FOUND. Set the rate card up in Aiwyn first.
  • Re-posting an entry (same systemRef) without billedPerUnit resolves the rate again from the values sent, as an edit in the firm portal does. An entry already on an invoice is locked and fails the record with LOCKED.
  • type ("Time"), billedAmount, writeOffAmount and costPerUnit are required by the schema. Send 0 for the three amounts on a new entry. loggedDate is an ISO-8601 date-time with zone (2026-06-17T09:00:00Z).
  • posted and approved default to true: an entry posted by an external system is treated as already approved and posted. Send false explicitly if the firm reviews entries in Aiwyn before billing.

TimeEntry — identifying the work (task type)

The work code decides whether the entry is billable and which rate applies. Send one of:

  • code — the work code string. It must match the exact time_management_entry_code.code value, or fall back to task_type.code. Stored as entry_code_id.
  • taskId — a project task. Accepts a systemRef ({ "system": "PM", "reference": "<task-pmsRef>" }), a numeric Aiwyn id, or a string numeric id (treated as Aiwyn id). The work code is derived from the task's task type when no code is supplied. When both are provided, code wins.

An entry with neither is stored as non-billable with a zero amount, because no rate can be resolved without a work code.

Resolving task references

Look up tasks before upserting entries:

  • GET /gql/v1/task/{id} — get a task by Aiwyn id
  • POST /gql/v1/tasks/search — search tasks (filter by job, assignee, task type, dates)

See GET /api/v1/entries/schema/TimeEntry for the full attribute list, including custom fields.

Example — time-entry tool (rate resolved by Aiwyn)

See the request sample: hours in units, value and costPerUnit 0, no billedPerUnit, the work code in code.

Example — practice management system (rate already resolved)

{
  "records": [
    {
      "type": "TimeEntry",
      "systemRef": {"system": "PM", "reference": "pms-entry-002"},
      "attributes": {
        "pmsRef": "pms-entry-002",
        "type": "Time",
        "loggedDate": "2026-06-17T14:00:00Z",
        "units": 1.0,
        "billedPerUnit": 250,
        "value": 250,
        "costPerUnit": 90,
        "billedAmount": 0,
        "writeOffAmount": 0,
        "billable": true,
        "clientId": {"system": "PM", "reference": "37584"},
        "jobId": {"system": "PM", "reference": "AIWYN_29059"},
        "loggedStaffId": {"system": "PM", "reference": "12345"},
        "taskId": {"system": "PM", "reference": "AIWYN_98765"}
      }
    }
  ]
}

Recording an expense with ExpenseEntry

ExpenseEntry is WIP-backed like TimeEntry: it carries clientId, jobId, and loggedStaffId, and the same checks apply (inactive client, inactive project, client/project mismatch, inactive staff). An entry already on an invoice is locked and fails the record with LOCKED. No rate is resolved for an expense: it is stored as sent.

  • type ("Expense"), loggedDate, clientId, loggedStaffId, value, costPerUnit, billedAmount, writeOffAmount, and billable are required by the schema. value is the expense amount. Send what the firm portal stores for an expense: units 1, costPerUnit and billedPerUnit equal to value, and 0 for billedAmount and writeOffAmount.
  • posted and approved default to true: an expense posted by an external system is treated as already approved and posted. Send false explicitly if the firm reviews expenses in Aiwyn before billing, as it does for expenses entered in the firm portal.
  • notes is the entry description carried on the WIP; internalNotes is the firm-internal note.

Select the expense code with either attribute:

  • expenseCodeId: the numeric Aiwyn id of an ExpenseCode. A non-null expenseCodeId wins when both are supplied.
  • code: the exact code value of an ExpenseCode; when several codes share the value, an active one is preferred. An unknown code fails the record with Unknown ExpenseEntry code; persist codes first via POST /api/v1/codes.

See GET /api/v1/entries/schema/ExpenseEntry for the full attribute list, including custom fields, and the ExpenseEntry request example at the end of this page.

Migrating from the firm portal expense form

Firm portal fieldExpenseEntry attribute
amountvalue, costPerUnit, and billedPerUnit; units is 1, billedAmount and writeOffAmount are 0
expenseCodeIdexpenseCodeId, or code
clientId, jobId, loggedStaffIdsame name; numeric Aiwyn id or {"system": "PM", "reference": "<pmsRef>"}
loggedDate, notes, internalNotessame name; loggedDate is an ISO-8601 date-time with offset, e.g. 2026-06-17T00:00:00Z
not on the formtype "Expense"; billable (the form copies it from the expense code); posted and approved false to match a form submission
wipIdnot sent; records are matched by systemRef

Business Applications:

  • Sync time entries from external time-tracking systems
  • Sync expense entries from expense-management and reimbursement systems
  • Attach project tasks to time entries
  • Upsert entries by external system reference

ExpenseEntry with expense code:

{
  "records": [
    {
      "type": "ExpenseEntry",
      "systemRef": {"system": "PM", "reference": "beeye-expense-001"},
      "attributes": {
        "pmsRef": "beeye-expense-001",
        "type": "Expense",
        "loggedDate": "2026-06-17T00:00:00Z",
        "value": 123.45,
        "units": 1,
        "costPerUnit": 123.45,
        "billedPerUnit": 123.45,
        "billedAmount": 0,
        "writeOffAmount": 0,
        "billable": true,
        "notes": "Client site travel",
        "internalNotes": "Mileage, 150 mi",
        "clientId": {"system": "PM", "reference": "37584"},
        "jobId": {"system": "PM", "reference": "AIWYN_29059"},
        "loggedStaffId": {"system": "PM", "reference": "12345"},
        "code": "TRAVEL"
      }
    }
  ]
}
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/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": [
      {
        "type": "TimeEntry",
        "systemRef": {
          "system": "PM",
          "reference": "laurel-entry-001"
        },
        "attributes": {
          "pmsRef": "laurel-entry-001",
          "type": "Time",
          "loggedDate": "2026-06-17T09:00:00Z",
          "units": 2.5,
          "value": 0,
          "costPerUnit": 0,
          "billedAmount": 0,
          "writeOffAmount": 0,
          "notes": "Worked on tax planning deliverable",
          "clientId": {
            "system": "PM",
            "reference": "37584"
          },
          "jobId": {
            "system": "PM",
            "reference": "AIWYN_29059"
          },
          "loggedStaffId": {
            "system": "PM",
            "reference": "12345"
          },
          "code": "TXBLE30X01"
        }
      }
    ]
  }'

Responses

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