> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infinity.swiss/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an account

> Adds an account to the chart of accounts. The account is created in the earliest open fiscal year and carried forward into the fiscal years that follow it, so that it becomes part of the current chart of accounts.

## Creating an account

Accounts are created by account number. For example, the following payload adds an expense account for electricity:

```json theme={null}
{
  "number": 6410,
  "name": "Electricity",
  "description": "Power for the workshop",
  "colour": "#0746c8"
}
```

The account type is inferred from the account number according to the Swiss chart of accounts for SMEs, unless you provide a `type` explicitly. Account numbers 1000–1999 are assets, 2000–2999 liabilities, 3000–3999 income and 4000–6999 expenses; the ranges 7000–8999 contain both income and expense accounts.

The new account becomes part of the [current chart of accounts](/api/accounting/accounts/find): it is created in the earliest open fiscal year and carried forward into the fiscal years that follow it.

## Foreign currency accounts

To create a bank account in a foreign currency, pass its `currency`. Foreign currency accounts are only allowed in the liquid assets range 1000–1099, and the currency must be enabled in the organisation.


## OpenAPI

````yaml POST /v1/accounts
openapi: 3.1.0
info:
  title: infinity.swiss Open API
  version: '1.0'
  summary: ''
servers:
  - url: https://api.infinity.swiss
security:
  - apiKey: []
paths:
  /v1/accounts:
    post:
      tags: []
      summary: Create an account
      description: >-
        Adds an account to the chart of accounts. The account is created in the
        earliest open fiscal year and carried forward into the fiscal years that
        follow it, so that it becomes part of the current chart of accounts.
      operationId: create-account-v1
      requestBody:
        description: Provide the account to create.
        content:
          application/json:
            schema:
              type: object
              x-examples:
                Example 1:
                  number: 6410
                  name: Electricity
                  description: Power for the workshop
                  colour: '#0746c8'
              required:
                - number
                - name
              properties:
                number:
                  type: integer
                  minimum: 1000
                  maximum: 9999
                  description: The four-digit account number. Must not be taken yet.
                  example: 6410
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: The name of the account.
                  example: Electricity
                type:
                  type: string
                  enum:
                    - assets
                    - liabilities
                    - income
                    - expense
                  description: >-
                    The type of the account. If omitted, the type is inferred
                    from the account number according to the Swiss chart of
                    accounts for SMEs (e.g. 1000–1999 are assets, 2000–2999
                    liabilities, 3000–3999 income, 4000–6999 expenses).
                description:
                  type: string
                  maxLength: 500
                  description: An optional description of what is booked to this account.
                colour:
                  type: string
                  pattern: ^#[0-9a-fA-F]{6}$
                  description: >-
                    An optional hex colour code used to display the account in
                    the app.
                  example: '#0746c8'
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                  description: >-
                    The 3-character currency code (ISO 4217) for a foreign
                    currency account. Only allowed for liquid assets accounts
                    1000–1099, and must be a currency that is enabled in the
                    organisation. Defaults to `CHF`.
                  example: EUR
      responses:
        '201':
          description: The account was created successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - account
                properties:
                  account:
                    $ref: '#/components/schemas/Account'
        '400':
          description: A bad request is thrown if the provided account is invalid.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                properties:
                  code:
                    type: string
                    description: >-
                      The specific error code for this request.

                      May be:

                      - `general/missing-fields`

                      - `accounts/foreign-currency-not-allowed-for-range` if a
                      currency other than CHF is requested for an account
                      outside of the liquid assets range 1000–1099
                  invalidFields:
                    type: array
                    uniqueItems: true
                    description: A list of the fields which were invalid, if applicable.
                    items:
                      type: string
                      example: colour
        '401':
          $ref: '#/components/responses/Unauthorised'
        '404':
          description: >-
            A 404 error is received when the organisation has no open fiscal
            year to create the account in, or when the requested currency is not
            enabled in the organisation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `fiscal-year/not-found`
                      - `currency/not-found`
        '409':
          description: An account with this account number already exists.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `ledger/account-already-exists`
components:
  schemas:
    Account:
      title: Account
      type: object
      description: >-
        An account of the chart of accounts. Accounts are identified by their
        account number.
      required:
        - number
        - name
        - type
        - currency
        - isSystemAccount
        - isTaxApplicable
      properties:
        number:
          type: integer
          minimum: 1000
          maximum: 9999
          description: The four-digit account number.
          example: 1020
        name:
          type: string
          description: The name of the account.
          example: Bank
        type:
          type: string
          enum:
            - assets
            - liabilities
            - income
            - expense
          description: The type of the account.
        description:
          type: string
          description: >-
            A description of what is booked to this account, if one was
            provided.
        colour:
          type: string
          description: >-
            The hex colour code used to display the account in the app, if one
            was set.
          example: '#0746c8'
        currency:
          type: string
          description: >-
            The 3-character currency code (ISO 4217) of the account. `CHF`
            unless the account is a foreign currency account.
          example: CHF
        isSystemAccount:
          type: boolean
          description: >-
            Whether Infinity relies on this account, e.g. for VAT. System
            accounts cannot be deleted.
        isTaxApplicable:
          type: boolean
          description: >-
            Whether ledger entries booked to this account may carry a VAT tax
            code.
  responses:
    Unauthorised:
      description: >-
        An unauthorised request was submitted. You may be using an incorrect or
        expired API token, or are attempting to access a document outside of the
        scope of the token.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                x-stoplight:
                  id: 08hkw8ukmi2lp
                description: Specific error code
          examples:
            Unauthorised request:
              value:
                code: general/unauthorised
  securitySchemes:
    apiKey:
      name: x-api-token
      type: apiKey
      in: header
      description: >-
        API token for authentication. Obtain from your Infinity account
        settings.

````