Skip to content
API Reference

Create

client.zones.secrets.create(stringzoneID, SecretCreateParams { data, entity_id, name, 4 more } params, RequestOptionsoptions?): Secret { id, created_at, entity_id, 7 more }
POST/zones/{zone_id}/secrets
ParametersExpand Collapse
zoneID: string

A globally unique opaque identifier

minLength1
params: SecretCreateParams { data, entity_id, name, 4 more }
data: SecretTokenFields { token, type } | SecretPasswordFields { password, type, username }

Body param

Accepts one of the following:
SecretTokenFields { token, type }
token: string
type: "token"
SecretPasswordFields { password, type, username }
password: string
type: "password"
username: string
entity_id: string

Body param: A globally unique opaque identifier

minLength1
name: string

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

description?: string

Body param: A description of the entity

maxLength128
metadata?: unknown

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

zone_id?: string

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?: string

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

formatuuid
ReturnsExpand Collapse
Secret { id, created_at, entity_id, 7 more }
id: string

A globally unique opaque identifier

minLength1
created_at: string
formatdate-time
entity_id: string

A globally unique opaque identifier

minLength1
name: string

A name for the entity to be displayed in UI

type: "token" | "password"
Accepts one of the following:
"token"
"password"
updated_at: string
formatdate-time
version: number
minimum1
zone_id: string

A globally unique opaque identifier

minLength1
description?: string

A description of the entity

maxLength128
metadata?: unknown

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

Create

import KeycardAPI from '@keycardai/api';

const client = new KeycardAPI();

const secret = await client.zones.secrets.create('x', {
  data: { token: 'token', type: 'token' },
  entity_id: 'x',
  name: 'name',
});

console.log(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": {}
}