Skip to content

Kody is live

Watch the launch video — what Kody is, and why it exists.

← Public packages

@kody/blandPublic

src/list-calls.ts

40 lines · 916 B · TypeScript
/**
 * List recent Bland calls (`GET /v1/calls`).
 * Read-only — no confirm required.
 *
 * @param input - optional query filters (from, to, limit, etc.)
 * @returns Call list payload
 *
 * @example
 * import { listCalls } from 'kody:@kody/bland/list-calls'
 * await listCalls({ limit: 10 })
 */
import { blandRequest, type BlandAuthInput } from './core.ts'

export type ListCallsInput = BlandAuthInput & {
	from?: number | string
	to?: number | string
	limit?: number
	offset?: number
	ascending?: boolean
	query?: Record<string, string | number | boolean | undefined | null>
}

export async function listCalls(input: ListCallsInput = {}) {
	const query = {
		...(input.query ?? {}),
		from: input.from,
		to: input.to,
		limit: input.limit,
		offset: input.offset,
		ascending: input.ascending,
	}
	return blandRequest({
		...input,
		method: 'GET',
		path: '/v1/calls',
		query,
	})
}

export default listCalls