Table of Contents

**@arolariu/website**


@arolariu/website / lib/actions/invoices/analyzeInvoice / default

Function: default()

default(input): ServerActionOutputType

Defined in: lib/actions/invoices/analyzeInvoice.ts:83

Submits an invoice to the AI-powered analysis pipeline.

Parameters

input

ServerActionInputType

The invoice identifier and analysis configuration

Returns

ServerActionOutputType

Promise that resolves when analysis is successfully queued

Remarks

Execution Context: Server-side only (Next.js server action).

Authentication: Automatically fetches JWT from Clerk auth service.

Side Effects:

  • Emits OpenTelemetry spans for tracing
  • Triggers async processing in the backend
  • Analysis results are stored on the invoice entity

Error Handling: Throws on validation failure, auth failure, or API errors. Errors are logged with trace context for debugging.

Throws

When invoiceIdentifier is not a valid GUID

Throws

When authentication fails

Throws

When API returns non-OK status

Example

import analyzeInvoice from "@/lib/actions/invoices/analyzeInvoice";
import {InvoiceAnalysisOptions} from "@/types/invoices";

await analyzeInvoice({
  invoiceIdentifier: "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  analysisOptions: InvoiceAnalysisOptions.DetailedAnalysis
});

See

fetchInvoice to retrieve the analyzed invoice