0

Get Mailing

by
Published today

Retrieves a single mailing by its ID, including engagement attributes.

Script outreach Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
/**
4
 * Get Mailing
5
 * Retrieves a single mailing by its ID, including engagement attributes (opens, clicks, replies).
6
 */
7
export async function main(auth: RT.Outreach, mailing_id: number) {
8
  const response = await fetch(
9
    `https://api.outreach.io/api/v2/mailings/${mailing_id}`,
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/vnd.api+json",
14
      },
15
    }
16
  )
17

18
  if (!response.ok) {
19
    throw new Error(`${response.status} ${await response.text()}`)
20
  }
21

22
  return await response.json()
23
}
24