export const title = 'Accounts'



## List all Accounts {{ tag: 'GET' , label: '/api/accounts' }} 

<Row>
  <Col>
    Returns a list of accounts of a user. Always returns a list of one account.
              </Col>

  <Col sticky>
    <CodeGroup title="Request" tag="GET" label="/api/accounts">
```bash {{ title: 'cURL' }}
curl -X GET https://api.netbird.io/api/accounts \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>' 
```

```js
const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: '/api/accounts',
  headers: {     
    'Accept': 'application/json',    
    'Authorization': 'Token <TOKEN>'
  }  
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

```python
import requests
import json

url = "https://api.netbird.io/api/accounts"

headers = {     
  'Accept': 'application/json',
  'Authorization': 'Token <TOKEN>'
}

response = requests.request("GET", url, headers=headers)

print(response.text)
```

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.netbird.io/api/accounts"
  method := "GET"
  
  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  {  
    
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Authorization", "Token <TOKEN>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.netbird.io/api/accounts")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"

response = https.request(request)
puts response.read_body
```

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();

Request request = new Request.Builder()
  .url("https://api.netbird.io/api/accounts")
  .method("GET")    
  .addHeader("Accept", "application/json")
  .addHeader("Authorization: Token <TOKEN>")
  .build();
Response response = client.newCall(request).execute();
```

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.netbird.io/api/accounts',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',  
  CURLOPT_HTTPHEADER => array(        
    'Accept: application/json',
    'Authorization: Token <TOKEN>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

    </CodeGroup>
    
    
    <CodeGroup title="Response">
```json {{ title: 'Example' }}
[
  {
    "id": "ch8i4ug6lnn4g9hqv7l0",
    "settings": {
      "peer_login_expiration_enabled": true,
      "peer_login_expiration": 43200,
      "regular_users_view_blocked": true,
      "groups_propagation_enabled": true,
      "jwt_groups_enabled": true,
      "jwt_groups_claim_name": "roles",
      "jwt_allow_groups": [
        "Administrators"
      ],
      "extra": {
        "peer_approval_enabled": true
      }
    }
  }
]
```
```json {{ title: 'Schema' }}
[
  {
    "id": "string",
    "settings": {
      "peer_login_expiration_enabled": "boolean",
      "peer_login_expiration": "integer",
      "regular_users_view_blocked": "boolean",
      "groups_propagation_enabled": "boolean",
      "jwt_groups_enabled": "boolean",
      "jwt_groups_claim_name": "string",
      "jwt_allow_groups": [
        "string"
      ],
      "extra": {
        "peer_approval_enabled": "boolean"
      }
    }
  }
]
```
    </CodeGroup>
    
 
  </Col>
</Row>

---


## Delete an Account {{ tag: 'DELETE' , label: '/api/accounts/{accountId}' }} 

<Row>
  <Col>
    Deletes an account and all its resources. Only account owners can delete accounts.
    
    #### Path Parameters
    <Properties>
        
          <Property name="accountId" type="string" required={true}> 
            The unique identifier of an account
          </Property>   
            </Properties>
              </Col>

  <Col sticky>
    <CodeGroup title="Request" tag="DELETE" label="/api/accounts/{accountId}">
```bash {{ title: 'cURL' }}
curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \
-H 'Authorization: Token <TOKEN>' 
```

```js
const axios = require('axios');

let config = {
  method: 'delete',
  maxBodyLength: Infinity,
  url: '/api/accounts/{accountId}',
  headers: {         
    'Authorization': 'Token <TOKEN>'
  }  
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

```python
import requests
import json

url = "https://api.netbird.io/api/accounts/{accountId}"

headers = {     
  'Authorization': 'Token <TOKEN>'
}

response = requests.request("DELETE", url, headers=headers)

print(response.text)
```

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.netbird.io/api/accounts/{accountId}"
  method := "DELETE"
  
  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  {  
    
  req.Header.Add("Authorization", "Token <TOKEN>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.netbird.io/api/accounts/{accountId}")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Token <TOKEN>"

response = https.request(request)
puts response.read_body
```

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();

Request request = new Request.Builder()
  .url("https://api.netbird.io/api/accounts/{accountId}")
  .method("DELETE")    
  .addHeader("Authorization: Token <TOKEN>")
  .build();
Response response = client.newCall(request).execute();
```

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.netbird.io/api/accounts/{accountId}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',  
  CURLOPT_HTTPHEADER => array(        
    'Authorization: Token <TOKEN>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

    </CodeGroup>
    
    
 
  </Col>
</Row>

---


## Update an Account {{ tag: 'PUT' , label: '/api/accounts/{accountId}' }} 

<Row>
  <Col>
    Update information about an account
    
    #### Path Parameters
    <Properties>
        
          <Property name="accountId" type="string" required={true}> 
            The unique identifier of an account
          </Property>   
            </Properties>
            
    #### Request-Body Parameters
    
    <Properties><Property name="settings" type="object" required={true}>
        
            <details class="custom-details" open>
                <summary>More Information</summary>
                <Properties>
                
                    <Properties><Property name="peer_login_expiration_enabled" type="boolean" required={true}>
        
            Enables or disables peer login expiration globally. After peer's login has expired the user has to log in (authenticate). Applies only to peers that were added by a user (interactive SSO login).
        
        </Property>
    <Property name="peer_login_expiration" type="integer" required={true}>
        
            Period of time after which peer login expires (seconds).
        
        </Property>
    <Property name="regular_users_view_blocked" type="boolean" required={true}>
        
            Allows blocking regular users from viewing parts of the system.
        
        </Property>
    <Property name="groups_propagation_enabled" type="boolean" required={false}>
        
            Allows propagate the new user auto groups to peers that belongs to the user
        
        </Property>
    <Property name="jwt_groups_enabled" type="boolean" required={false}>
        
            Allows extract groups from JWT claim and add it to account groups.
        
        </Property>
    <Property name="jwt_groups_claim_name" type="string" required={false}>
        
            Name of the claim from which we extract groups names to add it to account groups.
        
        </Property>
    <Property name="jwt_allow_groups" type="string[]" required={false}>
        
            List of groups to which users are allowed access
        
        </Property>
    <Property name="extra" type="object" required={false}>
        
            <details class="custom-details" open>
                <summary>More Information</summary>
                <Properties>
                
                    <Properties><Property name="peer_approval_enabled" type="boolean" required={false}>
        
            (Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin.
        
        </Property>
    </Properties>
                
                </Properties>
            </details>
        
        </Property>
    </Properties>
                
                </Properties>
            </details>
        
        </Property>
    </Properties>

    
       </Col>

  <Col sticky>
    <CodeGroup title="Request" tag="PUT" label="/api/accounts/{accountId}">
```bash {{ title: 'cURL' }}
curl -X PUT https://api.netbird.io/api/accounts/{accountId} \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
}'
```

```js
const axios = require('axios');
let data = JSON.stringify({
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
});
let config = {
  method: 'put',
  maxBodyLength: Infinity,
  url: '/api/accounts/{accountId}',
  headers: {     
    'Accept': 'application/json',    
    'Content-Type': 'application/json',
    'Authorization': 'Token <TOKEN>'
  },  
  data : data
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

```python
import requests
import json

url = "https://api.netbird.io/api/accounts/{accountId}"
payload = json.dumps({
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
})
headers = {   
  'Content-Type': 'application/json',  
  'Accept': 'application/json',
  'Authorization': 'Token <TOKEN>'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
```

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.netbird.io/api/accounts/{accountId}"
  method := "PUT"
  
  payload := strings.NewReader(`{
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
}`)
  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  {  
  
  req.Header.Add("Content-Type", "application/json")  
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Authorization", "Token <TOKEN>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

```ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.netbird.io/api/accounts/{accountId}")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"

request.body = JSON.dump({
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
})
response = https.request(request)
puts response.read_body
```

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
}');
Request request = new Request.Builder()
  .url("https://api.netbird.io/api/accounts/{accountId}")
  .method("PUT", body)  
  .addHeader("Content-Type", "application/json")  
  .addHeader("Accept", "application/json")
  .addHeader("Authorization: Token <TOKEN>")
  .build();
Response response = client.newCall(request).execute();
```

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.netbird.io/api/accounts/{accountId}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',  
  CURLOPT_POSTFIELDS => '{
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
}',
  CURLOPT_HTTPHEADER => array(    
    'Content-Type: application/json',    
    'Accept: application/json',
    'Authorization: Token <TOKEN>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

    </CodeGroup>
    
    
    <CodeGroup title="Response">
```json {{ title: 'Example' }}
{
  "id": "ch8i4ug6lnn4g9hqv7l0",
  "settings": {
    "peer_login_expiration_enabled": true,
    "peer_login_expiration": 43200,
    "regular_users_view_blocked": true,
    "groups_propagation_enabled": true,
    "jwt_groups_enabled": true,
    "jwt_groups_claim_name": "roles",
    "jwt_allow_groups": [
      "Administrators"
    ],
    "extra": {
      "peer_approval_enabled": true
    }
  }
}
```
```json {{ title: 'Schema' }}
{
  "id": "string",
  "settings": {
    "peer_login_expiration_enabled": "boolean",
    "peer_login_expiration": "integer",
    "regular_users_view_blocked": "boolean",
    "groups_propagation_enabled": "boolean",
    "jwt_groups_enabled": "boolean",
    "jwt_groups_claim_name": "string",
    "jwt_allow_groups": [
      "string"
    ],
    "extra": {
      "peer_approval_enabled": "boolean"
    }
  }
}
```
    </CodeGroup>
    
 
  </Col>
</Row>

---
