> ## Documentation Index
> Fetch the complete documentation index at: https://api-doc.fidly.be/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Journal

> Create an accounting journal of the company.

`code`, `category` and `sequence_scope` are fixed at creation and cannot be changed later.
Setting `is_default` demotes the previous default journal of the same category. A journal
created as the default must be active (`422 default_journal_required` otherwise): it is
the journal documents of its category are booked in when none is specified.

In sandbox mode the body is validated exactly as in live mode but nothing is stored, so
the returned `id` is not resolvable.



## OpenAPI

````yaml /openapi.json post /journals
openapi: 3.1.0
info:
  title: Fidly API
  version: 1.0.0
servers:
  - url: https://api.fidly.be
    description: Production
security: []
paths:
  /journals:
    post:
      tags:
        - journals
      summary: Create Journal
      description: >-
        Create an accounting journal of the company.


        `code`, `category` and `sequence_scope` are fixed at creation and cannot
        be changed later.

        Setting `is_default` demotes the previous default journal of the same
        category. A journal

        created as the default must be active (`422 default_journal_required`
        otherwise): it is

        the journal documents of its category are booked in when none is
        specified.


        In sandbox mode the body is validated exactly as in live mode but
        nothing is stored, so

        the returned `id` is not resolvable.
      operationId: create_journal_journals_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JournalCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JournalOut'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    JournalCreate:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
          description: Name of the journal.
        code:
          type: string
          maxLength: 45
          minLength: 1
          title: Code
          description: >-
            Short code, used as a prefix in the numbering. Must be unique within
            the company (case-insensitive): two journals sharing it would number
            two documents alike. Not editable afterwards.
        category:
          type: string
          title: Category
          description: >-
            What the journal holds. One of ['sales_invoice', 'sales_credit',
            'purchases_invoice', 'purchases_credit', 'incoming_sales',
            'incoming_purchases']. Not editable afterwards.
        is_default:
          type: boolean
          title: Is Default
          description: >-
            Makes this the default journal of its category. Setting it demotes
            the previous default of the same category in the same operation. A
            default journal must be active.
          default: false
        active:
          type: boolean
          title: Active
          description: Whether the journal is enabled.
          default: true
        start_number:
          anyOf:
            - type: integer
            - type: 'null'
          title: Start Number
          description: First number of the numbering sequence.
        numbering_format:
          type: string
          maxLength: 255
          title: Numbering Format
          description: >-
            Template applied when numbering a document. must look like
            '{code}-{year4}-{seq:5}': '{code}', a separator ('-' or '/'), one or
            more of the tokens {year4}, {year2}, {month}, {fys4}, {fys2},
            {fye4}, {fye2}, {fy4}, {fy2}, the same kind of separator, then
            '{seq:N}' with N a single digit 2-8.
          default: '{code}-{year4}-{seq:5}'
        sequence_scope:
          type: string
          title: Sequence Scope
          description: >-
            How often the numbering restarts. One of ['never', 'monthly',
            'calendar-year', 'fiscal-year']. Not editable afterwards.
          default: never
        bank_account_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Bank Account Id
          description: Opaque id of a bank account of the company to tie to this journal.
      additionalProperties: false
      type: object
      required:
        - name
        - code
        - category
      title: JournalCreate
      description: >-
        A journal to create. `name`, `code` and `category` identify it;
        everything else has a

        default. `code` and `category` cannot be changed afterwards (they drive
        the numbering and

        the kind of document the journal holds), so choose them carefully here.
    JournalOut:
      properties:
        id:
          type: string
          title: Id
          description: Opaque unique identifier of the journal.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Name of the journal.
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: Short code of the journal, used as a prefix in the numbering.
        category:
          type: string
          title: Category
          description: >-
            What the journal holds. One of: `sales_invoice`, `sales_credit`,
            `purchases_invoice`, `purchases_credit`, `incoming_sales`,
            `incoming_purchases`. A few legacy incoming journals with no
            direction are returned as plain `incoming`.
        is_default:
          type: boolean
          title: Is Default
          description: '`true` when this is the journal used by default for its category.'
        active:
          type: boolean
          title: Active
          description: '`false` when the journal is disabled and no longer used.'
        start_number:
          anyOf:
            - type: integer
            - type: 'null'
          title: Start Number
          description: First number of the numbering sequence.
        numbering_format:
          anyOf:
            - type: string
            - type: 'null'
          title: Numbering Format
          description: Template applied when numbering a document of this journal.
        sequence_scope:
          type: string
          title: Sequence Scope
          description: >-
            How often the numbering restarts: `never`, `monthly`,
            `calendar-year` or `fiscal-year`. A legacy journal carrying a value
            the numbering does not recognise comes out as `unknown` (and is
            numbered as `never`).
        bank_account_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Bank Account Id
          description: >-
            Opaque id of the bank account tied to this journal, resolvable
            through `GET /bank-accounts/{id}`. `null` when the journal has no
            bank account.
      additionalProperties: true
      type: object
      required:
        - id
        - name
        - code
        - category
        - is_default
        - active
        - start_number
        - numbering_format
        - sequence_scope
        - bank_account_id
      title: JournalOut
      description: >-
        An accounting journal of the company, identified by an opaque `id`.


        A journal groups documents of one kind and drives their numbering.
        `bank_account_id` only

        carries a value on the journals it applies to, and is `null` elsewhere.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````