godo.ADS.CreateToken()

Generated on 23 Nov 2026 from godo version v1.245.0

Usage

client.ADS.CreateToken(ctx context.Context, create *godo.ADSTokenCreateRequest) (*godo.ADSTokenCreateResponse, *godo.Response, error)

Description

CreateToken creates a token. Region comes from create and is used as the path segment.

Parameters

create *godo.ADSTokenCreateRequest required

Fields of godo.ADSTokenCreateRequest

ADSTokenCreateRequest is the body for CreateToken. Region is required. The other fields are optional and omitted when empty. WorkspaceUUIDs is the workspace binding list. ExpiresInSeconds is written as a JSON string. Zero means the server default and is omitted.

Region string

JSON key: region

Purpose godo.ADSTokenPurpose

Omitted from JSON when empty. JSON key: purpose

WorkspaceUUIDs []string

Omitted from JSON when empty. JSON key: workspace_uuids

Name string

Omitted from JSON when empty. JSON key: name

ExpiresInSeconds int64
Permissions []string

Omitted from JSON when empty. JSON key: permissions

Returns

*godo.ADSTokenCreateResponse
*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.ADSTokenCreateResponse

ADSTokenCreateResponse is the body returned by CreateToken. AccessToken is returned once, on create. Do not log this struct with %v or %+v.

ID string

JSON key: id

Name string

Omitted from JSON when empty. JSON key: name

AccessToken string

Omitted from JSON when empty. JSON key: access_token

ExpiresAt string

Omitted from JSON when empty. JSON key: expires_at

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.ADS.CreateToken(ctx, &godo.ADSTokenCreateRequest{
		Region: "<your-region>",
		ExpiresInSeconds: 1234567,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", result)
}

More Information

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.