Skip to main content
Fabien Landais
Rising Star
October 15, 2024
Question

Input file for btapi tool

Hi,

 

I’m alooking for some example around the btapi.exe usage. Command lines are pretty understandable and usable with options and arguments but I don’t know the file format for inputs. Apparently we can use json format or key=value format but I have never been succeeded to provide inputs to command as “add user”.

If somebody can provide me a json file example to create local users through btapi it will be wonderful :)

6 replies

Fabien Landais
Rising Star
October 15, 2024

Just to add more information : 

The following command is working fine : .\btapi.exe --verbose --env-file .\env-file.txt --input-json --input .\vaultGroups.json add vault/account-group

 

with the following json file : 

{
  "name": "VaultGroup",
  "description": "This is my test Vault Group"
}

 

However if I want to add several VaultGroup in one shot it is not working anymore with the following syntax : 

[
{
  "name": "VaultGroup1",
  "description": "This is my test Vault Group 1"
},
{
  "name": "VaultGroup2",
  "description": "This is my test Vault Group 2"
},
{
  "name": "VaultGroup3",
  "description": "This is my test Vault Group 3"
}
]

 

I have this output in verbose : 

Config loaded (from environment), using BT_API_HOST=[], version=[v1]                                                                                        Parsing path [.\env-file.txt]                                                                                                                    Loading env from [C:\Users\W10LAB\Desktop\Unicancer\btapi\env-file.txt]                                                               
           Config loaded (from file), using BT_API_HOST=[access.unicancer.fr], version=[v1]                                                      
           Loading input file .\vaultGroups.json                                                                                                 
           Parsing path [.\vaultGroups.json]                                                                                                     
           add vault/account-group                                                                                                                          Read input data                                                                                                                       
           [                                                                                                                                     
           {
             "name": "VaultGroup1",
             "description": "This is my test Vault Group 1"
           },
           {
             "name": "VaultGroup2",
             "description": "This is my test Vault Group 2"
           },
           {
             "name": "VaultGroup3",
             "description": "This is my test Vault Group 3"
           }
           ]

           [                                                                                                                                                    {'name': 'VaultGroup1', 'description': 'This is my test Vault Group 1'},
               {'name': 'VaultGroup2', 'description': 'This is my test Vault Group 2'},
               {'name': 'VaultGroup3', 'description': 'This is my test Vault Group 3'}
           ]
Unexpected input parameters: 0, 1, 2

BeyondTrust Employee
October 15, 2024

Hello Fabien Landais,

Just looking through your API string, and some other API documentation, it could be possible the API only supports adding a single entry at a time, and you would need to use a do...while or for… program loop through the JSON file one entry at a time, running the BTAPI Command to add once per new Vault Group you wish to create.

This also seems to be the case as per your exmaple where a json with a single new entry works as expected. The JSON can contain many ther properties then just the name and descrption, hence the use of that format, I suspect.

Fabien Landais
Rising Star
October 16, 2024

Hi PhilC,

 

Thank you for your answer even if it’s not the exact one I would like to hear 😅

Normally this kind of feature is really valuable to do mass import so if it’s not usable like that it’s a shame 

BeyondTrust Employee
October 16, 2024

Hello Fabien Landais - you absloutely can use the API for Mass Imports, you just have to loop through a list within your code, from what I can see.

Trailblazer
February 13, 2025

I would also like to know if we can get a sample provisioned for using BTAPI for bulk imports

Trailblazer
March 11, 2025

 

how to call and add jump groups using btapi, I am trying to add using 

 


D:\Cleanup\btapi>btapi add jump-group jumpgroup.json
Usage: btapi add [OPTIONS] RESOURCE
Try 'btapi add --help' for help.
╭─ Error ──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Got unexpected extra argument (jumpgroup.json)    

 

 

Please help how to add multiple jump groups and group policies using btapi for mass import