> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# VPS networking API

> Read a VPS’s addresses, manage forwarded ports and domains, order a dedicated IPv4 and request mail over the REST API.

## Goal

Automate VPS networking with an API token.

## Prerequisites

* An API token with access to the server.
* The server id from GET /api/v1/compute/instances.

## Workflow

**Step 1**

Read the current state with GET /api/v1/compute/instances/\{id}/edge.

**Step 2**

Add forwards and domains with POST, change them with PATCH and remove them with DELETE.

**Step 3**

Verify a domain with POST .../edge/domains/\{domainId}/verify after adding its records.

## Addresses and forwards

* GET /api/v1/compute/instances/\{id}/edge returns edge\_hostname, public\_ipv4, ipv6, ssh\_port, forwards and domains.
* POST /api/v1/compute/instances/\{id}/edge/forwards with protocol (tcp or udp), internal\_port and allowed\_cidrs. The response includes the external\_port StackShift picked.
* PATCH .../edge/forwards/\{forwardId} with allowed\_cidrs, including the SSH forward. DELETE removes a custom forward; the SSH forward cannot be removed.
* Instance responses also carry edge\_hostname, ssh\_port and node\_public\_ipv4.

```json Forward PostgreSQL on TCP theme={null}
{
  "protocol": "tcp",
  "internal_port": 5432,
  "allowed_cidrs": ["197.210.8.0/24"]
}
```

## Domains

* POST /api/v1/compute/instances/\{id}/edge/domains with hostname, tls\_mode (terminate or passthrough; passthrough when omitted), target\_port (required for terminate) and proxy\_protocol (passthrough only). Returns the domain and verification\_name.
* PATCH .../edge/domains/\{domainId} changes tls\_mode, target\_port, proxy\_protocol or allowed\_cidrs. DELETE removes it; the platform names return 409.
* POST .../edge/domains/\{domainId}/verify checks the TXT record and, for a terminate wildcard, the CNAME in acme\_cname\_name and acme\_cname\_target.
* Domain fields include verification\_token, verified\_at, certificate\_status (pending, issued or failed), certificate\_error and certificate\_expires\_at.

```json Add a domain with StackShift handling HTTPS theme={null}
{
  "hostname": "shop.example.com",
  "tls_mode": "terminate",
  "target_port": 3000
}
```

## Dedicated IPv4 and mail

* GET /api/v1/compute/instances/\{id}/ipv4 returns the offer: availability, message, currency, monthly\_minor, setup\_minor, charge\_now\_minor and any existing add-on.
* POST .../ipv4 with provider starts payment, or joins the waitlist when none is free. POST .../ipv4/checkout pays for an add-on that is ready. DELETE .../ipv4 cancels a request or removes the address.
* Add-on status moves through waitlisted, offered, awaiting\_payment, allocating, attaching and attached; detaching, released and cancelled end it.
* At order time, POST /api/v1/compute/instances accepts dedicated\_ipv4: true.
* POST /api/v1/compute/instances/\{id}/smtp-requests with reason sends a mail request; GET lists them. Without a dedicated IPv4 it returns 409.

## Expected result

> [!TIP]
>
> Your scripts manage the same routes the Networking tab shows.

## Related guides

> [card] [Domains and HTTPS](https://docs.stackshift.cloud/compute/custom-domains.md)
>
> Point your own domain at a VPS, prove it with a TXT record, and choose per domain whether StackShift handles HTTPS or forwards it untouched.

> [card] [SSH and forwarded ports](https://docs.stackshift.cloud/compute/ssh-and-forwarded-ports.md)
>
> Log in over the shared IPv4 on the server’s SSH port or over IPv6 on port 22, and forward up to 10 more TCP or UDP ports on the shared IPv4.

> [card] [Dedicated IPv4 add-on](https://docs.stackshift.cloud/compute/dedicated-ipv4.md)
>
> Attach an IPv4 address that only your VPS uses, for a fixed IP partners can allow-list, well-known ports on IPv4, or a mail server.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.