0

Get Subscription from Destination

by
Published Oct 17, 2025

Gets a Destination subscription by id. • This endpoint is in **Alpha** testing. Please submit any feedback by sending an email to [email protected]. • In order to successfully call this endpoint, the specified Workspace needs to have the Destination Subscriptions feature enabled. Please reach out to your customer success manager for more information.

Script segment Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Segment = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * Get Subscription from Destination
8
 * Gets a Destination subscription by id.
9

10
• This endpoint is in **Alpha** testing.  Please submit any feedback by sending an email to friends@segment.com.
11

12

13
• In order to successfully call this endpoint, the specified Workspace needs to have the Destination Subscriptions feature enabled. Please reach out to your customer success manager for more information.
14
 */
15
export async function main(auth: Segment, destinationId: string, id: string) {
16
  const url = new URL(
17
    `${auth.baseUrl}/destinations/${destinationId}/subscriptions/${id}`,
18
  );
19

20
  const response = await fetch(url, {
21
    method: "GET",
22
    headers: {
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.text();
32
}
33