## Create Credential

`client.credentials.create(CredentialCreateParamsbody, RequestOptionsoptions?): Credential`

**post** `/v5/credentials`

Create a new credential for storing sensitive data like API keys, tokens, or other secrets.

### Parameters

- `body: CredentialCreateParams`

  - `name: string`

    User-friendly name for the credential

  - `payload: string`

    The credential payload to be encrypted

  - `type: string`

    Type of credential: key or json

  - `credential_metadata?: Record<string, unknown>`

    Optional unencrypted credential_metadata

  - `description?: string`

    Optional description

### Returns

- `Credential`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string | null`

  - `created_by_user_id: string | null`

  - `credential_metadata: Record<string, unknown> | null`

  - `description: string | null`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object?: string`

### Example

```typescript
import SGPClient from 'scale-gp';

const client = new SGPClient({
  accountID: 'My Account ID',
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

const credential = await client.credentials.create({
  name: 'x',
  payload: 'x',
  type: 'x',
});

console.log(credential.id);
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by_identity_type": "created_by_identity_type",
  "created_by_user_id": "created_by_user_id",
  "credential_metadata": {
    "foo": "bar"
  },
  "description": "description",
  "name": "name",
  "type": "type",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "object": "object"
}
```
