0

Get a VPC subnet

by
Published Oct 17, 2025

Get information about a single VPC Subnet. > --- - __CLI__. ``` linode-cli vpcs subnet-view $vpcId $vpcSubnetId ``` [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 subnet
7
 * Get information about a single VPC Subnet.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli vpcs subnet-view $vpcId $vpcSubnetId
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
  vpcSubnetId: string,
28
) {
29
  const url = new URL(
30
    `https://api.linode.com/${apiVersion}/vpcs/${vpcId}/subnets/${vpcSubnetId}`,
31
  );
32

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