# Record Type Commands

Overview

The Record Type Commands in Keeper Commander are used for creating and managing Record Types and Custom Templates within the Keeper security platform. These are usable only to create custom record types to an enterprise scope.

## Commands

Below commands are supported in record-type:

* [Record-Type-Info](#record-type-info)
* [Record-Type-Create](#record-type-create)
* [Record-Type-Update](#record-type-update)
* [Record-Type-Delete](#record-type-delete)
* [Record-Type-Load](https://docs.keeper.io/en/keeperpam/commander-sdk/keeper-commander-sdks/import-export-commands#load-record-types-command)
* [Record-Type-Export](https://docs.keeper.io/en/keeperpam/commander-sdk/keeper-commander-sdks/sdk-command-reference/import-export-commands)

### Record-Type-Info

Lists available record types or shows detailed information about a specific record type.

<details>

<summary>DotNet CLI</summary>

**Command:** `record-type-info`

**Flag:**

* `value pos. 0` : Custom record type or field type name. This is a positional argument placed at position 0 immediately after the command
* `-f, --field` : Used to check all available fields for the custom record type.

**Example:**

```csharp
My Vault> record-type-info "myCustomType" 
    Record Type ID:  12345                    
         Type Name:  myCustomType
             Scope:  enterprise               
       Description:  My custom record         
            Fields:  (login)                  
                     (password)      
```

</details>

<details>

<summary>DotNet SDK</summary>

**Function:**

```csharp
 // Assuming vault is vaultOnline
var recordTypes = vault.RecordTypes;
```

</details>

<details>

<summary>PowerCommander</summary>

**Command** : `Get-KeeperRecordType`

**Alias :** `krti`

**Flags** :

* `-ShowFields` : Shows all the available fields present in the custom-record-type.
* `-Name` : Name of the custom record type

**Example:**

```powershell
PS > Get-KeeperRecordType -Name "myCustomType"     

Name          Description                          Scope        Fields
----          -----------                          -----        ------
myCustomType  My custom record for secure access   Enterprise   {login, password}
```

</details>

<details>

<summary>Python CLI</summary>

**Command** : `record-type-info`

**Options** :

* `-lr, --list-record-type` : \[RECORD\_NAME] list record type by name or use \* to list all
* `-lf, --list-field` : FIELD\_NAME list field type by name or use \* to list all
* `-e, --example` : Use --example to generate example JSON

**Example:**

```bash
My Vault> record-type-info "myCustomType"
  Record Type ID  Record Type Name               Record Type Scope
----------------  -----------------------------  -------------------
               1  address                        Standard
               2  bankAccount                    Standard
```

</details>

<details>

<summary>Python SDK</summary>

**Function:** `get_record_types`

```python
record_types = vault.vault_data.get_record_types()
```

</details>

### Record-Type-Create

Add a new custom Keeper Record Type. This will only be able to create custom record types which are scoped to your enterprise. this needs an admin role to execute.

<details>

<summary>DotNet CLI</summary>

**Command:** `record-type-add`

**Flag:**

* `value (pos. 0)` : Required. (Default: false) Adds a new record type with given data. Needs a Serialised JSON string.

**Example:**

```csharp
My Vault> record-type-add "{\"$id\":\"myCustomType_dotnet_test6\",\"description\":\"My custom record\",\"categories\":[\"note\"],\"fields\":[{\"$ref\":\"login\"},{\"$ref\":\"password\"}]}"
Created Record Type ID: 12345
```

</details>

<details>

<summary>DotNet SDK</summary>

Create a keeper record object and then call the function.

**Function:**

```csharp
Task<string> AddRecordType(string recordTypeData);
```

folder in which the record has to be created can be given as folder UID

```csharp
var createdRecord = vaultAddRecordType(recordTypeData);
```

</details>

<details>

<summary>PowerCommander</summary>

**Command:** `New-KeeperRecordType`

**Flags:**

* `-Data` : Data of the custom-record-type in Json format

**Example:**

```powershell
PS > New-KeeperRecordType -Data '{"$id": "myCustomType_powershell","description": "My custom record for secure access in Powershell","categories": ["note"],"fields": [{"$ref": "login"},{"$ref": "password"}]}'
Created Record Type ID: 12345
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `record-type-add`

**Parameters:**

* `--data` : DATA Record type definition in JSON format or "filepath:" to read from JSON file.

**Example:**

```bash
My Vault> record-type-add --data "{\"$id\":\"myCustomType_python\",\"description\":\"My custo
m record\",\"categories\":[\"note\"],\"fields\":[{\"$ref\":\"login\"},{\"$ref\":\"password\"}
]}"
Custom record type 'myCustomType' created successfully with fields: ['login', 'password'] and recordTypeId: 12345
```

</details>

<details>

<summary>Python SDK</summary>

**Function:** `create_custom_record_type`

```python
create_custom_record_type(vault: vault_online.VaultOnline, title: str, fields: List[Dict[str, str]], description: str, categories: List[str] = None):
```

**Example:**

```python
title = "<record type name>"
fields = [] ## TypedFields Array
description = "<some description>"
categories = []
result = record_type_management.create_custom_record_type(
            vault, title, fields, description, categories
        )
```

</details>

### Record-Type-Update

Update the existing custom record type. This does not affect old records created from same custom type. new records going forward will have the fields set here

<details>

<summary>DotNet CLI</summary>

**Command:** `record-type-update`

**Flag:**

* `value pos. 0` : RecordTypeId of record type to be updated
* `value pos. 1` : Update a new record type with given data. Needs a Serialized JSON string.

**Example:**

```csharp
My Vault> record-type-update 12345 "{\"$id\":\"myCustomType_dotnet_test6\",\"description\":\"My custom record\",\"categories\":[\"note\"],\"fields\":[{\"$ref\":\"login\"},{\"$ref\":\"password\"},{\"$ref\":\"url\"}]}" 
Updated Record Type ID: 12345
```

</details>

<details>

<summary>DotNet SDK</summary>

F**unction :**

```csharp
Task<string> UpdateRecordTypeAsync(string recordTypeId, string recordTypeData);
```

</details>

<details>

<summary>PowerCommander</summary>

**Command:** `Edit-KeeperRecordType`

**Flags:**

* `-RecordTypeId` : Record Id of the custom record type
* `-Data` : Additional fields that need to update

**Example:**

```powershell
PS > Edit-KeeperRecordType -RecordTypeId 12345 -Data '{"$id": "myCustomType","description": "My custom record with more fields","categories": ["note"],"fields": [{"$ref": "login"},{"$ref": "password"},{"$ref": "url"}]}'
Updated Record Type ID: 12345
```

</details>

<details>

<summary>Python CLI</summary>

**Command** : `record-type-edit`

**Parameter** :

* `record_type_id` : Record Type ID of record type to be updated.
* `--data` : DATA Record type definition in JSON format or "file path:" to read from JSON\
  file.

**Example:**

```bash
My Vault> record-type-edit 12345 --data "{\"$id\":\"myCustomType_python\",\"description\":\"M
y custom record\",\"categories\":[\"note\"],\"fields\":[{\"$ref\":\"login\"},{\"$ref\":\"pass
word\"},{\"$ref\":\"url\"}]}"
 
Custom record type (ID: 12345) updated successfully with fields: ['login', 'password', 'url'] and recordTypeId: 12345
```

</details>

<details>

<summary>Python SDK</summary>

**Function:** `edit_custom_record_types`

```python
edit_custom_record_types(vault: vault_online.VaultOnline, record_type_id: int, title: str, fields: List[Dict[str, str]], description: str, categories: List[str] = None):
```

</details>

### Record-Type-Delete

Delete the existing custom record type. If the record type exists then it will be deleted, else it will just give a notification for the same

<details>

<summary>DotNet CLI</summary>

**Command:** `record-type-delete`

**Flag:**

* `value pos. 0` Required. (Default: false) Record Type Id of record type to be deleted

**Example:**

```csharp
My Vault> record-type-delete 12345
Deleted Record Type ID: 12345
```

</details>

<details>

<summary>DotNet SDK</summary>

**Function:**

```csharp
Task<string> DeleteRecordTypeAsync(string recordTypeId);
```

</details>

<details>

<summary>PowerCommander</summary>

**Command:** `Remove-KeeperRecordType`

**Flag:**

* `-RecordTypeId` : Record Id of the custom record type
* `-Confirm` : Deletes the record forcefully

**Example:**

```powershell
PS > Remove-KeeperRecordType 12345 
Confirm
Are you sure you want to perform this action?
Performing the operation "Delete record type" on target "RecordTypeId '12345'".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
Deleted Record Type ID: 12345
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `record-type-delete`

**Parameter:**

* `record_type_id` : Record Type ID of record type to be deleted.

**Example:**

```bash
My Vault> record-type-delete 12345
Custom record type deleted successfully with record type id: 12345
```

</details>

<details>

<summary>Python SDK</summary>

**Function** : `delete_custom_record_types`

```python
delete_custom_record_types(vault: vault_online.VaultOnline, record_type_id: int):
```

</details>
