0

Create Member

by
Published Aug 26, 2024

Create a new member

Script ghostcms Verified

The script

Submitted by hugo697 Bun
Verified 652 days ago
1
import GhostAdminAPI from '@tryghost/admin-api'
2

3
type Ghostcms = {
4
	apiKey: string
5
	apiUrl: string
6
}
7

8
export async function main(
9
	resource: Ghostcms,
10
	payload: {
11
		email: string
12
		name?: string
13
		note?: string
14
		label?: {
15
			name: string
16
			slug: string
17
		}[]
18
		newsletters?: {
19
			id: string
20
		}[]
21
	}
22
) {
23
	const apiClient = new GhostAdminAPI({
24
		url: resource.apiUrl,
25
		version: 'v5.87',
26
		key: resource.apiKey
27
	})
28

29
	const response = await apiClient.members.add(payload)
30

31
	return response
32
}
33