createOrganization()
Creates an organization from multipart form fields. Name is required, and you can optionally include metadata and an uploaded image.
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 createOrganization() { const client = await wachtClient(); return client.organizations.createOrganization({ name: 'Acme', description: 'Enterprise account', public_metadata: { tier: 'enterprise' }, });}Signature
function createOrganization( request: CreateOrganizationRequest,): Promise<Organization>CreateOrganizationRequest
›name?: string | undefined;
name?: string | undefined;Organization display name.
›description?: string | undefined;
description?: string | undefined;Optional description text.
›public_metadata?: Record<string, unknown> | undefined;
public_metadata?: Record<string, unknown> | undefined;Optional public metadata.
›plan?: string | undefined;
plan?: string | undefined;Example public plan field.
›owner?: string | undefined;
owner?: string | undefined;Example public owner field.
›private_metadata?: Record<string, unknown> | undefined;
private_metadata?: Record<string, unknown> | undefined;Optional private metadata.
›internal_notes?: string | undefined;
internal_notes?: string | undefined;Example internal note field.
›billing_id?: string | undefined;
billing_id?: string | undefined;Example internal billing identifier.
›organization_image?: File | Blob | undefined;
organization_image?: File | Blob | undefined;Optional uploaded organization image.
Return value
›id?: string | undefined;
id?: string | undefined;Stable organization identifier.
›created_at?: string | undefined;
created_at?: string | undefined;Creation timestamp.
›updated_at?: string | undefined;
updated_at?: string | undefined;Last update timestamp.
›name?: string | undefined;
name?: string | undefined;Organization display name.
›description?: string | undefined;
description?: string | undefined;Organization description text.
›image_url?: string | undefined;
image_url?: string | undefined;Organization image URL.
›member_count?: number | undefined;
member_count?: number | undefined;Current member count.
›public_metadata?: Record<string, unknown> | undefined;
public_metadata?: Record<string, unknown> | undefined;Public organization metadata.
›plan?: string | undefined;
plan?: string | undefined;Example public plan field.
›owner?: string | undefined;
owner?: string | undefined;Example public owner field.
›private_metadata?: Record<string, unknown> | undefined;
private_metadata?: Record<string, unknown> | undefined;Private organization metadata.
›internal_notes?: string | undefined;
internal_notes?: string | undefined;Example internal note field.
›billing_id?: string | undefined;
billing_id?: string | undefined;Example internal billing identifier.
Behavior
- Creates an organization and returns the created organization object.
- Multipart payload allows metadata plus optional image upload.
Examples
Create with metadata only
import { wachtClient } from '@wacht/nextjs/server';export async function createBasicOrganization() { const client = await wachtClient(); return client.organizations.createOrganization({ name: 'Acme', public_metadata: { plan: 'pro' }, });}Create with uploaded image
import { wachtClient } from '@wacht/nextjs/server';export async function createOrganizationWithImage(file: Blob) { const client = await wachtClient(); return client.organizations.createOrganization({ name: 'Acme', organization_image: file, });}