Remove a tag from a subscriber by id
1
type Convertkit = {
2
apiSecret: string
3
}
4
5
export async function main(resource: Convertkit, subscriberId: string, tagId: string) {
6
const queryParams = new URLSearchParams({
7
api_secret: resource.apiSecret
8
})
9
10
const endpoint = `https://api.convertkit.com/v3/subscribers/${subscriberId}/tags/${tagId}?${queryParams.toString()}`
11
12
const response = await fetch(endpoint, {
13
method: 'DELETE',
14
headers: {
15
'Content-Type': 'application/json'
16
17
18
19
if (!response.ok) {
20
throw new Error(`HTTP error! status: ${response.status}`)
21
22
23
const data = await response.json()
24
25
return data
26
27