(transactions)
Manage transactions
- list - List all transactions
- create - Create a transaction
- get - Retrieve a transaction
- update - Update a transaction
- delete - Delete a transaction
- getAttachmentPreSignedUrl - Generate pre-signed URL for transaction attachment
- updateMany - Bulk update transactions
- createMany - Bulk create transactions
- deleteMany - Bulk delete transactions
Retrieve a list of transactions for the authenticated team.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.list({
cursor: "eyJpZCI6IjEyMyJ9",
sort: [
"date",
"desc",
],
pageSize: 50,
q: "office supplies",
categories: [
"office-supplies",
"travel",
],
tags: [
"tag-1",
"tag-2",
],
start: "2024-04-01T00:00:00.000Z",
end: "2024-04-30T23:59:59.999Z",
accounts: [
"account-1",
"account-2",
],
assignees: [
"user-1",
"user-2",
],
statuses: [
"in_review",
"export_error",
],
recurring: [
"monthly",
"annually",
],
attachments: "include",
amountRange: [
100,
1000,
],
amount: [
"150.75",
"299.99",
],
type: "expense",
manual: "include",
exported: false,
fulfilled: true,
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsList } from "@midday-ai/sdk/funcs/transactionsList.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsList(midday, {
cursor: "eyJpZCI6IjEyMyJ9",
sort: [
"date",
"desc",
],
pageSize: 50,
q: "office supplies",
categories: [
"office-supplies",
"travel",
],
tags: [
"tag-1",
"tag-2",
],
start: "2024-04-01T00:00:00.000Z",
end: "2024-04-30T23:59:59.999Z",
accounts: [
"account-1",
"account-2",
],
assignees: [
"user-1",
"user-2",
],
statuses: [
"in_review",
"export_error",
],
recurring: [
"monthly",
"annually",
],
attachments: "include",
amountRange: [
100,
1000,
],
amount: [
"150.75",
"299.99",
],
type: "expense",
manual: "include",
exported: false,
fulfilled: true,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.ListTransactionsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.ListTransactionsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Create a transaction
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.create({
name: "<value>",
amount: 5744.12,
currency: "Forint",
date: "2024-01-12",
bankAccountId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsCreate } from "@midday-ai/sdk/funcs/transactionsCreate.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsCreate(midday, {
name: "<value>",
amount: 5744.12,
currency: "Forint",
date: "2024-01-12",
bankAccountId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateTransactionRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateTransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Retrieve a transaction by its ID for the authenticated team.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.get({
id: "391723c9-de99-4039-b8e2-4fa5bbdf9480",
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsGet } from "@midday-ai/sdk/funcs/transactionsGet.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsGet(midday, {
id: "391723c9-de99-4039-b8e2-4fa5bbdf9480",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetTransactionByIdRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetTransactionByIdResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Update a transaction for the authenticated team. If there's no change, returns it as it is.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.update({
id: "f0c1d0ef-5679-4c1b-9698-2c64e97e8c1d",
requestBody: {},
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsUpdate } from "@midday-ai/sdk/funcs/transactionsUpdate.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsUpdate(midday, {
id: "f0c1d0ef-5679-4c1b-9698-2c64e97e8c1d",
requestBody: {},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpdateTransactionRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.UpdateTransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Delete a transaction for the authenticated team. Only manually created transactions can be deleted via this endpoint or the form. Transactions inserted by bank connections cannot be deleted, but can be excluded by updating the status.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.delete({
id: "92766ee2-a2bc-44aa-97af-6891695fc321",
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsDelete } from "@midday-ai/sdk/funcs/transactionsDelete.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsDelete(midday, {
id: "92766ee2-a2bc-44aa-97af-6891695fc321",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DeleteTransactionRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.DeleteTransactionResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Generate a pre-signed URL for accessing a transaction attachment. The URL is valid for 60 seconds and allows secure temporary access to the attachment file.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.getAttachmentPreSignedUrl({
transactionId: "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4",
attachmentId: "a43dc3a5-6925-4d91-ac9c-4c1a34bdb388",
download: true,
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsGetAttachmentPreSignedUrl } from "@midday-ai/sdk/funcs/transactionsGetAttachmentPreSignedUrl.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsGetAttachmentPreSignedUrl(midday, {
transactionId: "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4",
attachmentId: "a43dc3a5-6925-4d91-ac9c-4c1a34bdb388",
download: true,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsGetAttachmentPreSignedUrl failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetTransactionAttachmentPreSignedUrlRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetTransactionAttachmentPreSignedUrlResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.GetTransactionAttachmentPreSignedUrlBadRequestError | 400 | application/json |
| errors.GetTransactionAttachmentPreSignedUrlNotFoundError | 404 | application/json |
| errors.GetTransactionAttachmentPreSignedUrlInternalServerError | 500 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Bulk update transactions for the authenticated team. If there's no change, returns it as it is.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.updateMany({
ids: [
"<value 1>",
"<value 2>",
"<value 3>",
],
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsUpdateMany } from "@midday-ai/sdk/funcs/transactionsUpdateMany.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsUpdateMany(midday, {
ids: [
"<value 1>",
"<value 2>",
"<value 3>",
],
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsUpdateMany failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpdateTransactionsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.UpdateTransactionsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Bulk create transactions for the authenticated team.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.createMany([
{
name: "<value>",
amount: 5142.41,
currency: "Gourde",
date: "2024-03-22",
bankAccountId: "<id>",
},
]);
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsCreateMany } from "@midday-ai/sdk/funcs/transactionsCreateMany.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsCreateMany(midday, [
{
name: "<value>",
amount: 5142.41,
currency: "Gourde",
date: "2024-03-22",
bankAccountId: "<id>",
},
]);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsCreateMany failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.RequestBody[] | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateTransactionsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Bulk delete transactions for the authenticated team. Only manually created transactions can be deleted via this endpoint or the form. Transactions inserted by bank connections cannot be deleted, but can be excluded by updating the status.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.transactions.deleteMany([
"c0db9ee1-75c5-4621-84a2-0c38d2dc3106",
"e5581754-1917-44fa-a324-166437019d98",
"a8bccdfb-07ed-4359-8712-46b82316d8f9",
]);
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { transactionsDeleteMany } from "@midday-ai/sdk/funcs/transactionsDeleteMany.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await transactionsDeleteMany(midday, [
"c0db9ee1-75c5-4621-84a2-0c38d2dc3106",
"e5581754-1917-44fa-a324-166437019d98",
"a8bccdfb-07ed-4359-8712-46b82316d8f9",
]);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("transactionsDeleteMany failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
string[] | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.DeleteTransactionsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |