Skip to content
API Reference

Create

client.Zones.Secrets.New(ctx, zoneID, params) (*Secret, error)
POST/zones/{zone_id}/secrets
ParametersExpand Collapse
zoneID string

A globally unique opaque identifier

minLength1
params ZoneSecretNewParams

Body param

type SecretTokenFields struct{…}
Token string
Type SecretTokenFieldsType
type SecretPasswordFields struct{…}
Password string
Type SecretPasswordFieldsType
Username string
EntityID param.Field[string]

Body param: A globally unique opaque identifier

minLength1
Name param.Field[string]

Body param: A name for the entity to be displayed in UI

Description param.Field[string]optional

Body param: A description of the entity

maxLength128
Metadata param.Field[any]optional

Body param: A JSON object containing arbitrary metadata. Metadata will not be encrypted.

ZoneID param.Field[string]optional

Body param: Optional zone ID. This field is provided for API compatibility but is ignored during processing. The zone ID is derived from the path parameter (/zones/{zone_id}/secrets) and takes precedence.

minLength1
XClientRequestID param.Field[string]optional

Header param: Unique request identifier specified by the originating caller and passed along by proxies.

formatuuid
ReturnsExpand Collapse
type Secret struct{…}
ID string

A globally unique opaque identifier

minLength1
CreatedAt Time
formatdate-time
EntityID string

A globally unique opaque identifier

minLength1
Name string

A name for the entity to be displayed in UI

Type SecretType
Accepts one of the following:
const SecretTypeToken SecretType = "token"
const SecretTypePassword SecretType = "password"
UpdatedAt Time
formatdate-time
Version int64
minimum1
ZoneID string

A globally unique opaque identifier

minLength1
Description stringoptional

A description of the entity

maxLength128
Metadata anyoptional

A JSON object containing arbitrary metadata. Metadata will not be encrypted.

Create

package main

import (
  "context"
  "fmt"

  "github.com/keycardai/keycard-go"
)

func main() {
  client := keycard.NewClient(

  )
  secret, err := client.Zones.Secrets.New(
    context.TODO(),
    "x",
    keycard.ZoneSecretNewParams{
      Data: keycard.ZoneSecretNewParamsDataUnion{
        OfToken: &keycard.SecretTokenFieldsParam{
          Token: "token",
          Type: keycard.SecretTokenFieldsTypeToken,
        },
      },
      EntityID: "x",
      Name: "name",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", secret.ID)
}
{
  "id": "x",
  "created_at": "2019-12-27T18:11:19.117Z",
  "entity_id": "x",
  "name": "name",
  "type": "token",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "version": 1,
  "zone_id": "x",
  "description": "description",
  "metadata": {}
}
Returns Examples
{
  "id": "x",
  "created_at": "2019-12-27T18:11:19.117Z",
  "entity_id": "x",
  "name": "name",
  "type": "token",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "version": 1,
  "zone_id": "x",
  "description": "description",
  "metadata": {}
}