NewWacht Bench is live — AI-assisted development for Wacht

createSegment()

Creates a segment by name and target type.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function createSegment() {  const client = await wachtClient();  return client.segments.createSegment({    name: 'High Value Customers',    type: 'user',  });}

Signature

function createSegment(  request: CreateSegmentRequest,): Promise<Segment>

Parameters

name: string;
Segment display name.
type: 'organization' | 'workspace' | 'user';
Segment target type.

Return value

result?: Segment | undefined;
Operation result payload.

Behavior

  • Creates a new resource and returns the created object from the backend.
  • Validate required fields before calling to avoid predictable request failures.

On this page