# Create Journal Entry

> **Accounting API** · `POST /accounting/journal-entries`
> Canonical URL: https://developers.apideck.com/apis/accounting/reference#tag/Journal-Entries/operation/journalEntriesAdd
> MCP tool: `accounting-journal-entries-add`

## Authentication

- Send `Authorization: Bearer $API_KEY` using your Apideck secret API key. Keep the key server-side; never put it in a URL or client-side code.

Use the application, consumer and connector headers listed in Parameters below for this operation.

## Learn more

- [Journal entry explained](https://developers.apideck.com/glossary#journal-entry)
- [General ledger explained](https://developers.apideck.com/glossary#general-ledger)
- [Build a payroll journal workflow](https://developers.apideck.com/guides/payroll-journal-entries)

Create Journal Entry

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `raw` | query | `boolean` | No | Include raw response. Mostly used for debugging purposes |
| `x-apideck-consumer-id` | header | `string` | Yes | ID of the consumer which you want to get or push data from |
| `x-apideck-app-id` | header | `string` | Yes | The ID of your Unify application |
| `x-apideck-service-id` | header | `string` | No | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. |
| `x-apideck-company-id` | header | `string` | No | The ID of the company to scope requests to. For connectors that support multi-company, this overrides the default company configured in connection settings. |
| `idempotency-key` | header | `string` | No | A unique key you generate for one create or update, to make retrying it safe. If the request times out or fails with an uncertain outcome, resend it with the same key and the same body: the record is created, or the update applied, at most once. Keys are 1-255 printable ASCII characters (a UUID is recommended) and are accepted bare or as a quoted string. A key is remembered for 24 hours from its first use, or for the connector's own deduplication window where that is shorter (Xero: 6 minutes; Sage Intacct REST: 1 hour); after that, the same key is treated as a new request, so retry within the window. Some connectors also replay an error to retries with the same key: if retries keep returning the same error, check whether the record exists before sending it again with a new key. Reusing a key with a different body returns 422, and retrying while the first attempt is still running returns 409. A key is bound to its first request even if that request was rejected, so after fixing a rejected body, send it with a new key. Connectors that cannot honour the key on this operation reject the request with 400 instead of writing unprotected. |

### Request Body

_Required._

- `id` `string` — A unique identifier for an object. — example: `12345`
- `downstream_id` `string` — The third-party API ID of original entity — example: `12345`
- `display_id` `string` — Display ID of the journal entry — example: `12345`
- `title` `string` — Journal entry title — example: `Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry`
- `currency_rate` `number` — Currency Exchange Rate at the time entity was recorded/generated. — example: `0.69`
- `currency` `string` — Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). — enum: `UNKNOWN_CURRENCY`, `AED`, `AFN`, `ALL`, `AMD`, `ANG`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BGN`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYR`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HRK`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LTL`, `LVL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRO`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLL`, `SOS`, `SRD`, `SSP`, `STD`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRC`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `USS`, `UYI`, `UYU`, `UZS`, `VEF`, `VND`, `VUV`, `WST`, `XAF`, `XAG`, `XAU`, `XBA`, `XBB`, `XBC`, `XBD`, `XCD`, `XDR`, `XOF`, `XPD`, `XPF`, `XPT`, `XTS`, `XXX`, `YER`, `ZAR`, `ZMK`, `ZMW`, `BTC`, `ETH` — example: `USD`
- `company_id` `string` — The company ID the transaction belongs to — example: `12345`
- `subsidiary` `object`
  - `id` `string` — A unique identifier for an object. — example: `12345`
  - `display_id` `string` — Id to be displayed. — example: `123456`
  - `name` `string` — The name of the resource. — example: `Acme Inc.`
- `line_items` `array of object` — Requires a minimum of 2 line items that sum to 0
  - `id` `string` — A unique identifier for an object. — example: `12345`
  - `description` `string` — User defined description — example: `Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.`
  - `tax_amount` `number` — Tax amount — example: `27500`
  - `sub_total` `number` — Sub-total amount, normally before tax. — example: `27500`
  - `total_amount` `number` — Debit entries are considered positive, and credit entries are considered negative. — example: `27500`
  - `base_currency_amount` `number` — Amount for this line in the company's base currency. Used when the journal entry currency differs from the company's base currency. — example: `27500`
  - `type` `string` **required** — Debit entries are considered positive, and credit entries are considered negative. — enum: `debit`, `credit` — example: `debit`
  - `tax_rate` `object`
    - `id` `string` — The ID of the object. — example: `123456`
    - `code` `string` — Tax rate code — example: `N-T`
    - `name` `string` — Name of the tax rate — example: `GST on Purchases`
    - `rate` `number` — Rate of the tax rate — example: `10`
  - `tax_type` `string` — The tax applicability of this line item. Overrides the root-level tax_type for this line. — enum: `sales`, `purchase` — example: `sales`
  - `tracking_category` `object` **Deprecated.**
    - `id` `string` — The unique identifier for the tracking category. — example: `123456`
    - `name` `string` — The name of the tracking category. — example: `New York`
  - `tracking_categories` `array of object` — A list of linked tracking categories.
    - `id` `string` — The unique identifier for the tracking category. — example: `123456`
    - `code` `string` — The code of the tracking category. — example: `100`
    - `name` `string` — The name of the tracking category. — example: `New York`
    - `parent_id` `string` — The unique identifier for the parent tracking category. — example: `123456`
    - `parent_name` `string` — The name of the parent tracking category. — example: `New York`
  - `ledger_account` `object` **required**
    - `id` `string` — The unique identifier for the account. — example: `123456`
    - `name` `string` — The name of the account. — example: `Bank account`
    - `nominal_code` `string` — The nominal code of the account. — example: `N091`
    - `code` `string` — The code assigned to the account. — example: `453`
    - `parent_id` `string` — The parent ID of the account. — example: `123456`
    - `display_id` `string` — The display ID of the account. — example: `123456`
  - `customer` `object` — The customer this entity is linked to.
    - `id` `string` — The ID of the customer this entity is linked to. — example: `12345`
    - `display_id` `string` — The display ID of the customer. — example: `CUST00101`
    - `display_name` `string` — The display name of the customer. — example: `Windsurf Shop`
    - `name` `string` **Deprecated.** — The name of the customer. Deprecated, use display_name instead. — example: `Windsurf Shop`
    - `company_name` `string` — The company name of the customer. — example: `The boring company`
    - `email` `string` — The email address of the customer. — example: `boring@boring.com`
  - `supplier` `object` — The supplier this entity is linked to.
    - `id` `string` — The ID of the supplier this entity is linked to. — example: `12345`
    - `display_id` `string` — The display ID of the supplier. — example: `SUPP00101`
    - `display_name` `string` — The display name of the supplier. — example: `Windsurf Shop`
    - `company_name` `string` — The company name of the supplier. — example: `The boring company`
    - `address` `object`
      - `id` `string` — Unique identifier for the address. — example: `123`
      - `type` `string` — The type of address. — enum: `primary`, `secondary`, `home`, `office`, `shipping`, `billing`, `work`, `other` — example: `primary`
      - `string` `string` — The address string. Some APIs don't provide structured address data. — example: `25 Spring Street, Blackburn, VIC 3130`
      - `name` `string` — The name of the address. — example: `HQ US`
      - `line1` `string` — Line 1 of the address e.g. number, street, suite, apt #, etc. — example: `Main street`
      - `line2` `string` — Line 2 of the address — example: `apt #`
      - `line3` `string` — Line 3 of the address — example: `Suite #`
      - `line4` `string` — Line 4 of the address — example: `delivery instructions`
      - `line5` `string` — Line 5 of the address — example: `Attention: Finance Dept`
      - `street_number` `string` — Street number — example: `25`
      - `city` `string` — Name of city. — example: `San Francisco`
      - `state` `string` — Name of state — example: `CA`
      - `postal_code` `string` — Zip code or equivalent. — example: `94104`
      - `country` `string` — country code according to ISO 3166-1 alpha-2. — example: `US`
      - `latitude` `string` — Latitude of the address — example: `40.759211`
      - `longitude` `string` — Longitude of the address — example: `-73.984638`
      - `county` `string` — Address field that holds a sublocality, such as a county — example: `Santa Clara`
      - `contact_name` `string` — Name of the contact person at the address — example: `Elon Musk`
      - `salutation` `string` — Salutation of the contact person at the address — example: `Mr`
      - `phone_number` `string` — Phone number of the address — example: `111-111-1111`
      - `fax` `string` — Fax number of the address — example: `122-111-1111`
      - `email` `string` — Email address of the address — example: `elon@musk.com`
      - `website` `string` — Website of the address — example: `https://elonmusk.com`
      - `notes` `string` — Additional notes — example: `Address notes or delivery instructions.`
      - `row_version` `string` — A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. — example: `1-12345`
  - `employee` `object` — The employee this entity is linked to.
    - `id` `string` — A unique identifier for an object. — example: `12345`
    - `display_id` `string` — The display ID of the employee. For best performance, send this field (the employee number) instead of the GUID in the id field. — example: `EH`
    - `display_name` `string` — The display name of the employee. — example: `Ester Henderson`
  - `department_id` `string` — The ID of the department — example: `12345`
  - `location_id` `string` — The ID of the location — example: `12345`
  - `line_number` `integer` — Line number of the resource — example: `1`
  - `worktags` `array of object` — Worktags of the line item. This is currently only supported in Workday.
    - `id` `string` — The unique identifier for the worktag. — example: `123456`
    - `value` `string` — The value of the worktag. — example: `New York`
  - `date` `string` — The financial date of this specific line, when it differs from the journal entry's own posted_at date - for example when booking a historical or backdated transaction. Not populated by every connector: some post the entry date at the header level only, in which case this line-level date is legitimately absent rather than wrong. — format: `date` — example: `2020-09-30`
  - `source_id` `string` — A unique identifier for the source of this specific line, distinct from the journal entry's own source_id. Useful for reconciling an individual line back to an external system's own record when a single journal entry aggregates lines originating from more than one source. — example: `12345`
- `status` `string` — Journal entry status — enum: `draft`, `pending_approval`, `approved`, `posted`, `voided`, `rejected`, `deleted`, `other` — example: `draft`
- `memo` `string` — Reference for the journal entry. — example: `Thank you for your business and have a great day!`
- `posted_at` `string` — This is the date on which the journal entry was added. This can be different from the creation date and can also be backdated. — format: `date-time` — example: `2020-09-30T07:43:32.000Z`
- `journal_symbol` `string` — Journal symbol of the entry. For example IND for indirect costs. Where supported, list /accounting/journals to discover available journals and their posting rules. For Exact Online, supply the journal code, not its id. — example: `IND`
- `tax_type` `string` **Deprecated.** — Deprecated — use line_items[].tax_type for per-line tax applicability. Kept as fallback: applies to all lines that do not set their own tax_type. — example: `sales`
- `tax_code` `string` — Applicable tax id/code override if tax is not supplied on a line item basis. — example: `1234`
- `number` `string` — Journal entry number. — example: `OIT00546`
- `tracking_categories` `array of object` — A list of linked tracking categories.
  - `id` `string` — The unique identifier for the tracking category. — example: `123456`
  - `code` `string` — The code of the tracking category. — example: `100`
  - `name` `string` — The name of the tracking category. — example: `New York`
  - `parent_id` `string` — The unique identifier for the parent tracking category. — example: `123456`
  - `parent_name` `string` — The name of the parent tracking category. — example: `New York`
- `accounting_period` `string` — Accounting period — example: `01-24`
- `tax_inclusive` `boolean` — Amounts are including tax — example: `true`
- `attachments` `array of object` — Files attached to this journal entry. Use the attachments endpoints with reference_type=journal-entry and this entry's id where the connector supports it.
  - `name` `string` — The name of the file — example: `sample.jpg`
  - `mime_type` `string` — The MIME type of the file. — example: `image/jpeg`
  - `is_compressed` `boolean` — Whether the file is compressed. — example: `false`
  - `encoding` `string` — The encoding of the file. — example: `base64`
  - `content` `string` — The content of the file. — example: `data:image/jpeg;base64,...`
  - `notes` `string` — The notes of the file. — example: `A sample image`
- `source_type` `string` — The source type of the journal entry — example: `manual`
- `source_id` `string` — A unique identifier for the source of the journal entry — example: `12345`
- `custom_mappings` `object` — When custom mappings are configured on the resource, the result is included here.
- `updated_by` `string` — The user who last updated the object. — example: `12345`
- `created_by` `string` — The user who created the object. — example: `12345`
- `updated_at` `string` — The date and time when the object was last updated. — format: `date-time` — example: `2020-09-30T07:43:32.000Z`
- `created_at` `string` — The date and time when the object was created. — format: `date-time` — example: `2020-09-30T07:43:32.000Z`
- `row_version` `string` — A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. — example: `1-12345`
- `custom_fields` `array of object`
  - `id` `string` — Unique identifier for the custom field. — example: `2389328923893298`
  - `name` `string` — Name of the custom field. — example: `employee_level`
  - `ref_name` `string` — Display name of the record a reference-type custom field points at. `value` carries that record's id; this carries its human-readable name, so a consumer does not need a second lookup to render it. — example: `Marketing`
  - `description` `string` — More information about the custom field — example: `Employee Level`
  - `value` `string | number | boolean | object | array of string | number | boolean | object`
    - One of:
      - Option 1: string
      - Option 2: number
      - Option 3: boolean
      - Option 4: object

      - Option 5: array of string | number | boolean | object
- `pass_through` `array of object` — The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources.
  - `service_id` `string` **required** — Identifier for the service to which this pass_through should be applied.
  - `operation_id` `string` — Optional identifier for a workflow operation to which this pass_through should be applied. This is useful for Unify calls that are making more than one downstream request.
  - `extend_object` `object` — Simple object allowing any properties for direct extension.
  - `extend_paths` `array of object` — Array of objects for structured data modifications via paths.
    - `path` `string` **required** — JSONPath string specifying where to apply the value. — example: `$.nested.property`
    - `value` `any` **required** — The value to set at the specified path, can be any type.

### Responses

#### 201 — JournalEntries

- `status_code` `integer` **required** — HTTP Response Status Code — example: `201`
- `status` `string` **required** — HTTP Response Status — example: `Created`
- `service` `string` **required** — Apideck ID of service provider — example: `quickbooks`
- `resource` `string` **required** — Unified API resource name — example: `journal-entries`
- `operation` `string` **required** — Operation performed — example: `add`
- `data` `object` **required** — A object containing a unique identifier for the resource that was created, updated, or deleted.
  - `id` `string` **required** — The unique identifier of the resource — example: `12345`
- `_raw` `object` — Raw response from the integration when raw=true query param is provided

#### 400 — Bad Request

> Standard error response — see [Error Responses](https://developers.apideck.com/errors)

#### 401 — Unauthorized

> Standard error response — see [Error Responses](https://developers.apideck.com/errors)

#### 402 — Payment Required

> Standard error response — see [Error Responses](https://developers.apideck.com/errors)

#### 404 — The specified resource was not found

> Standard error response — see [Error Responses](https://developers.apideck.com/errors)

#### 422 — Unprocessable

> Standard error response — see [Error Responses](https://developers.apideck.com/errors)

#### default — Unexpected error

> Standard error response — see [Error Responses](https://developers.apideck.com/errors)

## SDK examples

Calls this operation with the official Apideck SDKs.

### TypeScript

Setup: [TypeScript SDK](https://developers.apideck.com/sdks/node.md)

```typescript
import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
  const result = await apideck.accounting.journalEntries.create({
    serviceId: "quickbooks",
    companyId: "12345",
    idempotencyKey: "your-unique-key-per-create",
    journalEntry: {
      title: "Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry",
      currencyRate: 0.69,
      currency: "USD",
      companyId: "12345",
      lineItems: [
        {
          description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
          taxAmount: 27500,
          subTotal: 27500,
          totalAmount: 27500,
          type: "debit",
          taxRate: {
            id: "123456",
            rate: 10,
          },
          trackingCategories: [
            {
              id: "123456",
              name: "New York",
            },
            {
              id: "123456",
              name: "New York",
            },
            {
              id: "123456",
              name: "New York",
            },
          ],
          ledgerAccount: {
            id: "123456",
            nominalCode: "N091",
            code: "453",
          },
          customer: {
            id: "12345",
            displayName: "Windsurf Shop",
            email: "boring@boring.com",
          },
          supplier: {
            id: "12345",
            displayName: "Windsurf Shop",
            address: {
              id: "123",
              type: "primary",
              string: "25 Spring Street, Blackburn, VIC 3130",
              name: "HQ US",
              line1: "Main street",
              line2: "apt #",
              line3: "Suite #",
              line4: "delivery instructions",
              streetNumber: "25",
              city: "San Francisco",
              state: "CA",
              postalCode: "94104",
              country: "US",
              latitude: "40.759211",
              longitude: "-73.984638",
              county: "Santa Clara",
              contactName: "Elon Musk",
              salutation: "Mr",
              phoneNumber: "111-111-1111",
              fax: "122-111-1111",
              email: "elon@musk.com",
              website: "https://elonmusk.com",
              notes: "Address notes or delivery instructions.",
              rowVersion: "1-12345",
            },
          },
          departmentId: "12345",
          locationId: "12345",
          lineNumber: 1,
        },
      ],
      status: "draft",
      memo: "Thank you for your business and have a great day!",
      postedAt: new Date("2020-09-30T07:43:32.000Z"),
      journalSymbol: "IND",
      taxType: "sales",
      taxCode: "1234",
      number: "OIT00546",
      trackingCategories: null,
      accountingPeriod: "01-24",
      rowVersion: "1-12345",
      customFields: [
        {
          id: "2389328923893298",
          name: "employee_level",
          description: "Employee Level",
          value: "Uses Salesforce and Marketo",
        },
      ],
      passThrough: [
        {
          serviceId: "<id>",
          extendPaths: [
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
          ],
        },
        {
          serviceId: "<id>",
          extendPaths: [
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
          ],
        },
        {
          serviceId: "<id>",
          extendPaths: [
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
            {
              path: "$.nested.property",
              value: {
                "TaxClassificationRef": {
                  "value": "EUC-99990201-V1-00020000",
                },
              },
            },
          ],
        },
      ],
    },
  });

  console.log(result);
}

run();
```

### Python

Setup: [Python SDK](https://developers.apideck.com/sdks/python.md)

```python
import apideck_unify
from apideck_unify import Apideck
from apideck_unify.utils import parse_datetime
from datetime import date
import os


with Apideck(
    consumer_id="test-consumer",
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:

    res = apideck.accounting.journal_entries.create(raw=False, service_id="quickbooks", company_id_param="12345", idempotency_key="your-unique-key-per-create", display_id="12345", title="Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry", currency_rate=0.69, currency=apideck_unify.Currency.USD, company_id="12345", subsidiary=None, line_items=[
        {
            "description": "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
            "tax_amount": 27500,
            "sub_total": 27500,
            "total_amount": 27500,
            "base_currency_amount": 27500,
            "type": apideck_unify.JournalEntryLineItemType.DEBIT,
            "tax_rate": {
                "id": "123456",
                "code": "N-T",
                "rate": 10,
            },
            "tax_type": apideck_unify.TaxType.SALES,
            "tracking_categories": [
                {
                    "id": "123456",
                    "code": "100",
                    "name": "New York",
                    "parent_id": "123456",
                    "parent_name": "New York",
                },
            ],
            "ledger_account": {
                "id": "123456",
                "name": "Bank account",
                "nominal_code": "N091",
                "code": "453",
                "parent_id": "123456",
                "display_id": "123456",
            },
            "customer": {
                "id": "12345",
                "display_name": "Windsurf Shop",
                "email": "boring@boring.com",
            },
            "supplier": {
                "id": "12345",
                "display_name": "Windsurf Shop",
                "address": {
                    "id": "123",
                    "type": apideck_unify.Type.PRIMARY,
                    "string": "25 Spring Street, Blackburn, VIC 3130",
                    "name": "HQ US",
                    "line1": "Main street",
                    "line2": "apt #",
                    "line3": "Suite #",
                    "line4": "delivery instructions",
                    "line5": "Attention: Finance Dept",
                    "street_number": "25",
                    "city": "San Francisco",
                    "state": "CA",
                    "postal_code": "94104",
                    "country": "US",
                    "latitude": "40.759211",
                    "longitude": "-73.984638",
                    "county": "Santa Clara",
                    "contact_name": "Elon Musk",
                    "salutation": "Mr",
                    "phone_number": "111-111-1111",
                    "fax": "122-111-1111",
                    "email": "elon@musk.com",
                    "website": "https://elonmusk.com",
                    "notes": "Address notes or delivery instructions.",
                    "row_version": "1-12345",
                },
            },
            "employee": {
                "id": "12345",
                "display_id": "EH",
                "display_name": "Ester Henderson",
            },
            "department_id": "12345",
            "location_id": "12345",
            "line_number": 1,
            "worktags": [
                {
                    "id": "123456",
                    "value": "New York",
                },
            ],
            "date_": date.fromisoformat("2020-09-30"),
            "source_id": "12345",
        },
    ], status=apideck_unify.JournalEntryStatus.DRAFT, memo="Thank you for your business and have a great day!", posted_at=parse_datetime("2020-09-30T07:43:32.000Z"), journal_symbol="IND", tax_code="1234", number="OIT00546", tracking_categories=None, accounting_period="01-24", tax_inclusive=True, attachments=[
        {
            "name": "sample.jpg",
            "mime_type": "image/jpeg",
            "is_compressed": False,
            "encoding": "base64",
            "content": "data:image/jpeg;base64,...",
            "notes": "A sample image",
        },
    ], source_type="manual", source_id="12345", row_version="1-12345", custom_fields=[
        {
            "id": "2389328923893298",
            "name": "employee_level",
            "ref_name": "Marketing",
            "description": "Employee Level",
            "value": "Uses Salesforce and Marketo",
        },
    ], pass_through=[
        {
            "service_id": "<id>",
            "extend_paths": [
                {
                    "path": "$.nested.property",
                    "value": {
                        "TaxClassificationRef": {
                            "value": "EUC-99990201-V1-00020000",
                        },
                    },
                },
            ],
        },
    ])

    assert res.create_journal_entry_response is not None

    # Handle response
    print(res.create_journal_entry_response)
```

### PHP

Setup: [PHP SDK](https://developers.apideck.com/sdks/php.md)

```php
declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;
use Apideck\Unify\Models\Operations;
use Apideck\Unify\Utils;

$sdk = Unify\Apideck::builder()
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Operations\AccountingJournalEntriesAddRequest(
    serviceId: 'quickbooks',
    companyId: '12345',
    idempotencyKey: 'your-unique-key-per-create',
    journalEntry: new Components\JournalEntryInput(
        title: 'Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry',
        currencyRate: 0.69,
        currency: Components\Currency::Usd,
        companyId: '12345',
        lineItems: [
            new Components\JournalEntryLineItemInput(
                description: 'Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.',
                taxAmount: 27500,
                subTotal: 27500,
                totalAmount: 27500,
                type: Components\JournalEntryLineItemType::Debit,
                taxRate: new Components\LinkedTaxRateInput(
                    id: '123456',
                    rate: 10,
                ),
                trackingCategories: [
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                    new Components\LinkedTrackingCategory(
                        id: '123456',
                        name: 'New York',
                    ),
                ],
                ledgerAccount: new Components\LinkedLedgerAccount(
                    id: '123456',
                    nominalCode: 'N091',
                    code: '453',
                ),
                customer: new Components\LinkedCustomerInput(
                    id: '12345',
                    displayName: 'Windsurf Shop',
                    email: 'boring@boring.com',
                ),
                supplier: new Components\LinkedSupplierInput(
                    id: '12345',
                    displayName: 'Windsurf Shop',
                    address: new Components\Address(
                        id: '123',
                        type: Components\Type::Primary,
                        string: '25 Spring Street, Blackburn, VIC 3130',
                        name: 'HQ US',
                        line1: 'Main street',
                        line2: 'apt #',
                        line3: 'Suite #',
                        line4: 'delivery instructions',
                        streetNumber: '25',
                        city: 'San Francisco',
                        state: 'CA',
                        postalCode: '94104',
                        country: 'US',
                        latitude: '40.759211',
                        longitude: '-73.984638',
                        county: 'Santa Clara',
                        contactName: 'Elon Musk',
                        salutation: 'Mr',
                        phoneNumber: '111-111-1111',
                        fax: '122-111-1111',
                        email: 'elon@musk.com',
                        website: 'https://elonmusk.com',
                        notes: 'Address notes or delivery instructions.',
                        rowVersion: '1-12345',
                    ),
                ),
                departmentId: '12345',
                locationId: '12345',
                lineNumber: 1,
            ),
        ],
        status: Components\JournalEntryStatus::Draft,
        memo: 'Thank you for your business and have a great day!',
        postedAt: Utils\Utils::parseDateTime('2020-09-30T07:43:32.000Z'),
        journalSymbol: 'IND',
        taxType: 'sales',
        taxCode: '1234',
        number: 'OIT00546',
        trackingCategories: null,
        accountingPeriod: '01-24',
        rowVersion: '1-12345',
        customFields: [
            new Components\CustomField1(
                id: '2389328923893298',
                name: 'employee_level',
                description: 'Employee Level',
                value: 'Uses Salesforce and Marketo',
            ),
        ],
        passThrough: [
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
            new Components\PassThroughBody(
                serviceId: '<id>',
                extendPaths: [
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                    new Components\ExtendPaths(
                        path: '$.nested.property',
                        value: [
                            'TaxClassificationRef' => [
                                'value' => 'EUC-99990201-V1-00020000',
                            ],
                        ],
                    ),
                ],
            ),
        ],
    ),
);

$response = $sdk->accounting->journalEntries->create(
    request: $request
);

if ($response->createJournalEntryResponse !== null) {
    // handle response
}
```

### Go

Setup: [Go SDK](https://developers.apideck.com/sdks/go.md)

```go
package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/models/components"
	"github.com/apideck-libraries/sdk-go/types"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
    )

    res, err := s.Accounting.JournalEntries.Create(ctx, operations.AccountingJournalEntriesAddRequest{
        ServiceID: sdkgo.Pointer("quickbooks"),
        CompanyID: sdkgo.Pointer("12345"),
        IdempotencyKey: sdkgo.Pointer("your-unique-key-per-create"),
        JournalEntry: components.JournalEntryInput{
            Title: sdkgo.Pointer("Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry"),
            CurrencyRate: sdkgo.Pointer[float64](0.69),
            Currency: components.CurrencyUsd.ToPointer(),
            CompanyID: sdkgo.Pointer("12345"),
            LineItems: []components.JournalEntryLineItemInput{
                components.JournalEntryLineItemInput{
                    Description: sdkgo.Pointer("Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection."),
                    TaxAmount: sdkgo.Pointer[float64](27500.0),
                    SubTotal: sdkgo.Pointer[float64](27500.0),
                    TotalAmount: sdkgo.Pointer[float64](27500.0),
                    Type: components.JournalEntryLineItemTypeDebit.ToPointer(),
                    TaxRate: &components.LinkedTaxRateInput{
                        ID: sdkgo.Pointer("123456"),
                        Rate: sdkgo.Pointer[float64](10.0),
                    },
                    TrackingCategories: []*components.LinkedTrackingCategory{
                        &components.LinkedTrackingCategory{
                            ID: sdkgo.Pointer("123456"),
                            Name: sdkgo.Pointer("New York"),
                        },
                        &components.LinkedTrackingCategory{
                            ID: sdkgo.Pointer("123456"),
                            Name: sdkgo.Pointer("New York"),
                        },
                        &components.LinkedTrackingCategory{
                            ID: sdkgo.Pointer("123456"),
                            Name: sdkgo.Pointer("New York"),
                        },
                    },
                    LedgerAccount: &components.LinkedLedgerAccount{
                        ID: sdkgo.Pointer("123456"),
                        NominalCode: sdkgo.Pointer("N091"),
                        Code: sdkgo.Pointer("453"),
                    },
                    Customer: &components.LinkedCustomerInput{
                        ID: sdkgo.Pointer("12345"),
                        DisplayName: sdkgo.Pointer("Windsurf Shop"),
                        Email: sdkgo.Pointer("boring@boring.com"),
                    },
                    Supplier: &components.LinkedSupplierInput{
                        ID: sdkgo.Pointer("12345"),
                        DisplayName: sdkgo.Pointer("Windsurf Shop"),
                        Address: &components.Address{
                            ID: sdkgo.Pointer("123"),
                            Type: components.TypePrimary.ToPointer(),
                            String: sdkgo.Pointer("25 Spring Street, Blackburn, VIC 3130"),
                            Name: sdkgo.Pointer("HQ US"),
                            Line1: sdkgo.Pointer("Main street"),
                            Line2: sdkgo.Pointer("apt #"),
                            Line3: sdkgo.Pointer("Suite #"),
                            Line4: sdkgo.Pointer("delivery instructions"),
                            StreetNumber: sdkgo.Pointer("25"),
                            City: sdkgo.Pointer("San Francisco"),
                            State: sdkgo.Pointer("CA"),
                            PostalCode: sdkgo.Pointer("94104"),
                            Country: sdkgo.Pointer("US"),
                            Latitude: sdkgo.Pointer("40.759211"),
                            Longitude: sdkgo.Pointer("-73.984638"),
                            County: sdkgo.Pointer("Santa Clara"),
                            ContactName: sdkgo.Pointer("Elon Musk"),
                            Salutation: sdkgo.Pointer("Mr"),
                            PhoneNumber: sdkgo.Pointer("111-111-1111"),
                            Fax: sdkgo.Pointer("122-111-1111"),
                            Email: sdkgo.Pointer("elon@musk.com"),
                            Website: sdkgo.Pointer("https://elonmusk.com"),
                            Notes: sdkgo.Pointer("Address notes or delivery instructions."),
                            RowVersion: sdkgo.Pointer("1-12345"),
                        },
                    },
                    DepartmentID: sdkgo.Pointer("12345"),
                    LocationID: sdkgo.Pointer("12345"),
                    LineNumber: sdkgo.Pointer[int64](1),
                },
            },
            Status: components.JournalEntryStatusDraft.ToPointer(),
            Memo: sdkgo.Pointer("Thank you for your business and have a great day!"),
            PostedAt: types.MustNewTimeFromString("2020-09-30T07:43:32.000Z"),
            JournalSymbol: sdkgo.Pointer("IND"),
            TaxType: sdkgo.Pointer("sales"),
            TaxCode: sdkgo.Pointer("1234"),
            Number: sdkgo.Pointer("OIT00546"),
            TrackingCategories: nil,
            AccountingPeriod: sdkgo.Pointer("01-24"),
            RowVersion: sdkgo.Pointer("1-12345"),
            CustomFields: []components.CustomField{
                components.CreateCustomFieldCustomField1(
                    components.CustomField1{
                        ID: sdkgo.Pointer("2389328923893298"),
                        Name: sdkgo.Pointer("employee_level"),
                        Description: sdkgo.Pointer("Employee Level"),
                        Value: sdkgo.Pointer(components.CreateCustomField1ValueStr(
                            "Uses Salesforce and Marketo",
                        )),
                    },
                ),
            },
            PassThrough: []components.PassThroughBody{
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CreateJournalEntryResponse != nil {
        // handle response
    }
}
```

### Java

Setup: [Java SDK](https://developers.apideck.com/sdks/java.md)

```java
package hello.world;

import com.apideck.unify.Apideck;
import com.apideck.unify.models.components.*;
import com.apideck.unify.models.errors.*;
import com.apideck.unify.models.operations.AccountingJournalEntriesAddRequest;
import com.apideck.unify.models.operations.AccountingJournalEntriesAddResponse;
import java.lang.Exception;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import org.openapitools.jackson.nullable.JsonNullable;

public class Application {

    public static void main(String[] args) throws BadRequestResponse, UnauthorizedResponse, PaymentRequiredResponse, NotFoundResponse, UnprocessableResponse, Exception {

        Apideck sdk = Apideck.builder()
                .consumerId("test-consumer")
                .appId("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX")
                .apiKey(System.getenv().getOrDefault("API_KEY", ""))
            .build();

        AccountingJournalEntriesAddRequest req = AccountingJournalEntriesAddRequest.builder()
                .journalEntry(JournalEntryInput.builder()
                    .title("Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry")
                    .currencyRate(0.69)
                    .currency(Currency.USD)
                    .companyId("12345")
                    .lineItems(List.of(
                        JournalEntryLineItemInput.builder()
                            .type(JournalEntryLineItemType.DEBIT)
                            .ledgerAccount(LinkedLedgerAccount.builder()
                                .id("123456")
                                .nominalCode("N091")
                                .code("453")
                                .build())
                            .description("Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.")
                            .taxAmount(27500d)
                            .subTotal(27500d)
                            .totalAmount(27500d)
                            .taxRate(LinkedTaxRateInput.builder()
                                .id("123456")
                                .rate(10d)
                                .build())
                            .trackingCategories(List.of(
                                LinkedTrackingCategory.builder()
                                    .id("123456")
                                    .name("New York")
                                    .build(),
                                LinkedTrackingCategory.builder()
                                    .id("123456")
                                    .name("New York")
                                    .build(),
                                LinkedTrackingCategory.builder()
                                    .id("123456")
                                    .name("New York")
                                    .build()))
                            .customer(LinkedCustomerInput.builder()
                                .id("12345")
                                .displayName("Windsurf Shop")
                                .email("boring@boring.com")
                                .build())
                            .supplier(LinkedSupplierInput.builder()
                                .id("12345")
                                .displayName("Windsurf Shop")
                                .address(Address.builder()
                                    .id("123")
                                    .type(Type.PRIMARY)
                                    .string("25 Spring Street, Blackburn, VIC 3130")
                                    .name("HQ US")
                                    .line1("Main street")
                                    .line2("apt #")
                                    .line3("Suite #")
                                    .line4("delivery instructions")
                                    .streetNumber("25")
                                    .city("San Francisco")
                                    .state("CA")
                                    .postalCode("94104")
                                    .country("US")
                                    .latitude("40.759211")
                                    .longitude("-73.984638")
                                    .county("Santa Clara")
                                    .contactName("Elon Musk")
                                    .salutation("Mr")
                                    .phoneNumber("111-111-1111")
                                    .fax("122-111-1111")
                                    .email("elon@musk.com")
                                    .website("https://elonmusk.com")
                                    .notes("Address notes or delivery instructions.")
                                    .rowVersion("1-12345")
                                    .build())
                                .build())
                            .departmentId("12345")
                            .locationId("12345")
                            .lineNumber(1L)
                            .build()))
                    .status(JournalEntryStatus.DRAFT)
                    .memo("Thank you for your business and have a great day!")
                    .postedAt(OffsetDateTime.parse("2020-09-30T07:43:32.000Z"))
                    .journalSymbol("IND")
                    .taxType("sales")
                    .taxCode("1234")
                    .number("OIT00546")
                    .trackingCategories(JsonNullable.of(null))
                    .accountingPeriod("01-24")
                    .rowVersion("1-12345")
                    .customFields(List.of(
                        CustomField.of(CustomField1.builder()
                            .id("2389328923893298")
                            .name("employee_level")
                            .description("Employee Level")
                            .value(CustomField1Value.of("Uses Salesforce and Marketo"))
                            .build())))
                    .passThrough(List.of(
                        PassThroughBody.builder()
                            .serviceId("<id>")
                            .extendPaths(List.of(
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build()))
                            .build(),
                        PassThroughBody.builder()
                            .serviceId("<id>")
                            .extendPaths(List.of(
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build()))
                            .build(),
                        PassThroughBody.builder()
                            .serviceId("<id>")
                            .extendPaths(List.of(
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build(),
                                ExtendPaths.builder()
                                    .path("$.nested.property")
                                    .value(Map.ofEntries(
                                        Map.entry("TaxClassificationRef", Map.ofEntries(
                                            Map.entry("value", "EUC-99990201-V1-00020000")))))
                                    .build()))
                            .build()))
                    .build())
                .serviceId("quickbooks")
                .companyId("12345")
                .idempotencyKey("your-unique-key-per-create")
                .build();

        AccountingJournalEntriesAddResponse res = sdk.accounting().journalEntries().create()
                .request(req)
                .call();

        if (res.createJournalEntryResponse().isPresent()) {
            System.out.println(res.createJournalEntryResponse().get());
        }
    }
}
```

### C# (.NET)

Setup: [C# (.NET) SDK](https://developers.apideck.com/sdks/dot-net.md)

```csharp
using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System;
using System.Collections.Generic;

var sdk = new Apideck(
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingJournalEntriesAddRequest req = new AccountingJournalEntriesAddRequest() {
    ServiceId = "quickbooks",
    CompanyId = "12345",
    IdempotencyKey = "your-unique-key-per-create",
    JournalEntry = new JournalEntryInput() {
        Title = "Purchase Invoice-Inventory (USD): 2019/02/01 Batch Summary Entry",
        CurrencyRate = 0.69D,
        Currency = Currency.Usd,
        CompanyId = "12345",
        LineItems = new List<JournalEntryLineItemInput>() {
            new JournalEntryLineItemInput() {
                Description = "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.",
                TaxAmount = 27500D,
                SubTotal = 27500D,
                TotalAmount = 27500D,
                Type = JournalEntryLineItemType.Debit,
                TaxRate = new LinkedTaxRateInput() {
                    Id = "123456",
                    Rate = 10D,
                },
                TrackingCategories = new List<LinkedTrackingCategory?>() {
                    new LinkedTrackingCategory() {
                        Id = "123456",
                        Name = "New York",
                    },
                    new LinkedTrackingCategory() {
                        Id = "123456",
                        Name = "New York",
                    },
                    new LinkedTrackingCategory() {
                        Id = "123456",
                        Name = "New York",
                    },
                },
                LedgerAccount = new LinkedLedgerAccount() {
                    Id = "123456",
                    NominalCode = "N091",
                    Code = "453",
                },
                Customer = new LinkedCustomerInput() {
                    Id = "12345",
                    DisplayName = "Windsurf Shop",
                    Email = "boring@boring.com",
                },
                Supplier = new LinkedSupplierInput() {
                    Id = "12345",
                    DisplayName = "Windsurf Shop",
                    Address = new Address() {
                        Id = "123",
                        Type = ApideckUnifySdk.Models.Components.Type.Primary,
                        String = "25 Spring Street, Blackburn, VIC 3130",
                        Name = "HQ US",
                        Line1 = "Main street",
                        Line2 = "apt #",
                        Line3 = "Suite #",
                        Line4 = "delivery instructions",
                        StreetNumber = "25",
                        City = "San Francisco",
                        State = "CA",
                        PostalCode = "94104",
                        Country = "US",
                        Latitude = "40.759211",
                        Longitude = "-73.984638",
                        County = "Santa Clara",
                        ContactName = "Elon Musk",
                        Salutation = "Mr",
                        PhoneNumber = "111-111-1111",
                        Fax = "122-111-1111",
                        Email = "elon@musk.com",
                        Website = "https://elonmusk.com",
                        Notes = "Address notes or delivery instructions.",
                        RowVersion = "1-12345",
                    },
                },
                DepartmentId = "12345",
                LocationId = "12345",
                LineNumber = 1,
            },
        },
        Status = JournalEntryStatus.Draft,
        Memo = "Thank you for your business and have a great day!",
        PostedAt = System.DateTime.Parse("2020-09-30T07:43:32.000Z").ToUniversalTime(),
        JournalSymbol = "IND",
        TaxType = "sales",
        TaxCode = "1234",
        Number = "OIT00546",
        TrackingCategories = null,
        AccountingPeriod = "01-24",
        RowVersion = "1-12345",
        CustomFields = new List<CustomField>() {
            CustomField.CreateCustomField1(
                new CustomField1() {
                    Id = "2389328923893298",
                    Name = "employee_level",
                    Description = "Employee Level",
                    Value = CustomField1Value.CreateStr(
                        "Uses Salesforce and Marketo"
                    ),
                }
            ),
        },
        PassThrough = new List<PassThroughBody>() {
            new PassThroughBody() {
                ServiceId = "<id>",
                ExtendPaths = new List<ExtendPaths>() {
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                },
            },
            new PassThroughBody() {
                ServiceId = "<id>",
                ExtendPaths = new List<ExtendPaths>() {
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                },
            },
            new PassThroughBody() {
                ServiceId = "<id>",
                ExtendPaths = new List<ExtendPaths>() {
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                    new ExtendPaths() {
                        Path = "$.nested.property",
                        Value = new Dictionary<string, object>() {
                            { "TaxClassificationRef", new Dictionary<string, object>() {
                                { "value", "EUC-99990201-V1-00020000" },
                            } },
                        },
                    },
                },
            },
        },
    },
};

var res = await sdk.Accounting.JournalEntries.CreateAsync(req);

// handle response
```
