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

> Create a new FinancialAccount record.

A **FinancialAccount** represents a bookkeeping account used for categorising revenue and payments.

Financial accounts can be assigned to Products, EventProducts, TimePasses, ExtraServices (resource prices), Tariffs and Charges to control how income is tracked and reported.

Each account has a `Code` (typically matching an external accounting system reference), a `Name`, and an `AccountType` that determines where it appears:

| AccountType | Value | Purpose                                      |
| ----------- | ----- | -------------------------------------------- |
| Sales       | 1     | Revenue from products, services and bookings |
| Payments    | 2     | Incoming payment receipts                    |
| Deposits    | 3     | Security deposits held against contracts     |

**Important:** Changing a financial account's details or reassigning it to different items has no effect on existing invoices. The financial account recorded on each invoice line is captured at the time the invoice is issued and is never updated retroactively.

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

## Enums

<Accordion title="eFinancialAccountType — AccountType values">
  | Value | Name     |
  | ----- | -------- |
  | 0     | None     |
  | 1     | Sales    |
  | 2     | Payments |
  | 3     | Deposits |
</Accordion>

## Request Body

### Required Fields

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

<ParamField body="Name" type="string" required>
  Display name for this financial account.
</ParamField>

<ParamField body="Code" type="string" required>
  Short reference code, typically matching the account code in an external accounting system.
</ParamField>

<ParamField body="AccountType" type="integer" required>
  Category of the account: Sales (1), Payments (2) or Deposits (3). Defaults to `eFinancialAccountType.Sales`.
</ParamField>

### Optional Fields

<ParamField body="Description" type="string">
  Optional free-text description of the account's purpose.
</ParamField>

## Code Examples

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

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

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

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

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

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

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "FinancialAccount 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
}
```
