---
title: "Create expense transaction"
method: POST
path: "/companies/{companyId}/sync/expenses/expense-transactions"
tags: ["Expenses"]
---

# Create expense transaction

`POST /companies/{companyId}/sync/expenses/expense-transactions`

The *Create expense* endpoint creates an [expense transaction](https://docs.codat.io/sync-for-expenses-api#/schemas/ExpenseTransaction) in the accounting software for a given company's connection. 

[Expense transactions](https://docs.codat.io/sync-for-expenses-api#/schemas/ExpenseTransaction) represent transactions made with a company debit or credit card. 

### Supported Integrations

| Integration                   | Supported |
|-------------------------------|-----------|
| Dynamics 365 Business Central | Yes       |
| FreeAgent                     | Yes       |
| QuickBooks Desktop            | Yes       |
| QuickBooks Online             | Yes       |
| Oracle NetSuite               | Yes       |
| Sage Intacct                  | Yes       |
| Xero                          | Yes       |
| Zoho Books                    | Yes       |

## Request body

- ExpenseTransaction[]
  - `id` string, uuid, required — Your unique identifier for the transaction.
  - `type` 'Payment' | 'Refund' | 'Reward' | 'Chargeback', required — The type of transaction.
  - `issueDate` 1, required — unresolved $ref
  - `currency` string, required — Currency the transaction was recorded in.
  - `currencyRate` number, nullable — Rate to convert the total amount of the payment into the base currency for the company at the time of the payment. Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit. It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR. Where the currency rate is provided by the underlying accounting software, it will be available from Codat with the same precision (up to a maximum of 9 decimal places). For accounting software which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places. ## Examples with base currency of GBP | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | | :--------------- | :------------- | :------------ | :------------------------- | | **USD** | $20 | 0.781 | £15.62 | | **EUR** | €20 | 0.885 | £17.70 | | **RUB** | ₽20 | 0.011 | £0.22 | ## Examples with base currency of USD | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | | :--------------- | :------------- | :------------ | :------------------------- | | **GBP** | £20 | 1.277 | $25.54 | | **EUR** | €20 | 1.134 | $22.68 | | **RUB** | ₽20 | 0.015 | $0.30 | ### Integration-specific details | Integration | Scenario | System behavior | |-------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| | QuickBooks Online | Transaction currency differs from base currency | If currency rate value is left `null`, a rate of 1 will be used by QBO by default. To override this, specify a currencyRate in the request body. |
  - `contactRef` ExpenseContactRef
    - `id` string, required — Identifier of supplier or customer.
    - `type` 'Supplier' — The type of contact.
  - `bankAccountRef` object
    - `id` string — Identifier of the bank account.
  - `reference` string, nullable — User-friendly reference for the expense transaction.
  - `merchantName` string — Name of the merchant where the purchase took place
  - `lines` ExpenseTransactionLine[] — Array of transaction lines.
    - `netAmount` number, required — Amount of the line, exclusive of tax.
    - `taxAmount` number — Amount of tax for the line.
    - `taxRateRef` RecordRef
      - `id` string — Identifier of linked reference from mapping options.
    - `accountRef` RecordRef
      - `id` string — Identifier of linked reference from mapping options.
    - `itemRef` ItemRef, nullable
      - `id` string — Unique identifier for the item associated with the transaction. The `itemRef` object is currently supported only for QuickBooks Desktop. You can specify either `itemRef` or `accountRef`, but not both.
    - `trackingRefs` TrackingRef[], nullable
      - `id` string — Unique identifier of the linked reference from mapping options or the unique identifier of the linked customer.
      - `dataType` 'trackingCategories' | 'customers' — The type of the linked reference
    - `invoiceTo` InvoiceTo, nullable — Unique identifier for the customer billed for the transaction. The `invoiceTo` object is currently supported only for QuickBooks Online and QuickBooks Desktop.
      - `id` string — identifier of customer.
      - `type` 'customer' — The type of contact.
  - `notes` string — Any private, company notes about the transaction.
  - `postAsDraft` boolean, nullable — This optional property, when set to true, posts the transaction to a drafted state. Note that postAsDraft is only supported in Microsoft Dynamics 365 Business Central.

## Response `200`

OK

- CreateExpenseResponse
  - `syncId` string, uuid — Unique id of sync created

## Other responses

- `400` — The request made is not valid.
- `401` — Your API request was not properly authorized.
- `402` — An account limit has been exceeded. The type of limit is described in the error property: - You have exceeded the 50-company limit that applies to a Free plan. Delete any companies you no longer need and retry the request. - The requested sync schedule is not allowed. You requested an hourly sync schedule but this functionality is not included in the Free plan. - Your Free account is older than 365 days and has expired. Contact support@codat.io.
- `403` — You are using an outdated API key or a key not associated with that resource.
- `404` — One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted.
- `429` — Too many requests were made in a given amount of time. Wait a short period and then try again.
- `500` — There is a problem with our server. Please try again later.
- `503` — The Codat API is temporarily offline for maintenance. Please try again later.

---

[API](https://skmtc.net/codatio/apis/sync-for-expenses-v1.md) · [All operations](https://skmtc.net/codatio/apis/sync-for-expenses-v1/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/codatio/sync-for-expenses-v1/revisions/3a810b6f9c66/schema)
