Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/hubspot

src/create-contact.ts

29 lines · 970 B · TypeScript
import { createStandard, parseCreateInput, type StandardCreateInput } from './wrappers.ts'

/**
 * Create a HubSpot contact. Requires `confirm: true`, or use `dryRun: true`.
 * @example
 * import createContact from 'kody:@kody/hubspot/create-contact'
 * const preview = await createContact({
 *   properties: { email: 'pat@example.com', firstname: 'Pat' },
 *   dryRun: true,
 * })
 */
export async function createContact(input: StandardCreateInput) {
	return createStandard('contacts', input)
}

/**
 * Create a HubSpot contact. Requires `confirm: true`, or use `dryRun: true`.
 * @example
 * import createContact from 'kody:@kody/hubspot/create-contact'
 * const preview = await createContact({
 *   properties: { email: 'pat@example.com' },
 *   dryRun: true,
 * })
 */
export default async function createContactEntrypoint(
	params: Partial<StandardCreateInput> & Record<string, unknown> = {},
) {
	return createContact(parseCreateInput(params, 'create-contact'))
}