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

# Update CoworkerInvoice

> Update an existing CoworkerInvoice record.

Updates an existing CoworkerInvoice record. You must include the `Id` of the record to update along with all required fields.

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`CoworkerInvoice-Edit`** role.
</Note>

## Enums

<Accordion title="eStorecoveInvoiceStatus — StorecoveInvoiceStatus values">
  | Value | Name             |
  | ----- | ---------------- |
  | 1     | None             |
  | 2     | TransferFailed   |
  | 3     | Processing       |
  | 4     | ProcessingFailed |
  | 5     | Processed        |
</Accordion>

## Request Body

### Required Fields

<ParamField body="Id" type="integer" required>
  The Id of the CoworkerInvoice record to update.
</ParamField>

<ParamField body="CoworkerId" type="integer" required>
  Coworker Id.
</ParamField>

<ParamField body="BusinessId" type="integer" required>
  Business Id.
</ParamField>

<ParamField body="InvoiceNumber" type="string" required>
  Unique invoice number assigned when the invoice is finalised.
</ParamField>

<ParamField body="BillToName" type="string" required>
  Name of the person or company being billed.
</ParamField>

<ParamField body="BillToAddress" type="string" required>
  Billing address on the invoice.
</ParamField>

<ParamField body="BillToCity" type="string" required>
  Billing city on the invoice.
</ParamField>

<ParamField body="BillToPostCode" type="string" required>
  Billing post code on the invoice.
</ParamField>

<ParamField body="BillToCountryId" type="integer" required>
  Bill To Country Id.
</ParamField>

<ParamField body="CurrencyId" type="integer" required>
  Currency Id.
</ParamField>

<ParamField body="StorecoveInvoiceStatus" type="integer" required>
  Status of e-invoicing transfer via Storecove.
</ParamField>

### Optional Fields

<ParamField body="PaymentReference" type="string">
  Reference code used to match payments to this invoice.
</ParamField>

<ParamField body="BillToPhone" type="string">
  Billing phone number on the invoice.
</ParamField>

<ParamField body="BillToFax" type="string">
  Billing fax number on the invoice.
</ParamField>

<ParamField body="BillToState" type="string">
  Billing state or region on the invoice.
</ParamField>

<ParamField body="BillToBankAccount" type="string">
  Bank account number on the invoice for payment.
</ParamField>

<ParamField body="BillToTaxIDNumber" type="string">
  Tax identification number of the billed party.
</ParamField>

<ParamField body="PurchaseOrder" type="string">
  Customer purchase order number for this invoice.
</ParamField>

<ParamField body="DueDate" type="string">
  Date by which payment is due.
</ParamField>

<ParamField body="InvoiceFromDate" type="string">
  Start date of the billing period covered by this invoice.
</ParamField>

<ParamField body="InvoiceToDate" type="string">
  End date of the billing period covered by this invoice.
</ParamField>

<ParamField body="TransactionTotalAmount" type="number">
  Transaction Total Amount.
</ParamField>

<ParamField body="TransactionCurrencyId" type="integer">
  Transaction Currency Id.
</ParamField>

<ParamField body="TransactionExchangeRate" type="number">
  Transaction Exchange Rate.
</ParamField>

<ParamField body="Draft" type="boolean">
  Whether the invoice is still a draft. Draft invoices can be modified before finalisation.
</ParamField>

<ParamField body="PaidOn" type="string">
  Date the invoice was marked as fully paid.
</ParamField>

<ParamField body="Billed" type="boolean">
  Billed.
</ParamField>

<ParamField body="DoNotApplyCreditAutomatically" type="boolean">
  Whether to skip automatic application of available credit to this invoice.
</ParamField>

<ParamField body="CreatedOnLocal" type="string">
  Created On Local.
</ParamField>

<ParamField body="DueDateLocal" type="string">
  Due Date Local.
</ParamField>

<ParamField body="InvoiceFromDateLocal" type="string">
  Invoice From Date Local.
</ParamField>

<ParamField body="InvoiceToDateLocal" type="string">
  Invoice To Date Local.
</ParamField>

<ParamField body="PaidOnLocal" type="string">
  Paid On Local.
</ParamField>

<ParamField body="RefundedOnLocal" type="string">
  Refunded On Local.
</ParamField>

<ParamField body="LastPaymentAttemptLocal" type="string">
  Last Payment Attempt Local.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT \
    "https://spaces.nexudus.com/api/billing/coworkerinvoices" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "CoworkerId": 0,
      "BusinessId": 0,
      "InvoiceNumber": "",
      "BillToName": "",
      "BillToAddress": "",
      "BillToCity": "",
      "BillToPostCode": "",
      "BillToCountryId": 0,
      "CurrencyId": 0,
      "StorecoveInvoiceStatus": 0,
      "Id": 87654321
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/coworkerinvoices',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        CoworkerId: 0,
        BusinessId: 0,
        InvoiceNumber: '',
        BillToName: '',
        BillToAddress: '',
        BillToCity: '',
        BillToPostCode: '',
        BillToCountryId: 0,
        CurrencyId: 0,
        StorecoveInvoiceStatus: 0,
        Id: 87654321
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.put(
      'https://spaces.nexudus.com/api/billing/coworkerinvoices',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'CoworkerId': 0,
          'BusinessId': 0,
          'InvoiceNumber': '',
          'BillToName': '',
          'BillToAddress': '',
          'BillToCity': '',
          'BillToPostCode': '',
          'BillToCountryId': 0,
          'CurrencyId': 0,
          'StorecoveInvoiceStatus': 0,
          'Id': 87654321
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Status" type="integer">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="Message" type="string">
  A human-readable message confirming the update.
</ResponseField>

<ResponseField name="Value" type="object">
  Contains the `Id` of the updated record.
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `true` if the coworkerinvoice was updated successfully.
</ResponseField>

<ResponseField name="Errors" type="array">
  `null` on success.
</ResponseField>

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "CoworkerInvoice was successfully updated.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

<ResponseField name="Message" type="string">
  A summary of the validation error(s), in the format `PropertyName: error message`.
</ResponseField>

<ResponseField name="Value" type="any">
  `null` on validation failure.
</ResponseField>

<ResponseField name="Errors" type="object[]">
  Array of validation errors.

  <Expandable>
    <ResponseField name="AttemptedValue" type="any">
      The value that was submitted for the field, or `null` if missing.
    </ResponseField>

    <ResponseField name="Message" type="string">
      The validation error message.
    </ResponseField>

    <ResponseField name="PropertyName" type="string">
      The name of the property that failed validation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `false` when the request fails validation.
</ResponseField>

```json Example Response theme={null}
{
  "Message": "InvoiceNumber: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "InvoiceNumber"
    }
  ],
  "WasSuccessful": false
}
```
