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

# Create ContractDeposit

> Create a new ContractDeposit record.

A **ContractDeposit** represents a security deposit or retainer associated with a plan contract (`CoworkerContract`). Each deposit is based on a `Product` and is charged to the member either on the first invoice generated for the contract, or on the next invoice for any contract that has `IncludeSignupFee = true`.

ContractDeposits are created automatically when a contract is signed for a plan (`Tariff`) that includes one or more `TariffSignupProducts`. Each `TariffSignupProduct` on the plan becomes a corresponding `ContractDeposit` on the new contract.

When `Refundable = true`, cancelling the parent contract automatically generates a credit note for the deposit amount. That credit note can then be applied — fully or partially — against any outstanding fees or damage charges raised via a separate invoice.

## 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 **`ContractDeposit-Create`** role.
</Note>

## Request Body

### Required Fields

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

<ParamField body="ProductId" type="integer" required>
  Product Id.
</ParamField>

### Optional Fields

<ParamField body="Notes" type="string">
  Optional notes or internal comments about this deposit.
</ParamField>

<ParamField body="Price" type="number">
  Deposit amount to charge. When set, overrides the default price of the linked product.
</ParamField>

<ParamField body="Refundable" type="boolean">
  When true, cancelling the parent contract automatically generates a credit note for the deposit amount, which can be applied against outstanding fees or damages.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/billing/contractdeposits" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "CoworkerContractId": 0,
      "ProductId": 0
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/contractdeposits',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        CoworkerContractId: 0,
        ProductId: 0
      })
    }
  );

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

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

  response = requests.post(
      'https://spaces.nexudus.com/api/billing/contractdeposits',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'CoworkerContractId': 0,
          'ProductId': 0
      }
  )

  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 creation.
</ResponseField>

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

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

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

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