### Install Midday CLI Source: https://github.com/midday-ai/midday/blob/main/packages/cli/README.md Install the Midday CLI using npx or npm. Global installation is recommended for frequent use. ```bash npx @midday-ai/cli@latest ``` ```bash npm install -g @midday-ai/cli ``` -------------------------------- ### Install @midday/categories Source: https://github.com/midday-ai/midday/blob/main/packages/categories/README.md Install the package using npm. ```bash npm install @midday/categories ``` -------------------------------- ### Start API in Development Mode Source: https://github.com/midday-ai/midday/blob/main/apps/api/README.md Run this command to start the API server in development mode. ```bash bun dev ``` -------------------------------- ### Start Live Timer Source: https://context7.com/midday-ai/midday/llms.txt Start a live timer for a specified project, optionally with a description. Requires `Authorization` and `Content-Type` headers. ```bash # Start a live timer curl -X POST https://api.midday.ai/tracker-entries/timer/start \ -H "Authorization: Bearer mid_live_abc123" \ -H "Content-Type: application/json" \ -d '{ "projectId": "proj_uuid", "description": "Client call" }' ``` -------------------------------- ### Start API in Production Mode Source: https://github.com/midday-ai/midday/blob/main/apps/api/README.md Run this command to start the API server in production mode. ```bash bun start ``` -------------------------------- ### NPM SDK Installation Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/api-reference.mdx Install the Midday SDK using npm. ```APIDOC ## NPM SDK ### Description Install the official Midday SDK for Node.js environments. ### Installation ```bash npm install @midday-ai/sdk ``` ``` -------------------------------- ### Authorization Endpoint Request Example Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/oauth-api-endpoints.mdx Construct a GET request to the authorization endpoint to initiate the OAuth flow. Ensure all required parameters, including PKCE parameters if used, are correctly included. ```http https://app.midday.ai/oauth/authorize? response_type=code& client_id=mid_client_abc123& redirect_uri=https://yourapp.com/callback& scope=transactions.read%20invoices.read& state=xyz789& code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM& code_challenge_method=S256 ``` -------------------------------- ### Start Live Timer Source: https://context7.com/midday-ai/midday/llms.txt Starts a live timer for a project. This is useful for tracking time in real-time. ```APIDOC ## POST /tracker-entries/timer/start ### Description Starts a live timer for a project. This is useful for tracking time in real-time. ### Method POST ### Endpoint /tracker-entries/timer/start ### Parameters #### Request Body - **projectId** (string) - Required - The ID of the project to start the timer for. - **description** (string) - Optional - A description for the timer entry. ### Request Example ```bash curl -X POST https://api.midday.ai/tracker-entries/timer/start \ -H "Authorization: Bearer mid_live_abc123" \ -H "Content-Type: application/json" \ -d '{ "projectId": "proj_uuid", "description": "Client call" }' ``` ``` -------------------------------- ### Install Midday NPM SDK Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/api-reference.mdx Install the official Midday SDK for Node.js and browser environments using npm. ```bash npm install @midday-ai/sdk ``` -------------------------------- ### Install Midday MCP Package Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/api-reference.mdx Install the Midday MCP package for AI tool integrations using npx. ```bash npx @midday-ai/mcp ``` -------------------------------- ### Start Redis with Docker Source: https://github.com/midday-ai/midday/blob/main/apps/api/README.md Use this command to start a Redis instance locally using Docker for development purposes. ```bash docker run -d --name redis -p 6379:6379 redis:alpine ``` -------------------------------- ### MCP Package Installation Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/api-reference.mdx Install the MCP package for AI tool integrations. ```APIDOC ## MCP Package ### Description Install the MCP package for integrating with AI tools. ### Installation ```bash npx @midday-ai/mcp ``` ``` -------------------------------- ### Provider Balance Normalization Example Source: https://github.com/midday-ai/midday/blob/main/docs/runway-burn-rate-analysis.md Illustrates how raw API responses for balances are stored in the database, highlighting normalization for GoCardless. ```plaintext Provider | Raw API Response | Stored In Database | Plaid | Positive (`1000` = $1000 owed) | Positive | GoCardless | Negative (`-1500` = $1500 owed) | **Normalized to positive** | EnableBanking | Positive (ISO 20022 `current`) | Positive (normalized as safety) | Teller | Positive | Positive (normalized as safety) ``` -------------------------------- ### Run Midday Desktop App in Development Mode Source: https://github.com/midday-ai/midday/blob/main/apps/desktop/README.md Execute this command to run the app in development mode, which loads the local development server at http://localhost:3001. Ensure you have Bun installed. ```bash bun run tauri:dev ``` -------------------------------- ### Get Platform-Specific Instructions Source: https://github.com/midday-ai/midday/blob/main/docs/bot-messaging-integration.md Retrieves platform-specific instructions, appending formatting hints to the system prompt for enhanced user experience. ```typescript import { getPlatformInstructions, BotPlatform } from "@midday/bot"; const platform: BotPlatform = "telegram"; // or "whatsapp", "slack" const instructions = getPlatformInstructions(platform); console.log(instructions); ``` -------------------------------- ### Initialize Midday SDK with Access Token Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/build-oauth-app.mdx Instantiate the Midday SDK using the obtained access token to make authenticated API requests. This example shows how to list transactions, invoices, and retrieve financial metrics. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ token: "mid_at_xxxxx", // Access token from OAuth flow }); // List transactions const transactions = await midday.transactions.list({ pageSize: 50, }); // Get invoices const invoices = await midday.invoices.list({ pageSize: 20, }); // Get financial metrics const revenue = await midday.metrics.revenue({ from: "2024-01-01", to: "2024-12-31", }); ``` -------------------------------- ### Track Export Transactions Event with LogSnag Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/updates/posts/lognsag.mdx An example of using the `setupLogSnag` function within a server action to track a 'transactions export' event, including user identification and event details. ```typescript export const exportTransactionsAction = action( exportTransactionsSchema, async (transactionIds) => { const user = await getUser(); const event = await client.sendEvent({ name: Events.TRANSACTIONS_EXPORT, payload: { transactionIds, teamId: user.data.team_id, locale: user.data.locale, }, }); const logsnag = await setupLogSnag({ userId: user.data.id, fullName: user.data.full_name, }); logsnag.track({ event: LogEvents.ExportTransactions.name, icon: LogEvents.ExportTransactions.icon, channel: LogEvents.ExportTransactions.channel, }); return event; } ); ``` -------------------------------- ### Minimal Read Scope Example Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/oauth-scopes.mdx Request only the necessary read scopes for specific functionalities, such as a spending tracker. ```text transactions.read ``` -------------------------------- ### Generate Business Insights with InsightsService Source: https://github.com/midday-ai/midday/blob/main/packages/insights/README.md Use the `createInsightsService` function to initialize the service and then call `generateInsight` with the appropriate parameters to get business insights. Ensure the necessary imports from `@midday/insights` and `@midday/db/client` are included. ```typescript import { createInsightsService } from "@midday/insights"; import { db } from "@midday/db/client"; const service = createInsightsService(db); const result = await service.generateInsight({ teamId: "team-uuid", periodType: "weekly", periodStart: new Date("2024-01-08"), periodEnd: new Date("2024-01-14"), periodLabel: "Week 2, 2024", periodYear: 2024, periodNumber: 2, currency: "USD", }); // Result contains: // - selectedMetrics: Top 4 most relevant metrics // - allMetrics: Full metrics snapshot // - anomalies: Detected issues/alerts // - activity: Invoice, time tracking, customer activity // - content: AI-generated narrative (sentiment, opener, story, actions) ``` -------------------------------- ### Full TypeScript OAuth Implementation Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/build-oauth-app.mdx An example Express.js application demonstrating the full OAuth 2.0 flow with Midday.ai, including redirecting to authorization, handling callbacks, exchanging codes for tokens, and using the SDK. ```typescript import express from "express"; import crypto from "crypto"; import { Midday } from "@midday-ai/sdk"; const app = express(); const CLIENT_ID = process.env.MIDDAY_CLIENT_ID!; const CLIENT_SECRET = process.env.MIDDAY_CLIENT_SECRET!; const REDIRECT_URI = "http://localhost:3000/callback"; // In production, use a proper session store const sessions = new Map(); // Step 1: Redirect to authorization app.get("/connect", (req, res) => { const sessionId = crypto.randomUUID(); const state = crypto.randomUUID(); sessions.set(sessionId, { state }); res.cookie("session_id", sessionId); const authUrl = new URL("https://app.midday.ai/oauth/authorize"); authUrl.searchParams.set("response_type", "code"); authUrl.searchParams.set("client_id", CLIENT_ID); authUrl.searchParams.set("redirect_uri", REDIRECT_URI); authUrl.searchParams.set("scope", "transactions.read invoices.read"); authUrl.searchParams.set("state", state); res.redirect(authUrl.toString()); }); // Step 2: Handle callback and exchange code for tokens app.get("/callback", async (req, res) => { const { code, state, error } = req.query; const sessionId = req.cookies.session_id; const session = sessions.get(sessionId); if (error) { return res.send("Authorization denied"); } // Verify state matches if (state !== session?.state) { return res.status(400).send("Invalid state"); } // Exchange code for tokens const response = await fetch("https://api.midday.ai/v1/oauth/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ grant_type: "authorization_code", code, redirect_uri: REDIRECT_URI, client_id: CLIENT_ID, client_secret: CLIENT_SECRET, }), }); const tokens = await response.json(); session.accessToken = tokens.access_token; res.send("Connected successfully!"); }); // Step 3: Use the SDK with the access token app.get("/transactions", async (req, res) => { const sessionId = req.cookies.session_id; const session = sessions.get(sessionId); if (!session?.accessToken) { return res.status(401).send("Not connected"); } const midday = new Midday({ token: session.accessToken, }); const result = await midday.transactions.list({ pageSize: 50, }); res.json(result); }); app.listen(3000, () => { console.log("Server running on http://localhost:3000"); }); ``` -------------------------------- ### Setup LogSnag with User Identification Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/updates/posts/lognsag.mdx Initializes LogSnag, optionally identifying the user with their ID and name if consent is given. It also wraps the track method to conditionally include the user ID. ```typescript export const setupLogSnag = async (options?: Props) => { const { userId, fullName } = options ?? {}; const consent = cookies().get(Cookies.TrackingConsent)?.value === "0"; const logsnag = new LogSnag({ token: process.env.LOGSNAG_PRIVATE_TOKEN!, project: process.env.NEXT_PUBLIC_LOGSNAG_PROJECT!, disableTracking: Boolean(process.env.NEXT_PUBLIC_LOGSNAG_DISABLED!), }); if (consent && userId && fullName) { await logsnag.identify({ user_id: userId, properties: { name: fullName, }, }); } return { ...logsnag, track: (options: TrackOptions) => logsnag.track({ ...options, user_id: consent ? userId : undefined, }), }; }; ``` -------------------------------- ### Build Midday Desktop App for Production Source: https://github.com/midday-ai/midday/blob/main/apps/desktop/README.md Use this command to create a production build of the Midday Desktop App. Requires Bun. ```bash bun run tauri:build:prod ``` -------------------------------- ### Build Midday Desktop App for Staging Source: https://github.com/midday-ai/midday/blob/main/apps/desktop/README.md Use this command to create a staging build of the Midday Desktop App. Requires Bun. ```bash bun run tauri:build:staging ``` -------------------------------- ### Build Midday Desktop App for Development Source: https://github.com/midday-ai/midday/blob/main/apps/desktop/README.md Use this command to create a development build of the Midday Desktop App. Requires Bun. ```bash bun run tauri:build ``` -------------------------------- ### Run Midday Desktop App in Staging Mode Source: https://github.com/midday-ai/midday/blob/main/apps/desktop/README.md Execute this command to run the app in staging mode, loading the staging environment from https://beta.midday.ai. Requires Bun. ```bash bun run tauri:staging ``` -------------------------------- ### Handle Assistant Thread Started Event Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/updates/posts/slack-assistant.mdx This function is triggered when a new assistant thread starts. It sends a welcome message and suggests initial prompts to the user. ```typescript import type { AssistantThreadStartedEvent, WebClient } from "@slack/web-api"; export async function assistantThreadStarted( event: AssistantThreadStartedEvent, client: WebClient, ) { const prompts = [ { title: "What’s my runway?", message: "What's my runway?" }, // Additional prompts... ]; try { await client.chat.postMessage({ channel: event.assistant_thread.channel_id, thread_ts: event.assistant_thread.thread_ts, text: "Welcome! I'm your financial assistant. Here are some suggestions:", }); await client.assistant.threads.setSuggestedPrompts({ channel_id: event.assistant_thread.channel_id, thread_ts: event.assistant_thread.thread_ts, prompts: prompts.sort(() => 0.5 - Math.random()).slice(0, 4), }); } catch (error) { console.error("Error in assistant thread:", error); await client.assistant.threads.setStatus({ channel_id: event.assistant_thread.channel_id, thread_ts: event.assistant_thread.thread_ts, status: "Something went wrong", }); } } ``` -------------------------------- ### Get Payment Health Score Source: https://context7.com/midday-ai/midday/llms.txt Retrieves the overall payment health score. ```APIDOC ## GET /invoices/payment-status ### Description Gets the payment health score. ### Method GET ### Endpoint https://api.midday.ai/invoices/payment-status ``` -------------------------------- ### Get payment health score Source: https://context7.com/midday-ai/midday/llms.txt Retrieve the overall payment health score for your invoices. ```bash curl "https://api.midday.ai/invoices/payment-status" \ -H "Authorization: Bearer mid_live_abc123" ``` -------------------------------- ### Get Single Transaction Source: https://context7.com/midday-ai/midday/llms.txt Retrieve details for a specific transaction using its unique ID. ```bash curl "https://api.midday.ai/transactions/txn_uuid" \ -H "Authorization: Bearer mid_live_abc123" ``` -------------------------------- ### Update Invoice Status Source: https://context7.com/midday-ai/midday/llms.txt Updates the status of an existing invoice, for example, to mark it as paid. ```APIDOC ## PUT /invoices/{invoiceId} ### Description Updates an invoice, including its status. ### Method PUT ### Endpoint https://api.midday.ai/invoices/{invoiceId} ### Parameters #### Path Parameters - **invoiceId** (string) - Required - The ID of the invoice to update. ### Request Body - **updateData** (object) - Required - The data to update. - **status** (string) - Required - The new status for the invoice (e.g., `paid`). - **paidAt** (string) - Optional - The date and time the invoice was paid (ISO 8601 format), required if status is `paid`. ### Request Example ```json { "status": "paid", "paidAt": "2024-07-05T14:30:00Z" } ``` ``` -------------------------------- ### Initialize Theme Preference Source: https://github.com/midday-ai/midday/blob/main/packages/workbench/src/ui/index.html Sets the initial theme (light or dark) based on local storage or system preference. This script runs immediately to prevent theme flash. ```javascript (() => { var stored = localStorage.getItem('workbench:theme'); var isDark = stored ? stored === 'dark' : window.matchMedia('(prefers-color-scheme: dark)').matches; if (isDark) document.documentElement.classList.add('dark'); })(); /* Prevent flash - set background immediately */ ``` -------------------------------- ### Get Invoice Summary Source: https://context7.com/midday-ai/midday/llms.txt Retrieves a summary of invoices grouped by status, including counts and total amounts. ```APIDOC ## GET /invoices/summary ### Description Gets a summary of invoices by status. ### Method GET ### Endpoint https://api.midday.ai/invoices/summary ### Parameters #### Query Parameters - **statuses[]** (string) - Optional - Filters the summary by one or more statuses (e.g., `unpaid`, `overdue`). ### Response #### Success Response (200) - **data** (array) - An array of summary objects, each containing status, count, totalAmount, and currency. ``` -------------------------------- ### Create a customer Source: https://context7.com/midday-ai/midday/llms.txt Add a new customer to the system. This data can be used to auto-populate invoice details. ```bash curl -X POST https://api.midday.ai/customers \ -H "Authorization: Bearer mid_live_abc123" \ -H "Content-Type: application/json" \ -d '{ "name": "Acme Corp", "email": "billing@acme.com", "website": "https://acme.com", "address": "123 Main St", "city": "San Francisco", "state": "CA", "zip": "94105", "country": "US", "vatNumber": "US123456789" }' ``` -------------------------------- ### Get invoice summary by status Source: https://context7.com/midday-ai/midday/llms.txt Fetch a summary of invoices, including counts and total amounts, for specified statuses. ```bash curl "https://api.midday.ai/invoices/summary?statuses[]=unpaid&statuses[]=overdue" \ -H "Authorization: Bearer mid_live_abc123" ``` -------------------------------- ### Run Midday Desktop App in Production Mode Source: https://github.com/midday-ai/midday/blob/main/apps/desktop/README.md Execute this command to run the app in production mode, loading the production environment from https://app.midday.ai. Requires Bun. ```bash bun run tauri:prod ``` -------------------------------- ### Using Midday SDK with OAuth Access Token Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/oauth-api-endpoints.mdx Demonstrates how to initialize the Midday SDK with an OAuth access token and make various API requests such as listing transactions, invoices, and retrieving financial metrics. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ token: accessToken, // OAuth access token }); // List transactions const transactions = await midday.transactions.list({ pageSize: 50, }); // Get invoices const invoices = await midday.invoices.list({ statuses: ["unpaid", "overdue"], }); // Get financial metrics const profit = await midday.metrics.profit({ from: "2024-01-01", to: "2024-12-31", }); ``` -------------------------------- ### Group Related Scopes Example Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/oauth-scopes.mdx Group related scopes together, such as requesting both invoice and customer scopes if your application deals with both. ```text invoices.read invoices.write customers.read ``` -------------------------------- ### Configure Claude Desktop MCP Server Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/assistant-mcp.mdx Add this configuration to your Claude Desktop's `claude_desktop_config.json` file to enable Midday integration. Ensure you replace `your-api-key-here` with your actual Midday API key. ```json { "mcpServers": { "midday": { "command": "npx", "args": ["-y", "@midday-ai/mcp"], "env": { "MIDDAY_API_KEY": "your-api-key-here" } } } } ``` -------------------------------- ### Get Pre-signed URL for Transaction Attachment Source: https://context7.com/midday-ai/midday/llms.txt Generates a pre-signed URL to download a transaction attachment. The URL is valid for 60 seconds. ```APIDOC ## POST /transactions/{transactionId}/attachments/{attachmentId}/presigned-url ### Description Gets a pre-signed URL for a transaction attachment. ### Method POST ### Endpoint https://api.midday.ai/transactions/{transactionId}/attachments/{attachmentId}/presigned-url ### Parameters #### Path Parameters - **transactionId** (string) - Required - The ID of the transaction. - **attachmentId** (string) - Required - The ID of the attachment. #### Query Parameters - **download** (boolean) - Optional - Set to `true` to indicate a download request. ``` -------------------------------- ### Get pre-signed URL for transaction attachment Source: https://context7.com/midday-ai/midday/llms.txt Obtain a temporary URL to download a transaction attachment. The URL is valid for 60 seconds. ```bash curl -X POST "https://api.midday.ai/transactions/txn_uuid/attachments/att_uuid/presigned-url?download=true" \ -H "Authorization: Bearer mid_live_abc123" ``` -------------------------------- ### Readiness check for service dependencies Source: https://context7.com/midday-ai/midday/llms.txt Check the readiness of the service, including its dependencies like database and Redis. Returns 'ok' or 'degraded' status. ```bash curl https://api.midday.ai/health/ready ``` -------------------------------- ### Retrieve Category Colors Source: https://github.com/midday-ai/midday/blob/main/packages/categories/README.md Import and use functions to get the predefined color for any category or access the complete map of category colors. ```typescript import { getCategoryColor, CATEGORY_COLOR_MAP } from '@midday/categories'; // Get color for any category const revenueColor = getCategoryColor('revenue'); // "#00D084" (Green) const officeSuppliesColor = getCategoryColor('office-supplies'); // "#8ED1FC" (Sky Blue) // Access the complete color map const allColors = CATEGORY_COLOR_MAP; ``` -------------------------------- ### Database Configuration Source: https://github.com/midday-ai/midday/blob/main/apps/api/README.md Configure these environment variables with your PostgreSQL database URLs for primary and replica instances across different regions. ```bash DATABASE_PRIMARY_URL=postgresql://... DATABASE_FRA_URL=postgresql://... # EU replica DATABASE_IAD_URL=postgresql://... # US East replica DATABASE_SJC_URL=postgresql://... # US West replica ``` -------------------------------- ### Time Tracking Operations Source: https://github.com/midday-ai/midday/blob/main/packages/cli/README.md Control time tracking, including starting, stopping, and checking timer status. Manage projects for time entries. ```bash midday tracker start --project proj_abc --description "API development" ``` ```bash midday tracker stop ``` ```bash midday tracker projects create --name "Website Redesign" --rate 150 ``` -------------------------------- ### Type Guards and Assertions Source: https://github.com/midday-ai/midday/blob/main/packages/inbox/README.md Provides examples of using type guards (`isInboxAuthError`, `isInboxSyncError`) and assertions (`assertInboxAuthError`, `assertInboxSyncError`) for robust error handling. ```APIDOC ### Type Guards and Assertions - **`isInboxAuthError(error)`**: Type guard that returns `true` if the provided error is an `InboxAuthError`. - **`isInboxSyncError(error)`**: Type guard that returns `true` if the provided error is an `InboxSyncError`. - **`assertInboxAuthError(error)`**: Assertion function that narrows the type to `InboxAuthError`. Throws an error if the provided error is not an `InboxAuthError`. - **`assertInboxSyncError(error)`**: Assertion function that narrows the type to `InboxSyncError`. Throws an error if the provided error is not an `InboxSyncError`. ### Usage Example ```typescript import { isInboxAuthError, isInboxSyncError, assertInboxAuthError, } from "@midday/inbox/errors"; // Using type guards if (isInboxAuthError(error)) { // TypeScript knows 'error' is InboxAuthError here console.log(error.requiresReauth); } // Using assertions try { assertInboxAuthError(error); // TypeScript knows 'error' is InboxAuthError here console.log(error.provider); } catch (e) { // Handle cases where it's not an InboxAuthError if (isInboxSyncError(e)) { console.log(e.code); } } ``` ``` -------------------------------- ### Environment Variables for Accounting Provider Configuration Source: https://github.com/midday-ai/midday/blob/main/packages/accounting/README.md Lists the necessary environment variables for configuring connections to Xero, QuickBooks, and Fortnox, including client IDs, secrets, and redirect URLs. Also includes a variable for OAuth state encryption. ```bash # Xero XERO_CLIENT_ID=your_client_id XERO_CLIENT_SECRET=your_client_secret XERO_OAUTH_REDIRECT_URL=https://api.midday.ai/v1/apps/xero/oauth-callback # QuickBooks QUICKBOOKS_CLIENT_ID=your_client_id QUICKBOOKS_CLIENT_SECRET=your_client_secret QUICKBOOKS_OAUTH_REDIRECT_URL=https://api.midday.ai/v1/apps/quickbooks/oauth-callback # Fortnox FORTNOX_CLIENT_ID=your_client_id FORTNOX_CLIENT_SECRET=your_client_secret FORTNOX_OAUTH_REDIRECT_URL=https://api.midday.ai/v1/apps/fortnox/oauth-callback # OAuth state encryption ACCOUNTING_OAUTH_SECRET=32_byte_encryption_key ``` -------------------------------- ### Database Query: Get Transactions for Sync Source: https://github.com/midday-ai/midday/blob/main/packages/accounting/README.md Retrieves transactions from the database that are pending synchronization with an accounting provider. Requires database connection and sync parameters. ```typescript // Get transactions for export getTransactionsForAccountingSync(db, { teamId: string, provider: ProviderType, transactionIds: string[], // Required for manual export limit?: number, }): Promise ``` -------------------------------- ### Revoke Token Request Example Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/oauth-api-endpoints.mdx Use this cURL command to revoke an access or refresh token. Provide the token, client ID, and client secret. ```bash curl -X POST https://api.midday.ai/v1/oauth/revoke \ -H "Content-Type: application/json" \ -d '{ "token": "mid_at_xxxxxxxxxxxxx", "client_id": "mid_client_abc123", "client_secret": "mid_secret_xyz789" }' ``` -------------------------------- ### Create Time Entry Source: https://context7.com/midday-ai/midday/llms.txt Create a new time entry with project ID, date, start/stop times, duration, and description. Requires `Authorization` and `Content-Type` headers. ```bash # Create a time entry curl -X POST https://api.midday.ai/tracker-entries \ -H "Authorization: Bearer mid_live_abc123" \ -H "Content-Type: application/json" \ -d '{ "projectId": "proj_uuid", "date": "2024-06-20", "start": "2024-06-20T09:00:00Z", "stop": "2024-06-20T12:00:00Z", "duration": 10800, "description": "API integration work" }' ``` -------------------------------- ### Create and send an invoice Source: https://context7.com/midday-ai/midday/llms.txt Create a new invoice and immediately send it to the customer via email. Specify line items, dates, and optional VAT/discount. ```bash curl -X POST https://api.midday.ai/invoices \ -H "Authorization: Bearer mid_live_abc123" \ -H "Content-Type: application/json" \ -d '{ "customerId": "cust_uuid", "deliveryType": "create_and_send", "issueDate": "2024-06-20T00:00:00Z", "dueDate": "2024-07-20T00:00:00Z", "lineItems": [ { "name": "Web Development", "quantity": 40, "price": 125.00, "unit": "hours" }, { "name": "Design Review", "quantity": 5, "price": 100.00, "unit": "hours" } ], "vat": 250.00, "discount": 100.00 }' ``` -------------------------------- ### Authorization Endpoint Error Response Example Source: https://github.com/midday-ai/midday/blob/main/apps/website/src/app/docs/content/oauth-api-endpoints.mdx In case of an error during authorization, the user is redirected to your `redirect_uri` with `error` and `error_description` parameters, along with the original `state`. ```http https://yourapp.com/callback?error=access_denied&error_description=User%20denied%20access&state=xyz789 ```