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

# Create bookings in DATEV Rechnungswesen

> Easily create journal entries in DATEV for accounting and tax purposes

## Create journal entries in Datev in 10 steps

**Required**: Before getting started, ensure that your end users have the `Belegbilderservice` and `Buchungsdatenservice` enabled in their DATEV accounts

<Steps>
  <Step title="Authorize end user" titleSize="h3">
    Your end user must first authorize your application to access their data in DATEV Rechnungswesen through [maesn Connect](/guides/maesn-connect).
  </Step>

  <Step title="Retrieve companies" titleSize="h3">
    Fetch all the companies associated to your end users's DATEV account using the GET [/companies](/api-reference/auth/get-companies) endpoint. The user will need to select a company to proceed, as the company ID will be needed for subsequent steps.
    Note that you can use the [interactive authentication flow](/authentication#interactive-authentication-flow) to eliminate this step.
  </Step>

  <Step title="Get user info (optional)" titleSize="h3">
    Fetch the user info associated to your end users's DATEV account using the GET [/userInfo](/api-reference/user-endpoints/user/user-info) endpoint. Display the retrieved information in your application's UI as required by DATEV (see 'general requirements' below).
  </Step>

  <Step title="Decide your path" titleSize="h3">
    At this point, determine whether your use case requires attaching files (e.g. PDFs) to the journal entries data:

    <ul>
      <li><strong>If yes</strong>, proceed with the steps below to fetch document-related data and upload files.</li>
      <li><strong>If not</strong>, skip directly to the "Create journal entries" step below.</li>
    </ul>
  </Step>

  <Step title="Retrieve document types (optional)" titleSize="h3">
    Fetch the relevant document types from your end users's DATEV account using the GET [/documentTypes](/api-reference/accounting-endpoints/files/get-document-types) endpoint. The document types will be used to categorize the files you will upload. These may, for example, be presented to the end user as a drop-down menu at the point of file upload.
    <ul> <strong>IMPORTANT</strong>: it is sufficient to call the endpoint once per user, as the document types are not expected to change frequently.</ul>
  </Step>

  <Step title="Check document extensions (optional)" titleSize="h3">
    If necessary, confirm the file extensions supported by the selected end user company (Mandant) by calling the GET [/documentExtensions](/api-reference/accounting-endpoints/files/get-document-extensions).
    <ul> <strong>IMPORTANT</strong>: like in the step above, this endpoint should be called only once per user.</ul>
  </Step>

  <Step title="Upload the document (optional)" titleSize="h3">
    Upload the document to DATEV using the POST [/files](/api-reference/accounting-endpoints/files/upload-file) endpoint and save the <strong> retrieved file id </strong>. Make sure to include all the required fields in the request body. Ensure your application checks the file size before uploading to avoid performance issues (see last step).
  </Step>

  <Step title="Create journal entries" titleSize="h3">
    Create the journal entries list and upload it to Rechnungswesen using the POST [/journalEntries](/api-reference/accounting-endpoints/journalentries/create-journal-entries-bulk) endpoint. Make sure to include all the required fields in the request body. You can include the <strong>document id</strong> of the uploaded document in the request.
  </Step>

  <Step title="Check status" titleSize="h3">
    Check the status of the journal entries list using the GET [/asyncTask](/api-reference/accounting-endpoints/asynctask) endpoint. This will allow you to verify if the batch was successfully processed by DATEV.
    Read more about asynchronous tasks [here](/async-task)
  </Step>

  <Step title="Check DATEV general requirements" titleSize="h3">
    Review the DATEV interface [requirements](https://developer.datev.de/en/guides/interface-requirements) to ensure that your application complies with DATEV’s specifications.
  </Step>
</Steps>

Optional:

<Steps>
  <Step title="Delete end user" stepNumber="0" titleSize="h3">
    If your user deletes their account, you may delete the end user from our API and revoke their token using the the POST [/delete-end-users](/api-reference/accounting-endpoints/tenants/delete-end-user). This step ensures both actions are handled on the backend.
  </Step>
</Steps>
