> ## 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 CoworkerBookingCredit

> Update an existing CoworkerBookingCredit record.

Updates an existing CoworkerBookingCredit 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 **`CoworkerBookingCredit-Edit`** role.
</Note>

## Request Body

### Required Fields

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

<ParamField body="CoworkerId" type="integer" required>
  ID of the customer this credit is assigned to.
</ParamField>

<ParamField body="BusinessId" type="integer" required>
  ID of the location issuing the credit.
</ParamField>

<ParamField body="TotalCredit" type="number" required>
  Total credit amount originally assigned.
</ParamField>

### Optional Fields

<ParamField body="Description" type="string">
  Optional description or label for this credit.
</ParamField>

<ParamField body="ElegibleResourceTypes" type="integer[]">
  Resource types this credit can be used for. If empty, the credit is valid for all resource types.
</ParamField>

<ParamField body="AddedElegibleResourceTypes" type="integer[]">
  Resource type IDs to add to ElegibleResourceTypes.
</ParamField>

<ParamField body="RemovedElegibleResourceTypes" type="integer[]">
  Resource type IDs to remove from ElegibleResourceTypes.
</ParamField>

<ParamField body="ElegibleProducts" type="integer[]">
  Products this credit can be used for. If empty, applies to all products.
</ParamField>

<ParamField body="AddedElegibleProducts" type="integer[]">
  Product IDs to add to ElegibleProducts.
</ParamField>

<ParamField body="RemovedElegibleProducts" type="integer[]">
  Product IDs to remove from ElegibleProducts.
</ParamField>

<ParamField body="ElegibleTariffs" type="integer[]">
  Plans (tariffs) this credit is restricted to. If empty, applies to customers on any plan.
</ParamField>

<ParamField body="AddedElegibleTariffs" type="integer[]">
  Plan IDs to add to ElegibleTariffs.
</ParamField>

<ParamField body="RemovedElegibleTariffs" type="integer[]">
  Plan IDs to remove from ElegibleTariffs.
</ParamField>

<ParamField body="ValidFrom" type="string">
  Date from which this credit is valid.
</ParamField>

<ParamField body="ExpireDate" type="string">
  Date on which this credit expires.
</ParamField>

<ParamField body="CaneBeUsedForBookings" type="boolean">
  Whether this credit can be used to pay for bookings. Restrict to specific resource types with `ElegibleResourceTypes`.
</ParamField>

<ParamField body="CaneBeUsedForEvents" type="boolean">
  Whether this credit can be used to pay for event sign-ups. Restrict to specific categories with `EventCategories`.
</ParamField>

<ParamField body="EventCategories" type="integer[]">
  Event categories this credit can be used for. If empty, applies to all event categories.
</ParamField>

<ParamField body="AddedEventCategories" type="integer[]">
  Event category IDs to add to EventCategories.
</ParamField>

<ParamField body="RemovedEventCategories" type="integer[]">
  Event category IDs to remove from EventCategories.
</ParamField>

<ParamField body="IsUniversalCredit" type="boolean">
  Whether this is a universal credit applicable to products, time passes and other charges. Restrict with `ElegibleProducts`, `ElegiblePasses` and `AppliesToCharges`; if all are empty the credit applies to all products, passes and charges.
</ParamField>

<ParamField body="UseCreditPrice" type="boolean">
  Whether to use the credit price instead of the standard booking price when this credit is applied.
</ParamField>

<ParamField body="CoworkerContractUniqueId" type="string">
  Unique ID of the contract that originated this credit.
</ParamField>

<ParamField body="ElegiblePasses" type="integer[]">
  Time passes this credit can be used for. If empty, applies to all passes.
</ParamField>

<ParamField body="AddedElegiblePasses" type="integer[]">
  Pass IDs to add to ElegiblePasses.
</ParamField>

<ParamField body="RemovedElegiblePasses" type="integer[]">
  Pass IDs to remove from ElegiblePasses.
</ParamField>

<ParamField body="AppliesToCharges" type="boolean">
  Whether this universal credit applies to other charges.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT \
    "https://spaces.nexudus.com/api/billing/coworkerbookingcredits" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "CoworkerId": 0,
      "BusinessId": 0,
      "TotalCredit": 0,
      "Id": 87654321
  }'
  ```

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

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

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

  response = requests.put(
      'https://spaces.nexudus.com/api/billing/coworkerbookingcredits',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'CoworkerId': 0,
          'BusinessId': 0,
          'TotalCredit': 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 coworkerbookingcredit was updated successfully.
</ResponseField>

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

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "CoworkerBookingCredit 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": "RemainingCredit: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "RemainingCredit"
    }
  ],
  "WasSuccessful": false
}
```
