(accounting.expenses)
- list - List Expenses
- create - Create Expense
- get - Get Expense
- update - Update Expense
- delete - Delete Expense
List Expenses
import apideck_unify
from apideck_unify import Apideck
from apideck_unify.utils import parse_datetime
import os
with Apideck(
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:
res = apideck.accounting.expenses.list(raw=False, service_id="salesforce", company_id="12345", limit=20, filter_={
"updated_since": parse_datetime("2020-09-30T07:43:32.000Z"),
"status": apideck_unify.ExpensesFilterStatus.DRAFT,
"type": apideck_unify.ExpensesFilterType.EXPENSE,
})
while res is not None:
# Handle items
res = res.next()| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
consumer_id |
Optional[str] | ➖ | ID of the consumer which you want to get or push data from | test-consumer |
app_id |
Optional[str] | ➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
company_id |
Optional[str] | ➖ | The ID of the company to scope requests to. For connectors that support multi-company, this overrides the default company configured in connection settings. | 12345 |
cursor |
OptionalNullable[str] | ➖ | Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response. | |
limit |
Optional[int] | ➖ | Number of results to return. Minimum 1, Maximum 200, Default 20 | |
filter_ |
Optional[models.ExpensesFilter] | ➖ | Apply filters | { "updated_since": "2020-09-30T07:43:32.000Z", "status": "draft", "type": "expense" } |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.AccountingExpensesAllResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models.BadRequestResponse | 400 | application/json |
| models.UnauthorizedResponse | 401 | application/json |
| models.PaymentRequiredResponse | 402 | application/json |
| models.NotFoundResponse | 404 | application/json |
| models.UnprocessableResponse | 422 | application/json |
| models.APIError | 4XX, 5XX | */* |
Create Expense
import apideck_unify
from apideck_unify import Apideck
from apideck_unify.utils import parse_datetime
import os
with Apideck(
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:
res = apideck.accounting.expenses.create(transaction_date=parse_datetime("2021-05-01T12:00:00.000Z"), line_items=[
{
"tracking_categories": [
{
"id": "123456",
"name": "New York",
},
{
"id": "123456",
"name": "New York",
},
],
"account_id": "123456",
"customer_id": "12345",
"department_id": "12345",
"location_id": "12345",
"tax_rate": {
"id": "123456",
"rate": 10,
},
"description": "Travel US.",
"total_amount": 275,
"line_number": 1,
},
], raw=False, service_id="salesforce", company_id_param="12345", display_id="123456", number="OIT00546", account_id="123456", account={
"id": "123456",
"type": apideck_unify.LinkedFinancialAccountAccountType.LEDGER_ACCOUNT,
"code": "1100",
"display_id": "123456",
"account_number": "123465",
}, supplier_id="12345", 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",
},
}, company_id="12345", location={
"id": "123456",
"display_id": "123456",
"name": "New York Office",
}, department_id="12345", department={
"display_id": "123456",
"name": "Acme Inc.",
}, payment_type=apideck_unify.ExpensePaymentType.CASH, currency=apideck_unify.Currency.USD, currency_rate=0.69, type_=apideck_unify.ExpenseType.EXPENSE, memo="For travel expenses incurred on 2024-05-15", tax_rate={
"id": "123456",
"rate": 10,
}, tax_inclusive=True, sub_total=250, total_tax=25, total_amount=275, tracking_categories=[
{
"id": "123456",
"code": "100",
"name": "New York",
"parent_id": "123456",
"parent_name": "New York",
},
], reference="INV-2024-001", source_document_url="https://www.invoicesolution.com/expense/123456", custom_fields=[
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": {
"0": {
},
},
},
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": {
"0": {
},
},
},
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": {
"0": {
},
},
},
], status=apideck_unify.ExpenseStatus.DRAFT, row_version="1-12345", pass_through=[
{
"service_id": "<id>",
"extend_paths": [
{
"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",
},
},
},
],
},
{
"service_id": "<id>",
"extend_paths": [
{
"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",
},
},
},
],
},
])
assert res.create_expense_response is not None
# Handle response
print(res.create_expense_response)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
transaction_date |
date | ✔️ | The date of the transaction - YYYY:MM::DDThh:mm:ss.sTZD | 2021-05-01T12:00:00.000Z |
line_items |
List[models.ExpenseLineItemInput] | ✔️ | Expense line items linked to this expense. | |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
consumer_id |
Optional[str] | ➖ | ID of the consumer which you want to get or push data from | test-consumer |
app_id |
Optional[str] | ➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
company_id_param |
Optional[str] | ➖ | The ID of the company to scope requests to. For connectors that support multi-company, this overrides the default company configured in connection settings. | 12345 |
display_id |
OptionalNullable[str] | ➖ | Id to be displayed. | 123456 |
number |
OptionalNullable[str] | ➖ | Number. | OIT00546 |
account_id |
Optional[str] | ➖ | : warning: ** DEPRECATED **: Deprecated. Use account instead.. The unique identifier for the ledger account that this expense should be credited to. Deprecated, use account instead. |
123456 |
account |
OptionalNullable[models.LinkedFinancialAccountInput] | ➖ | A flexible account reference that can represent a ledger account (GL account), a bank account, or an employee payable account, depending on the connector's requirements. | |
supplier_id |
Optional[str] | ➖ | : warning: ** DEPRECATED **: Deprecated. Use supplier instead.. The ID of the supplier this entity is linked to. Deprecated, use supplier instead. |
12345 |
supplier |
OptionalNullable[models.LinkedSupplierInput] | ➖ | The supplier this entity is linked to. | |
company_id |
OptionalNullable[str] | ➖ | The company ID the transaction belongs to | 12345 |
location |
OptionalNullable[models.LinkedLocationInput] | ➖ | N/A | |
department_id |
OptionalNullable[str] | ➖ | The ID of the department | 12345 |
department |
OptionalNullable[models.LinkedDepartmentInput] | ➖ | N/A | |
payment_type |
OptionalNullable[models.ExpensePaymentType] | ➖ | The type of payment for the expense. | cash |
currency |
OptionalNullable[models.Currency] | ➖ | Indicates the associated currency for an amount of money. Values correspond to ISO 4217. | USD |
currency_rate |
OptionalNullable[float] | ➖ | Currency Exchange Rate at the time entity was recorded/generated. | 0.69 |
type |
OptionalNullable[models.ExpenseType] | ➖ | The type of expense. | expense |
memo |
OptionalNullable[str] | ➖ | The memo of the expense. | For travel expenses incurred on 2024-05-15 |
tax_rate |
Optional[models.LinkedTaxRateInput] | ➖ | N/A | |
tax_inclusive |
OptionalNullable[bool] | ➖ | Amounts are including tax | true |
sub_total |
OptionalNullable[float] | ➖ | Subtotal amount, normally before tax. | 250 |
total_tax |
OptionalNullable[float] | ➖ | Total tax amount applied to this transaction. | 25 |
total_amount |
OptionalNullable[float] | ➖ | The total amount of the expense line item. | 275 |
tracking_categories |
List[Nullable[models.LinkedTrackingCategory]] | ➖ | A list of linked tracking categories. | |
reference |
OptionalNullable[str] | ➖ | Optional reference identifier for the transaction. | INV-2024-001 |
source_document_url |
OptionalNullable[str] | ➖ | URL link to a source document - shown as 'Go to [appName]' in the downstream app. Currently only supported for Xero. | https://www.invoicesolution.com/expense/123456 |
custom_fields |
List[models.CustomField] | ➖ | N/A | |
status |
OptionalNullable[models.ExpenseStatus] | ➖ | Expense status | draft |
row_version |
OptionalNullable[str] | ➖ | 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. | 1-12345 |
pass_through |
List[models.PassThroughBody] | ➖ | The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.AccountingExpensesAddResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models.BadRequestResponse | 400 | application/json |
| models.UnauthorizedResponse | 401 | application/json |
| models.PaymentRequiredResponse | 402 | application/json |
| models.NotFoundResponse | 404 | application/json |
| models.UnprocessableResponse | 422 | application/json |
| models.APIError | 4XX, 5XX | */* |
Get Expense
from apideck_unify import Apideck
import os
with Apideck(
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:
res = apideck.accounting.expenses.get(id="<id>", service_id="salesforce", company_id="12345", raw=False)
assert res.get_expense_response is not None
# Handle response
print(res.get_expense_response)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
id |
str | ✔️ | ID of the record you are acting upon. | |
consumer_id |
Optional[str] | ➖ | ID of the consumer which you want to get or push data from | test-consumer |
app_id |
Optional[str] | ➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
company_id |
Optional[str] | ➖ | The ID of the company to scope requests to. For connectors that support multi-company, this overrides the default company configured in connection settings. | 12345 |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.AccountingExpensesOneResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models.BadRequestResponse | 400 | application/json |
| models.UnauthorizedResponse | 401 | application/json |
| models.PaymentRequiredResponse | 402 | application/json |
| models.NotFoundResponse | 404 | application/json |
| models.UnprocessableResponse | 422 | application/json |
| models.APIError | 4XX, 5XX | */* |
Update Expense
import apideck_unify
from apideck_unify import Apideck
from apideck_unify.utils import parse_datetime
import os
with Apideck(
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:
res = apideck.accounting.expenses.update(id="<id>", transaction_date=parse_datetime("2021-05-01T12:00:00.000Z"), line_items=[
{
"tracking_categories": [
{
"id": "123456",
"name": "New York",
},
{
"id": "123456",
"name": "New York",
},
],
"account_id": "123456",
"customer_id": "12345",
"department_id": "12345",
"location_id": "12345",
"tax_rate": {
"id": "123456",
"rate": 10,
},
"description": "Travel US.",
"total_amount": 275,
"line_number": 1,
},
], service_id="salesforce", raw=False, display_id="123456", number="OIT00546", account_id="123456", account={
"id": "123456",
"type": apideck_unify.LinkedFinancialAccountAccountType.LEDGER_ACCOUNT,
"code": "1100",
"display_id": "123456",
"account_number": "123465",
}, supplier_id="12345", 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",
},
}, company_id="12345", location={
"id": "123456",
"display_id": "123456",
"name": "New York Office",
}, department_id="12345", department=None, payment_type=apideck_unify.ExpensePaymentType.CASH, currency=apideck_unify.Currency.USD, currency_rate=0.69, type_=apideck_unify.ExpenseType.EXPENSE, memo="For travel expenses incurred on 2024-05-15", tax_rate={
"id": "123456",
"rate": 10,
}, tax_inclusive=True, sub_total=250, total_tax=25, total_amount=275, tracking_categories=[
{
"id": "123456",
"code": "100",
"name": "New York",
"parent_id": "123456",
"parent_name": "New York",
},
], reference="INV-2024-001", source_document_url="https://www.invoicesolution.com/expense/123456", custom_fields=[
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": "Uses Salesforce and Marketo",
},
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": "Uses Salesforce and Marketo",
},
{
"id": "2389328923893298",
"name": "employee_level",
"description": "Employee Level",
"value": "Uses Salesforce and Marketo",
},
], status=apideck_unify.ExpenseStatus.DRAFT, row_version="1-12345", pass_through=[
{
"service_id": "<id>",
"extend_paths": [
{
"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",
},
},
},
],
},
{
"service_id": "<id>",
"extend_paths": [
{
"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",
},
},
},
],
},
{
"service_id": "<id>",
"extend_paths": [
{
"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",
},
},
},
],
},
])
assert res.update_expense_response is not None
# Handle response
print(res.update_expense_response)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
id |
str | ✔️ | ID of the record you are acting upon. | |
transaction_date |
date | ✔️ | The date of the transaction - YYYY:MM::DDThh:mm:ss.sTZD | 2021-05-01T12:00:00.000Z |
line_items |
List[models.ExpenseLineItemInput] | ✔️ | Expense line items linked to this expense. | |
consumer_id |
Optional[str] | ➖ | ID of the consumer which you want to get or push data from | test-consumer |
app_id |
Optional[str] | ➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
display_id |
OptionalNullable[str] | ➖ | Id to be displayed. | 123456 |
number |
OptionalNullable[str] | ➖ | Number. | OIT00546 |
account_id |
Optional[str] | ➖ | : warning: ** DEPRECATED **: Deprecated. Use account instead.. The unique identifier for the ledger account that this expense should be credited to. Deprecated, use account instead. |
123456 |
account |
OptionalNullable[models.LinkedFinancialAccountInput] | ➖ | A flexible account reference that can represent a ledger account (GL account), a bank account, or an employee payable account, depending on the connector's requirements. | |
supplier_id |
Optional[str] | ➖ | : warning: ** DEPRECATED **: Deprecated. Use supplier instead.. The ID of the supplier this entity is linked to. Deprecated, use supplier instead. |
12345 |
supplier |
OptionalNullable[models.LinkedSupplierInput] | ➖ | The supplier this entity is linked to. | |
company_id |
OptionalNullable[str] | ➖ | The company ID the transaction belongs to | 12345 |
location |
OptionalNullable[models.LinkedLocationInput] | ➖ | N/A | |
department_id |
OptionalNullable[str] | ➖ | The ID of the department | 12345 |
department |
OptionalNullable[models.LinkedDepartmentInput] | ➖ | N/A | |
payment_type |
OptionalNullable[models.ExpensePaymentType] | ➖ | The type of payment for the expense. | cash |
currency |
OptionalNullable[models.Currency] | ➖ | Indicates the associated currency for an amount of money. Values correspond to ISO 4217. | USD |
currency_rate |
OptionalNullable[float] | ➖ | Currency Exchange Rate at the time entity was recorded/generated. | 0.69 |
type |
OptionalNullable[models.ExpenseType] | ➖ | The type of expense. | expense |
memo |
OptionalNullable[str] | ➖ | The memo of the expense. | For travel expenses incurred on 2024-05-15 |
tax_rate |
Optional[models.LinkedTaxRateInput] | ➖ | N/A | |
tax_inclusive |
OptionalNullable[bool] | ➖ | Amounts are including tax | true |
sub_total |
OptionalNullable[float] | ➖ | Subtotal amount, normally before tax. | 250 |
total_tax |
OptionalNullable[float] | ➖ | Total tax amount applied to this transaction. | 25 |
total_amount |
OptionalNullable[float] | ➖ | The total amount of the expense line item. | 275 |
tracking_categories |
List[Nullable[models.LinkedTrackingCategory]] | ➖ | A list of linked tracking categories. | |
reference |
OptionalNullable[str] | ➖ | Optional reference identifier for the transaction. | INV-2024-001 |
source_document_url |
OptionalNullable[str] | ➖ | URL link to a source document - shown as 'Go to [appName]' in the downstream app. Currently only supported for Xero. | https://www.invoicesolution.com/expense/123456 |
custom_fields |
List[models.CustomField] | ➖ | N/A | |
status |
OptionalNullable[models.ExpenseStatus] | ➖ | Expense status | draft |
row_version |
OptionalNullable[str] | ➖ | 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. | 1-12345 |
pass_through |
List[models.PassThroughBody] | ➖ | The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.AccountingExpensesUpdateResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models.BadRequestResponse | 400 | application/json |
| models.UnauthorizedResponse | 401 | application/json |
| models.PaymentRequiredResponse | 402 | application/json |
| models.NotFoundResponse | 404 | application/json |
| models.UnprocessableResponse | 422 | application/json |
| models.APIError | 4XX, 5XX | */* |
Delete Expense
from apideck_unify import Apideck
import os
with Apideck(
consumer_id="test-consumer",
app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:
res = apideck.accounting.expenses.delete(id="<id>", service_id="salesforce", raw=False)
assert res.delete_expense_response is not None
# Handle response
print(res.delete_expense_response)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
id |
str | ✔️ | ID of the record you are acting upon. | |
consumer_id |
Optional[str] | ➖ | ID of the consumer which you want to get or push data from | test-consumer |
app_id |
Optional[str] | ➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
service_id |
Optional[str] | ➖ | Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. | salesforce |
raw |
Optional[bool] | ➖ | Include raw response. Mostly used for debugging purposes | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.AccountingExpensesDeleteResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models.BadRequestResponse | 400 | application/json |
| models.UnauthorizedResponse | 401 | application/json |
| models.PaymentRequiredResponse | 402 | application/json |
| models.NotFoundResponse | 404 | application/json |
| models.UnprocessableResponse | 422 | application/json |
| models.APIError | 4XX, 5XX | */* |