0

Get a VPC

by
Published Oct 17, 2025

Get information about a single VPC. > --- - __CLI__. ``` linode-cli vpcs view $vpcId ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Get a VPC
7
 * Get information about a single VPC.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli vpcs view $vpcId
19
    ```
20

21
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
22
 */
23
export async function main(
24
  auth: Linode,
25
  apiVersion: "v4" | "v4beta",
26
  vpcId: string,
27
) {
28
  const url = new URL(`https://api.linode.com/${apiVersion}/vpcs/${vpcId}`);
29

30
  const response = await fetch(url, {
31
    method: "GET",
32
    headers: {
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: undefined,
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43