Skip to content
Go to Boltz API

Create a workspace API key

client.Admin.APIKeys.New(ctx, body) (*AdminAPIKeyNewResponse, error)
POST/compute/v1/admin/api-keys

Create a workspace API key

ParametersExpand Collapse
body AdminAPIKeyNewParams
Name param.Field[string]

API key name

minLength1
maxLength255
AllowedIPs param.Field[[]string]optional

IP addresses allowed to use this key (IPv4 or IPv6). An empty array (the default) means all IPs are allowed.

ExpiresInDays param.Field[int64]optional

Days until the key expires. Omit for a key that does not expire.

minimum1
maximum365
Mode param.Field[AdminAPIKeyNewParamsMode]optional

Key mode. Test keys create test-mode resources with synthetic data.

const AdminAPIKeyNewParamsModeLive AdminAPIKeyNewParamsMode = "live"
const AdminAPIKeyNewParamsModeTest AdminAPIKeyNewParamsMode = "test"
WorkspaceID param.Field[string]optional

Workspace ID to scope this key to. Omit for default workspace.

ReturnsExpand Collapse
type AdminAPIKeyNewResponse struct{…}
Key string

The full API key. This is only shown once — store it securely.

KeyDetails AdminAPIKeyNewResponseKeyDetails
ID string

API key ID

AllowedIPs []string

IP addresses allowed to use this key. An empty array means all IPs are allowed.

CreatedAt Time
formatdate-time
ExpiresAt Time

When the key expires. Null if the key does not expire.

formatdate-time
IsActive bool
KeyPrefix string

First 12 characters of the key

KeyType Workspace
LastUsedAt Time
formatdate-time
Livemode bool

Whether this is a live API key (false for test keys).

Name string

API key name

WorkspaceID string

Workspace this key is scoped to

Create a workspace API key

package main

import (
  "context"
  "fmt"

  "github.com/boltz-bio/boltz-api-go"
  "github.com/boltz-bio/boltz-api-go/option"
)

func main() {
  client := boltzapi.NewClient(
    option.WithAPIKey("My API Key"),
  )
  apiKey, err := client.Admin.APIKeys.New(context.TODO(), boltzapi.AdminAPIKeyNewParams{
    Name: "x",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", apiKey.Key)
}
{
  "key": "key",
  "key_details": {
    "id": "id",
    "allowed_ips": [
      "string"
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "expires_at": "2019-12-27T18:11:19.117Z",
    "is_active": true,
    "key_prefix": "key_prefix",
    "key_type": "workspace",
    "last_used_at": "2019-12-27T18:11:19.117Z",
    "livemode": true,
    "name": "name",
    "workspace_id": "workspace_id"
  }
}
Returns Examples
{
  "key": "key",
  "key_details": {
    "id": "id",
    "allowed_ips": [
      "string"
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "expires_at": "2019-12-27T18:11:19.117Z",
    "is_active": true,
    "key_prefix": "key_prefix",
    "key_type": "workspace",
    "last_used_at": "2019-12-27T18:11:19.117Z",
    "livemode": true,
    "name": "name",
    "workspace_id": "workspace_id"
  }
}