> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infinity.swiss/llms.txt
> Use this file to discover all available pages before exploring further.

# Modify work entry

> Edits the provided fields of a work entry. Any fields that are not provided are left unchanged.

Omit `type` to keep the work entry at its current type. Provide `type` to convert the work entry, in which case the fields of the new type must be provided as well and the fields of the previous type are discarded.

Only fields belonging to the resulting type may be sent. Work entries that have already been billed can still be edited, but this does not change any invoice that was already issued from them.

## Modifying a work entry

Any fields that are not provided are left unchanged. Omit `type` to keep the work entry at its current type and correct individual fields:

```json theme={null}
{
  "hours": 4,
  "minutes": 15
}
```

Provide `type` to convert a work entry into another type. The fields of the new type must be provided as well, and the fields of the previous type are discarded:

```json theme={null}
{
  "type": "fixed-price",
  "price": 50000
}
```

Only fields belonging to the resulting type may be sent. Sending a `price` for an entry that stays `hourly`, for example, is rejected with `general/malformed-request`.

<Note>
  Work entries that have already been billed can still be edited, but this does
  not change any invoice that was already issued from them. The `wasBilled`
  field is read-only and is set by Infinity when the work is billed.
</Note>


## OpenAPI

````yaml PATCH /v1/projects/{projectId}/work-entries/{workEntryId}
openapi: 3.1.0
info:
  title: infinity.swiss Open API
  version: '1.0'
  summary: ''
servers:
  - url: https://api.infinity.swiss
security:
  - apiKey: []
paths:
  /v1/projects/{projectId}/work-entries/{workEntryId}:
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        description: The id of the project the work entry belongs to.
        required: true
      - schema:
          type: string
        name: workEntryId
        in: path
        description: The id of the specific work entry.
        required: true
    patch:
      tags: []
      summary: Modify work entry
      description: >-
        Edits the provided fields of a work entry. Any fields that are not
        provided are left unchanged.


        Omit `type` to keep the work entry at its current type. Provide `type`
        to convert the work entry, in which case the fields of the new type must
        be provided as well and the fields of the previous type are discarded.


        Only fields belonging to the resulting type may be sent. Work entries
        that have already been billed can still be edited, but this does not
        change any invoice that was already issued from them.
      operationId: modify-work-entry-by-id-v1
      requestBody:
        description: The changes to apply to the work entry.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkEntryModificationInput'
            examples:
              Correct the description:
                value:
                  description: Elektroinstallation Erdgeschoss
              Correct the time spent:
                value:
                  hours: 4
                  minutes: 15
              Convert to a fixed price:
                value:
                  type: fixed-price
                  price: 50000
      responses:
        '200':
          description: The changes were saved successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  workEntry:
                    $ref: '#/components/schemas/WorkEntry'
        '400':
          $ref: '#/components/responses/WorkEntryBadRequest'
        '401':
          $ref: '#/components/responses/Unauthorised'
        '404':
          $ref: '#/components/responses/WorkEntryNotFound'
components:
  schemas:
    WorkEntryModificationInput:
      title: WorkEntryModificationInput
      type: object
      description: >-
        Request body for modifying a work entry. All fields are optional. Only
        fields belonging to the resulting type may be sent.
      properties:
        type:
          $ref: '#/components/schemas/WorkEntryType'
        date:
          type: string
          format: date
          description: The date the work was performed on, in YYYY-MM-DD format.
        description:
          type: string
          maxLength: 2000
          description: The description of the work that was performed.
        price:
          type: integer
          description: The amount in cents to invoice, for `fixed-price` work entries.
        rate:
          type: integer
          description: The hourly rate in cents, for `hourly` work entries.
        hours:
          type: integer
          description: The number of full hours spent, for `hourly` work entries.
        minutes:
          type: integer
          description: >-
            The number of minutes spent in addition to `hours`, for `hourly`
            work entries.
    WorkEntry:
      title: WorkEntry
      type: object
      description: A single unit of work that was performed on a project.
      required:
        - id
        - type
        - date
        - description
        - wasBilled
      properties:
        id:
          type: string
          description: The unique id of this work entry within its project.
        type:
          $ref: '#/components/schemas/WorkEntryType'
        date:
          type: string
          format: date
          description: The date the work was performed on, in YYYY-MM-DD format.
        description:
          type: string
          description: >-
            The description of the work that was performed. Appears on the
            invoice when the work entry is billed.
        wasBilled:
          type: boolean
          description: >-
            Whether this work entry has already been billed on an invoice. This
            field is read-only and is set by Infinity when the work is billed.
        price:
          type: integer
          description: >-
            The amount in cents that can be invoiced for this work entry. Only
            present for `fixed-price` work entries.
        rate:
          type: integer
          description: >-
            The hourly rate in cents used for this work entry. Only present for
            `hourly` work entries.
        hours:
          type: integer
          description: >-
            The number of full hours spent. Only present for `hourly` work
            entries.
        minutes:
          type: integer
          description: >-
            The number of minutes spent in addition to `hours`. Only present for
            `hourly` work entries.
        amount:
          type: integer
          description: >-
            The resulting value of this work entry in cents. Not present for
            `unbillable` work entries.
    WorkEntryType:
      title: WorkEntryType
      type: string
      description: >-
        The kind of a work entry, which determines how it is valued:

        - `hourly` is valued by an hourly rate and the time spent

        - `fixed-price` is valued by a fixed amount, e.g. for materials or lump
        sum work

        - `unbillable` has no value and cannot be billed
      enum:
        - unbillable
        - fixed-price
        - hourly
  responses:
    WorkEntryBadRequest:
      description: >-
        A bad request is thrown if the work entry payload is malformed or fails
        validation.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
            properties:
              code:
                type: string
                description: >-
                  The specific error code for this request. May be:

                  - `general/missing-fields` when required fields are missing or
                  malformed

                  - `general/malformed-request` when fields are sent that do not
                  belong to the work entry type

                  - `general/zero-or-negative-amount-not-allowed` when a price
                  or rate is zero or negative

                  - `projects/invalid-unbilled-work-time` when the time spent is
                  zero or the minutes are out of range
              invalidFields:
                type: array
                description: A list of the fields which were invalid, if applicable.
                items:
                  type: string
    Unauthorised:
      description: >-
        An unauthorised request was submitted. You may be using an incorrect or
        expired API token, or are attempting to access a document outside of the
        scope of the token.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                x-stoplight:
                  id: 08hkw8ukmi2lp
                description: Specific error code
          examples:
            Unauthorised request:
              value:
                code: general/unauthorised
    WorkEntryNotFound:
      description: >-
        The project could not be found in this organisation, or it has no work
        entry with the given id.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                description: |-
                  The specific error code for this request. May be:
                  - `projects/not-found` when the project does not exist
                  - `general/not-found` when the project has no such work entry
  securitySchemes:
    apiKey:
      name: x-api-token
      type: apiKey
      in: header
      description: >-
        API token for authentication. Obtain from your Infinity account
        settings.

````