Skip to content
Docs
Credentials

Create

Create

client.organizations.serviceAccounts.credentials.create(stringserviceAccountID, CredentialCreateParams { organization_id, name, description, xClientRequestID } params, RequestOptionsoptions?): CredentialCreateResponse { id, client_id, client_secret, 3 more }
POST/organizations/{organization_id}/service-accounts/{service_account_id}/credentials

Create a new credential for a service account

ParametersExpand Collapse
serviceAccountID: string

Identifier for API resources. A 26-char nanoid (URL/DNS safe).

minLength1
maxLength255
params: CredentialCreateParams { organization_id, name, description, xClientRequestID }
organization_id: string

Path param: Organization ID or label identifier

minLength1
maxLength255
name: string

Body param: Credential name

description?: string

Body param: Optional description of the credential

maxLength500
xClientRequestID?: string

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

formatuuid
ReturnsExpand Collapse
CredentialCreateResponse { id, client_id, client_secret, 3 more }

Service account credential with plaintext secret (only returned on creation)

id: string

Identifier for API resources. A 26-char nanoid (URL/DNS safe).

minLength1
maxLength255
client_id: string

The client ID for authentication

client_secret: string

The client secret

created_at: string

The time the entity was created in utc

formatdate-time
name: string

A name for the entity to be displayed in UI

description?: string

Optional description of the credential

Create

import KeycardAPI from '@keycardai/api';

const client = new KeycardAPI();

const credential = await client.organizations.serviceAccounts.credentials.create(
  'ab3def8hij2klm9opq5rst7uvw',
  { organization_id: 'x', name: 'name' },
);

console.log(credential.id);
{
  "id": "ab3def8hij2klm9opq5rst7uvw",
  "client_id": "A1b2C3d4E5f6G7h8I9j0K",
  "client_secret": "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0u1V2w3X4y5Z6A7B8c9D0e1F2",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "description": "description"
}
Returns Examples
{
  "id": "ab3def8hij2klm9opq5rst7uvw",
  "client_id": "A1b2C3d4E5f6G7h8I9j0K",
  "client_secret": "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0u1V2w3X4y5Z6A7B8c9D0e1F2",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "description": "description"
}