0

Get Send-As Alias

by
Published today

Get one send-as alias by its email address. Requires gmail.readonly, gmail.modify or gmail.settings.basic on the connection.

Script gmail Verified

The script

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

3
/**
4
 * Get Send-As Alias
5
 * Get one send-as alias (display name, reply-to, signature, `isDefault`, `verificationStatus`) by its email address. Requires gmail.readonly, gmail.modify or gmail.settings.basic on the connection.
6
 */
7
export async function main(auth: RT.Gmail, send_as_email: string) {
8
  const response = await fetch(
9
    `https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs/${encodeURIComponent(send_as_email)}`,
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/json",
14
      },
15
    }
16
  )
17
  if (!response.ok) {
18
    throw new Error(`${response.status} ${await response.text()}`)
19
  }
20

21
  return await response.json()
22
}
23