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

# Update a work

> Updates a work. Send the full set of fields you want the work to have; the same required-field rules as creation apply.
Completed works can only be updated if the workspace allows it. Requires the `works:write` scope.




## OpenAPI

````yaml /openapi.yaml put /works/{id}
openapi: 3.1.0
info:
  title: BeanRails Public API
  version: 1.0.0
  description: >
    Read and write BeanRails contacts, works, invoices, quotations and invoice
    payments from your own systems.

    Authenticate every request with an API key. See the guides for scopes,
    pagination and error handling.
servers:
  - url: https://{host}/api/public/v1
    description: Public API v1
    variables:
      host:
        default: app.beanrails.com
        description: The host your BeanRails workspace is served from.
security:
  - bearerAuth: []
tags:
  - name: Contacts
    description: Customers and leads.
  - name: Contact addresses
    description: Billing, shipping and service addresses of a contact.
  - name: Works
    description: Service or delivery jobs.
  - name: Work PODs
    description: Proof of delivery records submitted by drivers (read only).
  - name: Invoices
    description: Invoices, including status changes.
  - name: Quotations
    description: Quotations, including status changes.
  - name: Invoice payments
    description: Payments recorded against an invoice.
paths:
  /works/{id}:
    parameters:
      - $ref: '#/components/parameters/Id'
    put:
      tags:
        - Works
      summary: Update a work
      description: >
        Updates a work. Send the full set of fields you want the work to have;
        the same required-field rules as creation apply.

        Completed works can only be updated if the workspace allows it. Requires
        the `works:write` scope.
      operationId: updateWork
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkInput'
      responses:
        '200':
          description: The updated work.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkEnvelope'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    Id:
      name: id
      in: path
      required: true
      description: The record ID.
      schema:
        type: integer
  schemas:
    WorkInput:
      type: object
      required:
        - work_date
        - attention
        - address1
      properties:
        work_date:
          type: string
          format: date
          description: '`YYYY-MM-DD`, in the workspace timezone.'
        time_window_from:
          type: string
          description: '`HH:mm`.'
        time_window_to:
          type: string
          description: '`HH:mm`, after `time_window_from`.'
        work_number:
          type: string
          description: >-
            Required only when the workspace does not number works
            automatically.
        contact_id:
          type: integer
        vehicle_id:
          type: integer
        zone_id:
          type: integer
        service_type:
          type: string
          enum:
            - service
            - engineering
        attention:
          type: string
          maxLength: 255
          description: The person to see on site.
        email:
          type: string
        company_name:
          type: string
        mobile_no:
          type: string
        office_no:
          type: string
        address1:
          type: string
          maxLength: 255
        address2:
          type: string
        city:
          type: string
        state:
          type: string
        postcode:
          type: string
        country:
          type: string
          description: Two letter country code.
        user_lat:
          type: number
        user_lng:
          type: number
        work_price:
          type: number
        instructions:
          type: string
        is_collect_work_price:
          type: boolean
        is_auto_reschedule:
          type: boolean
        vehicles:
          type: array
          items:
            type: integer
          description: Additional helper vehicle IDs.
        items:
          type: array
          items:
            type: object
            required:
              - name
            properties:
              id:
                type: integer
                description: >-
                  Include to update an existing item on work update. Items you
                  leave out are removed.
              name:
                type: string
              sku:
                type: string
              description:
                type: string
              quantity:
                type: number
              unit_of_measure:
                type: string
              unit_price:
                type: number
    WorkEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Work'
    Work:
      type: object
      additionalProperties: true
      properties:
        id:
          type: integer
        work_number:
          type: string
        work_date:
          type: string
          description: The work date in the workspace timezone.
        time_window_from:
          type:
            - string
            - 'null'
        time_window_to:
          type:
            - string
            - 'null'
        status:
          type: string
          enum:
            - new
            - vehicle_assigned
            - in_progress
            - failed
            - cancelled
            - completed
        status_name:
          type:
            - string
            - 'null'
        service_type:
          type:
            - string
            - 'null'
          enum:
            - service
            - engineering
            - null
        contact_id:
          type:
            - integer
            - 'null'
        vehicle_id:
          type:
            - integer
            - 'null'
        vehicle_name:
          type:
            - string
            - 'null'
        zone_id:
          type:
            - integer
            - 'null'
        zone_name:
          type:
            - string
            - 'null'
        attention:
          type: string
        email:
          type:
            - string
            - 'null'
        company_name:
          type:
            - string
            - 'null'
        mobile_no:
          type:
            - string
            - 'null'
        office_no:
          type:
            - string
            - 'null'
        address1:
          type: string
        address2:
          type:
            - string
            - 'null'
        city:
          type:
            - string
            - 'null'
        state:
          type:
            - string
            - 'null'
        postcode:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
        instructions:
          type:
            - string
            - 'null'
        work_price:
          type:
            - string
            - 'null'
          description: Free text entered by the user, not a number.
        items:
          type: array
          items:
            $ref: '#/components/schemas/WorkItem'
        created_at:
          type: string
        updated_at:
          type: string
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: A stable, machine readable code.
              examples:
                - not_found
            message:
              type: string
              description: A human readable explanation.
    ValidationError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - fields
          properties:
            code:
              type: string
              enum:
                - validation_failed
            message:
              type: string
            fields:
              type: object
              description: Field names mapped to a list of messages.
              additionalProperties:
                type: array
                items:
                  type: string
    WorkItem:
      type: object
      additionalProperties: true
      properties:
        id:
          type: integer
        name:
          type: string
        sku:
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        quantity:
          type:
            - number
            - 'null'
        unit_of_measure:
          type:
            - string
            - 'null'
        unit_price:
          type:
            - number
            - 'null'
  responses:
    Unauthorized:
      description: The API key is missing, invalid, revoked or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_api_key
              message: The API key is invalid, revoked, or expired.
    Forbidden:
      description: >-
        The key lacks the required scope, the key owner's role no longer allows
        it, or the owner's account is suspended.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: insufficient_scope
              message: This API key does not have the required scope.
    NotFound:
      description: The record does not exist, or your key is not allowed to see it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
              message: The requested resource was not found.
    ValidationFailed:
      description: >-
        The request body failed validation. `error.fields` lists the problems
        per field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
          example:
            error:
              code: validation_failed
              message: The attention field is required.
              fields:
                attention:
                  - The attention field is required.
    RateLimited:
      description: >-
        You exceeded the key's requests per minute. Wait for the number of
        seconds in the `Retry-After` header.
      headers:
        Retry-After:
          description: Seconds until you can retry.
          schema:
            type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An API key created in BeanRails, for example `brk_live_...`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.