godo.MicroVMs.ListByName()

Generated on 5 Nov 2026 from godo version v1.236.0

Usage

client.MicroVMs.ListByName(ctx context.Context, name string, opt *godo.ListOptions) ([]godo.MicroVM, *godo.Response, error)

Description

ListByName lists MicroVMs filtered by exact name match, with optional pagination.

This method sends a GET request to /v2/microvms.

Parameters

name string required
opt *godo.ListOptions

Fields of godo.ListOptions

ListOptions specifies the optional parameters to various List methods that support pagination.

Page int

For paginated result sets, page of results to retrieve.

PerPage int

For paginated result sets, the number of results to include per page.

WithProjects bool

Whether App responses should include project_id fields. The field will be empty if false or if omitted. (ListApps)

Deployed bool

This parameter is used to only list agents that are deployed in the response.

PublicOnly bool

This parameter is used to include models that are publicly available.

Usecases []string

This parameter is used to include models according to the use cases.

Returns

[]godo.MicroVM
*godo.Response

The HTTP response, with pagination Links, Meta, and Rate limit information.

error

Non-nil when the request fails. API errors are returned as *godo.ErrorResponse.

Fields of godo.MicroVM

MicroVM represents a DigitalOcean MicroVM.

ID string

Omitted from JSON when empty. JSON key: id

Name string

Omitted from JSON when empty. JSON key: name

Region string

Omitted from JSON when empty. JSON key: region

State godo.MicroVMState

Omitted from JSON when empty. JSON key: state

Size *godo.MicroVMSize

Omitted from JSON when empty. JSON key: size

URLs []godo.MicroVMURL

Omitted from JSON when empty. JSON key: urls

Ports []uint32

Omitted from JSON when empty. JSON key: ports

FailureReason string

Omitted from JSON when empty. JSON key: failure_reason

Networking godo.MicroVMNetworking

Omitted from JSON when empty. JSON key: networking

Source *godo.MicroVMSource

Omitted from JSON when empty. JSON key: source

AutoPause *godo.AutoPauseConfig

Omitted from JSON when empty. JSON key: auto_pause

AutoResume *bool

Omitted from JSON when empty. JSON key: auto_resume

HTTPProtocol godo.MicroVMHTTPProtocol

Omitted from JSON when empty. JSON key: http_protocol

Created string

Omitted from JSON when empty. JSON key: created_at

Tags []string

Omitted from JSON when empty. JSON key: tags

EgressPolicy *godo.MicroVMEgressPolicy

EgressPolicy is the outbound allow list set at create, as supplied.
Nil when the MicroVM has no policy and egress is unrestricted.

Omitted from JSON when empty. JSON key: egress_policy

Request Sample

Show Request Sample
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/digitalocean/godo"
)

func main() {
	client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
	ctx := context.TODO()

	result, _, err := client.MicroVMs.ListByName(ctx, "<your-name>", &godo.ListOptions{Page: 1, PerPage: 50})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", result)
}

Pagination

This method returns one page of results. Response.Links carries the pagination state; loop until IsLastPage reports true.

Show Pagination Sample
opt := &godo.ListOptions{Page: 1, PerPage: 50}
for {
	items, resp, err := client.MicroVMs.ListByName(ctx, "<your-name>", opt)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", items)

	if resp.Links == nil || resp.Links.IsLastPage() {
		break
	}
	page, err := resp.Links.CurrentPage()
	if err != nil {
		log.Fatal(err)
	}
	opt.Page = page + 1
}

Response Example

Show Response Example
{
  "microvms": [
    {
      "id": "01a0ef1a-d873-793d-ae6a-5dd6239be62a",
      "name": "example-microvm",
      "region": "mkc1",
      "size": {
        "cpu": 1,
        "memory": 2048,
        "disk": 50
      },
      "source": {
        "oci_ref": "docker.io/library/nginx:latest"
      },
      "state": "paused",
      "networking": "public",
      "auto_pause": {
        "enabled": true,
        "idle_timeout": "5m0s"
      },
      "auto_resume": true,
      "http_protocol": "http",
      "ports": [
        80
      ],
      "tags": [
        "example"
      ],
      "urls": [
        {
          "hostname": "01a0ef1a-d873-793d-ae6a-5dd6239be62a.mkc1.microvm.ondigitalocean.com",
          "port": 80,
          "default": true,
          "status": "ACTIVE"
        }
      ],
      "created_at": "2026-09-29T21:38:29Z"
    }
  ],
  "links": {
    "pages": {
      "last": "/v2/microvms?page=4&per_page=1",
      "next": "/v2/microvms?page=2&per_page=1"
    }
  },
  "meta": {
    "page": 1,
    "per_page": 1,
    "total": 4
  }
}

More Information

See GET /v2/microvms in the API reference for additional detail on responses, headers, parameters, and more.

See the Go package documentation for the source of this method.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.