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

> Create a new CoworkerLedgerEntry record.

A CoworkerLedgerEntry, shown as a ledger entry, records a payment, charge, credit, or adjustment in a customer's financial ledger for a location and can be applied to an 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 **`CoworkerLedgerEntry-Create`** role.
</Note>

## Enums

<Accordion title="ePaymentProvider">
  | Value | Name |
  | - | - |
  | 1 | PayPalStandard |
  | 2 | PaypalStandardSubscription |
  | 3 | GoCardless |
  | 4 | Stripe |
  | 5 | AuthorizeNetDirect |
  | 6 | UsaEPay |
  | 7 | AuthorizeNetSubscription |
  | 8 | Adyen |
  | 9 | MultiGateway |
  | 11 | Manual |
  | 12 | Forte |
  | 13 | PayPalAdaptive |
  | 14 | GoCardlessPro |
  | 15 | CreditCard |
  | 16 | EPay |
  | 17 | Braintree |
  | 18 | MidTrans |
  | 19 | EziDebit |
  | 20 | LiqPay |
  | 21 | RazorPay |
  | 22 | SquareCash |
  | 23 | SquareCreditCard |
  | 24 | StripeACH |
  | 25 | StripeDirectDebit |
  | 26 | IZettleCreditCard |
  | 27 | PeachPayments |
  | 28 | Klarna |
  | 29 | StripeTerminal |
  | 30 | PayPalStandardRest |
  | 401 | HostedPaymentPage1 |
  | 402 | HostedPaymentPage2 |
  | 403 | HostedPaymentPage3 |
  | 500 | Xero |
  | 501 | Quickbooks |
  | 986 | VirtualCard |
  | 987 | PosTerminal |
  | 988 | BankDraft |
  | 989 | ManualDirectDebit |
  | 990 | BadDebt |
  | 991 | CreditCardManual1 |
  | 992 | CreditCardManual2 |
  | 993 | CreditCardManual3 |
  | 994 | Credit |
  | 995 | Gift |
  | 996 | Bank |
  | 997 | Cash |
  | 998 | Check |
  | 999 | Other |
</Accordion>

## Request Body

### Required Fields

<ParamField body="BusinessId" type="integer" required>
  ID of the location that owns this ledger entry..
</ParamField>

<ParamField body="CoworkerId" type="integer" required>
  ID of the customer whose ledger contains this entry..
</ParamField>

<ParamField body="Description" type="string" required>
  Required free-text explanation of the payment, charge, credit, or adjustment..
</ParamField>

<ParamField body="Code" type="string" required>
  Required ledger reference code; payment and invoice workflows commonly generate codes such as PAYM-, CASH-, CRED-, REFD-, or INVC-..
</ParamField>

<ParamField body="Debit" type="number" required>
  Debit amount in the location currency, rounded to two decimal places when saved; positive debits are invoice charges and negative debits are credit notes. Debit and Credit are mutually exclusive, so set the other amount to zero..
</ParamField>

<ParamField body="Credit" type="number" required>
  Credit amount in the location currency, rounded to two decimal places when saved; positive credits are received payments and negative credits are refunded payments. Credit and Debit are mutually exclusive, so set the other amount to zero..
</ParamField>

### Optional Fields

<ParamField body="CoworkerInvoiceId" type="integer">
  Optional ID of the invoice this payment, charge, or credit is applied to..
</ParamField>

<ParamField body="PaymentGatewayName" type="integer">
  Payment provider or payment method for this transaction; choosing a connected gateway such as Stripe or Spreedly attempts to collect payment and creation can fail if collection fails. Manual payments cannot use GoCardless, GoCardlessPro, StripeDirectDebit, Xero, Forte, or StripeACH.. See `ePaymentProvider?` enum above.
</ParamField>

<ParamField body="PaymentMethodNumber" type="string">
  Payment-method detail supplied by the payment processor; hidden because it can contain sensitive payment information..
</ParamField>

<ParamField body="TransactionDate" type="string">
  Date and time of the transaction in UTC; defaults to the current UTC time when omitted and cannot be before the location billing lock date..
</ParamField>

<ParamField body="Billed" type="boolean">
  Internal flag tracking whether Nexudus has billed this transaction to the operator; hidden because it is managed by billing workflows..
</ParamField>

<ParamField body="TransactionDateLocal" type="string">
  Internal localized copy of TransactionDate derived using the owning location's time zone; hidden because TransactionDate is the supported input..
</ParamField>

<ParamField body="ConnectedTransactionGuid" type="string">
  Internal identifier linking related ledger transactions so that deletion can reverse the connected payment; hidden because it is managed by payment workflows..
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/billing/coworkerledgerentries" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "BusinessId": 0,
      "CoworkerId": 0,
      "Description": "",
      "Code": "",
      "Debit": 0,
      "Credit": 0
  }'
  ```

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

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

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

  response = requests.post(
      'https://spaces.nexudus.com/api/billing/coworkerledgerentries',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'BusinessId': 0,
          'CoworkerId': 0,
          'Description': '',
          'Code': '',
          'Debit': 0,
          'Credit': 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 coworkerledgerentry was created successfully.
</ResponseField>

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

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


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