0

Attach a child organization to an enterprise

by
Published Oct 17, 2025

Attaches an existing organization to an enterprise. The `retention` and `owner` field are optional, and will be defaulted if not specified. To specify which child organization to attach, one of its service keys must be supplied through our typical service key authorization schema; either as basic authorization or through the `servicekey` header.

Script mezmo Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Attach a child organization to an enterprise
4
 * Attaches an existing organization to an enterprise. The `retention` and `owner` field are optional, and will be defaulted if not specified. To specify which child organization to attach, one of its service keys must be supplied through our typical service key authorization schema; either as basic authorization or through the `servicekey` header.
5
 */
6
export async function main(auth: RT.Mezmo, body: Body) {
7
	const url = new URL(`https://api.mezmo.com/v1/enterprise/account`)
8

9
	const response = await fetch(url, {
10
		method: 'POST',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Token ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface Body {
32
	/**
33
	 * Current retention period selected for the child organization
34
	 */
35
	retention?: number
36
	/**
37
	 * The email of a user to be given owner privileges of an account.
38
	 */
39
	owner?: string
40
}
41