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

> Create a new CoworkerContract record.

A **CoworkerContract** is the foundation for automatic billing. It links a customer (`Coworker`) to a plan (`Tariff`) that drives the billing frequency, benefits and default settings for the contract. A customer can hold as many contracts as needed, each pointing to the same or different plans.

A customer with at least one active contract is regarded as a **Member**; customers with no active contracts are **Contacts**. Nexudus uses this distinction to enforce policies on products, resources, events, pricing and many other entities that expose `OnlyForMembers` or `OnlyForContacts` properties.

**Pricing** — The contract price can be fixed (`Price` is not null) or derived from the plan it is for. The `Value` field is used in reporting to compare with the actual price. Automatic price adjustments over time can be set up via `ContractSchedule` child entities.

**Billing cycle** — `RenewalDate` is the date on which the contract will next be automatically invoiced; it advances automatically each time the contract is invoiced. `InvoicedPeriod` is the period the next invoice will cover. For a new contract these two dates are usually the same. If `Tariff.AdvanceInvoiceCycles` is greater than 1, Nexudus invoices several periods in one go the first time, pushing `InvoicedPeriod` ahead of `RenewalDate` from the first invoice onwards. When the contract is cancelled, Nexudus stops invoicing once `InvoicedPeriod` reaches the cancellation date.

**Benefits** — The plan may include benefits (booking credits, time passes, etc.) which are released and assigned to the contract-holder customer based on the contract cycle or other expiration criteria (month, week, day, etc.).

**Cancellation** — Contracts support minimum contract length (`ContractTerm`), cancellation policies (`CancellationLimitDays`, `ProRateCancellation`) and cancellation reasons. `CancelTeamContracts` can cascade cancellation to team members.

**Additional charges** — Contracts can optionally include products (`ContractProduct` entities) to be billed alongside the plan, as well as security deposits/retainers (`ContractDeposit` entities).

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

## Enums

<Accordion title="eCancellationReason">
  | Value | Name                     |
  | ----- | ------------------------ |
  | 1     | PriceTooHigh             |
  | 2     | NewJobRelocation         |
  | 3     | MovedToOtherSpace        |
  | 4     | ChangeWorkEnvironment    |
  | 5     | LackCommunityInterations |
  | 6     | PoorSpaceCondition       |
  | 7     | OtherMembers             |
  | 8     | Rellocated               |
  | 9     | BusinessExpansion        |
  | 10    | Pause                    |
  | 11    | Renewed                  |
  | 12    | Upgraded                 |
  | 13    | Downgraded               |
  | 19    | Covid19                  |
  | 99    | Other                    |
</Accordion>

<Accordion title="eDeliveryHandlingPreference">
  | Value | Name                       |
  | ----- | -------------------------- |
  | 1     | StoreForCollection         |
  | 2     | Forward                    |
  | 3     | OpenScanForward            |
  | 4     | OpenScanRecycle            |
  | 5     | OpenScanShred              |
  | 6     | OpenScanStoreForCollection |
  | 7     | Recycle                    |
  | 8     | ReturnToSender             |
  | 9     | Shred                      |
  | 10    | DepositCheck               |
  | 11    | Unknown                    |
</Accordion>

## Request Body

### Required Fields

<ParamField body="IssuedById" type="integer" required>
  Issued By Id.
</ParamField>

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

<ParamField body="TariffId" type="integer" required>
  Tariff Id.
</ParamField>

<ParamField body="BillingDay" type="integer" required>
  Day of month on which billing occurs.
</ParamField>

<ParamField body="Quantity" type="integer" required>
  Quantity.
</ParamField>

### Optional Fields

<ParamField body="NextTariffId" type="integer">
  Next Tariff Id.
</ParamField>

<ParamField body="Notes" type="string">
  Free-text notes for this contract.
</ParamField>

<ParamField body="StartDate" type="string">
  Contract start date.
</ParamField>

<ParamField body="RenewalDate" type="string">
  Date on which the contract will next be automatically invoiced. Updated automatically every time the contract is invoiced, advancing by the plan's renewal period.
</ParamField>

<ParamField body="InvoicedPeriod" type="string">
  Period the next invoice will cover. For new contracts this equals RenewalDate. If Tariff.AdvanceInvoiceCycles > 1, Nexudus invoices several periods at once on the first invoice, pushing InvoicedPeriod ahead of RenewalDate. Nexudus stops invoicing when InvoicedPeriod reaches the cancellation date.
</ParamField>

<ParamField body="ContractTerm" type="string">
  Minimum contract length end date. Defines the earliest date at which the contract can be cancelled without penalty.
</ParamField>

<ParamField body="Price" type="number">
  Fixed price override for this contract. If null, the contract uses the plan's default price (TariffPrice).
</ParamField>

<ParamField body="Value" type="number">
  Contract value used in reporting to compare against the actual invoiced price.
</ParamField>

<ParamField body="Desks" type="integer[]">
  Desks.
</ParamField>

<ParamField body="Variants" type="integer[]">
  Variants.
</ParamField>

<ParamField body="PurchaseOrder" type="string">
  Purchase order.
</ParamField>

<ParamField body="IncludeSignupFee" type="boolean">
  Whether to include the plan's signup fee when creating this contract.
</ParamField>

<ParamField body="InvoiceAdvancedCycles" type="boolean">
  Whether to invoice multiple billing cycles in advance on the first invoice, as configured by Tariff.AdvanceInvoiceCycles.
</ParamField>

<ParamField body="ApplyProRating" type="boolean">
  Whether to pro-rate the first invoice based on the contract start date relative to the billing cycle.
</ParamField>

<ParamField body="NextAutoInvoice" type="string">
  Date of the next automatic invoice generation for this contract.
</ParamField>

<ParamField body="PricePlanTermsAccepted" type="boolean">
  Whether the customer has accepted the plan's terms and conditions.
</ParamField>

<ParamField body="CancellationDate" type="string">
  Date on which the contract will be cancelled. Nexudus stops invoicing when InvoicedPeriod reaches this date.
</ParamField>

<ParamField body="CancellationLimitDays" type="integer">
  Minimum number of days' notice required before cancellation takes effect.
</ParamField>

<ParamField body="ProRateCancellation" type="boolean">
  Whether to pro-rate the final invoice when the contract is cancelled mid-cycle.
</ParamField>

<ParamField body="CancelTeamContracts" type="boolean">
  Whether to cascade cancellation to contracts of team members under this customer.
</ParamField>

<ParamField body="CancellationReason" type="integer">
  Reason for cancellation. See `eCancellationReason?` enum above.
</ParamField>

<ParamField body="CancellationNotes" type="string">
  Free-text notes about the cancellation.
</ParamField>

<ParamField body="DeliveryHandlingPreferenceChecks" type="integer">
  Delivery handling preference for checks. See `eDeliveryHandlingPreference?` enum above.
</ParamField>

<ParamField body="DeliveryHandlingPreferenceMail" type="integer">
  Delivery handling preference for mail. See `eDeliveryHandlingPreference?` enum above.
</ParamField>

<ParamField body="DeliveryHandlingPreferenceParcels" type="integer">
  Delivery handling preference for parcels. See `eDeliveryHandlingPreference?` enum above.
</ParamField>

<ParamField body="DeliveryHandlingPreferencePublicity" type="integer">
  Delivery handling preference for publicity. See `eDeliveryHandlingPreference?` enum above.
</ParamField>

<ParamField body="DeliveryInstructions" type="string">
  Free-text delivery instructions for this contract's mail handling.
</ParamField>

<ParamField body="IdentityChecksDueOn" type="string">
  Date by which identity verification checks must be completed for this contract.
</ParamField>

<ParamField body="AddressChecksDueOn" type="string">
  Date by which address verification checks must be completed for this contract.
</ParamField>

<ParamField body="StartDateLocal" type="string">
  Start Date Local.
</ParamField>

<ParamField body="RenewalDateLocal" type="string">
  Renewal Date Local.
</ParamField>

<ParamField body="NextAutoInvoiceLocal" type="string">
  Next Auto Invoice Local.
</ParamField>

<ParamField body="PricePlanTermsAcceptedOnLocal" type="string">
  Price Plan Terms Accepted On Local.
</ParamField>

<ParamField body="CancellationDateLocal" type="string">
  Cancellation Date Local.
</ParamField>

<ParamField body="ContractTermLocal" type="string">
  Contract Term Local.
</ParamField>

<ParamField body="InvoicedPeriodLocal" type="string">
  Invoiced Period Local.
</ParamField>

<ParamField body="PoBoxNumber" type="string">
  PO box number.
</ParamField>

### Children

<ParamField body="ContractSchedules" type="object[]">
  Scheduled future price changes for this contract. Each entry sets a new Price to apply on a given date

  <Expandable>
    <ParamField body="Price" type="number">
      The new contract price to apply on the scheduled date.
    </ParamField>

    <ParamField body="ApplyOn" type="string" required>
      Date on which the system will automatically update the contract price to the value in Price.
    </ParamField>
  </Expandable>
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/billing/coworkercontracts" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "IssuedById": 0,
      "CoworkerId": 0,
      "TariffId": 0,
      "BillingDay": 0,
      "Quantity": 0,
      "ContractSchedules": [
          {
              "Price": null,
              "ApplyOn": "2025-01-15T10:30:00Z"
          }
      ]
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/billing/coworkercontracts',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        IssuedById: 0,
        CoworkerId: 0,
        TariffId: 0,
        BillingDay: 0,
        Quantity: 0,
        ContractSchedules: [object Object]
      })
    }
  );

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

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

  response = requests.post(
      'https://spaces.nexudus.com/api/billing/coworkercontracts',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'IssuedById': 0,
          'CoworkerId': 0,
          'TariffId': 0,
          'BillingDay': 0,
          'Quantity': 0,
          'ContractSchedules': [object Object]
      }
  )

  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 coworkercontract was created successfully.
</ResponseField>

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

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