Skip to main content

Reports resource

Stable reports surface has two methods: create() and get().

create()​

Create an async report job and receive a receipt with a handle.

const receipt = await conduitClient.reports.create({
source: { url: "https://example.com/call.mp3" },
output: { template: "general_report" },
target: { strategy: "dominant" },
webhook: { url: "https://your-app.com/webhooks/conduit" },
})

console.info(receipt.jobId)

Request shape​

type ReportCreateRequest = {
source:
| { mediaId: string }
| { file: Blob | ArrayBuffer | Uint8Array | ReadableStream<Uint8Array>; label?: string }
| { url: string; label?: string }
| { path: string; label?: string }
output: { template: "sales_playbook" | "general_report"; templateParams?: Record<string, unknown> }
target: TargetSelector
label?: string
entityLabel?: string
webhook?: { url: string; headers?: Record<string, string> }
idempotencyKey?: string
requestId?: string
signal?: AbortSignal
}

Receipt and handle​

type ReportJobReceipt = {
jobId: string
mediaId?: string
status: "queued" | "running"
stage?: JobStage
estimatedWaitSec?: number
requestId?: string
handle?: {
wait(opts?): Promise<Report>
stream(opts?): AsyncIterable<JobEvent>
cancel(): Promise<Job>
job(): Promise<Job>
report(): Promise<Report | null>
}
}
  • source.url makes the SDK host runtime fetch the remote media and then upload it to Conduit.
  • source.path resolves from the current working directory in filesystem-capable runtimes.
  • source.url, source.path, and some ReadableStream uploads may buffer in memory before upload when streaming is not available end-to-end.

get(reportId)​

Fetch a completed report by id.

const report = await conduitClient.reports.get("report_abc123")
console.info(report.output.template)

Webhook-first pattern​

const receipt = await conduitClient.reports.create({
source: { mediaId: "media_abc123" },
output: { template: "sales_playbook" },
target: { strategy: "dominant" },
webhook: { url: "https://your-app.com/webhooks/conduit" },
idempotencyKey: `report:${userId}:${mediaId}`,
})

await db.jobs.create({ id: receipt.jobId, status: receipt.status })

Fallback polling​

Use handle polling only when webhook delivery is not possible.

const receipt = await conduitClient.reports.create({
source: { url: "https://example.com/call.mp3" },
output: { template: "general_report" },
target: { strategy: "dominant" },
})

const report = await receipt.handle?.wait({ timeoutMs: 10 * 60_000 })
console.info(report?.id)