> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/api/api-doc-en/api-reference/jue-se-he-quan-xian.md).

# Roles and Permissions

### Create Role <a href="#undefined" id="undefined"></a>

POST `/api/organizations/{organizationPk}/groups/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Request Body

**Request Parameters**

| Field        | Type           | Required | Description |
| ------------ | -------------- | -------- | ----------- |
| name         | string         | Yes      |             |
| organization | string (uuid)  | No       |             |
| permissions  | array\[string] | Yes      |             |

**Request Structure Example**

```typescript
{
  "name": string
  "organization"?: string (uuid) // optional
  "permissions": [
    string (uuid)
  ]
}
```

**Request Example Value**

```json
{
  "name": "Example Name",
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "permissions": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Call API Example (Shell)
curl -X POST "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example Name",
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "permissions": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "name": "Example Name",
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "permissions": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
      "name": "Sample Name",
      "organization": "550e8400-e29b-41d4-a716-446655440000",
      "permissions": [
        "550e8400-e29b-41d4-a716-446655440000"
      ]
    }

response = requests.post(url, json=data, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => {
            "name": "Example Name",
            "organization": "550e8400-e29b-41d4-a716-446655440000",
            "permissions": [
                "550e8400-e29b-41d4-a716-446655440000"
            ]
        }
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 201**

**Response Schema Example**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "permissions": [
    {
      "id": string (uuid)
      "name": string
      "description"?: string // optional
    }
  ]
  "createdAt": string (timestamp)
}
```

**Response Example Value**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response String",
  "type": {},
  "permissions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response String",
      "description": "Response String"
    }
  ],
  "createdAt": "Response String"
}
```

***

### Bulk Add Role Members <a href="#undefined" id="undefined"></a>

POST `/api/organizations/{organizationPk}/groups/{groupPk}/group-members/bulk-create/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `groupPk`        | ✅        | string |                                                |
| `organizationPk` | ✅        | string | A UUID string identifying this organization ID |

#### Request Body

**Request Parameters**

| Field   | Type           | Required | Description |
| ------- | -------------- | -------- | ----------- |
| members | array\[string] | Yes      |             |

**Request Structure Example**

```typescript
{
  "members": [
    string (uuid)
  ]
}
```

**Request Example Value**

```json
{
  "members": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X POST "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/bulk-create/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "members": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "members": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/bulk-create/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/bulk-create/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
      "members": [
        "550e8400-e29b-41d4-a716-446655440000"
      ]
    }

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/bulk-create/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => {
            "members": [
                "550e8400-e29b-41d4-a716-446655440000"
            ]
        }
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully got response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 201**

**Response Schema Example**

```typescript
[
  {
    "id"?: string (uuid) // Role member ID (optional)
    "member"?: { // optional
    {
      "id"?: string (uuid) // Member ID (optional)
      "name"?: string // Member name (optional)
      "email"?: string (email) // Member email (optional)
      "organization"?: { // optional
      {
        "id"?: string (uuid) // Organization ID (optional)
        "name"?: string // Organization name (optional)
        "createdAt"?: string // Organization creation timestamp (optional)
        "usageStatistics"?: { // optional
        {
          "chatbotsCount"?: integer // Number of chatbots (optional)
          "canCreateChatbot"?: boolean // Whether a chatbot can be created (optional)
          "hasCreateChatbotLimit"?: boolean // Whether there is a limit on creating chatbots (optional)
          "currentMonthWordsCountTotal"?: integer // Total word count limit for the current month (optional)
          "currentMonthUsedWordsCountTotal"?: integer // Words used in the current month (optional)
          "currentMonthUsedConversationsCountTotal"?: integer // Conversations used in the current month (optional)
          "availableUploadFilesSizeTotal"?: integer // Total available upload file size (optional)
          "usedUploadFileSizeTotal"?: integer // Total used upload file size (optional)
        }
        }
        "organizationPlan"?: { // optional
        {
          "id"?: string (uuid) // Plan ID (optional)
          "planName"?: string // Plan name (optional)
          "expiredAt"?: string // Plan expiration time (optional)
        }
        }
      }
      }
      "isOwner"?: boolean // Whether is the organization owner (optional)
      "permissions"?: { // optional
      {
        "hasOrganizationAccessPermission"?: boolean // Whether has organization access permission (optional)
        "hasChatAccessPermission"?: boolean // Whether has chat access permission (optional)
        "hasConversationAccessPermission"?: boolean // Whether has conversation access permission (optional)
        "hasChatbotAccessPermission"?: boolean // Whether has chatbot access permission (optional)
        "hasWebChatAccessPermission"?: boolean // Whether has web chat access permission (optional)
      }
      }
      "createdAt"?: string // Member creation timestamp (optional)
    }
    }
    "createdAt"?: string // Role member creation timestamp (optional)
  }
]
```

**Response Example Value**

```json
[
  {
    "id": "c1e54f04-01fc-45e9-b40c-9d8b37bd0ac0",
    "member": {
      "id": "af4e472d-3f9b-446b-bab8-05de4112d086",
      "name": "h",
      "email": "h@gmail.com",
      "organization": {
        "id": "670e3d30-9d24-47b4-b2cc-6bf224b2f3bb",
        "name": "Updated Org Name",
        "createdAt": "1745288290000",
        "usageStatistics": {
          "chatbotsCount": 1,
          "canCreateChatbot": false,
          "hasCreateChatbotLimit": true,
          "currentMonthWordsCountTotal": 1000000,
          "currentMonthUsedWordsCountTotal": 0,
          "currentMonthUsedConversationsCountTotal": 0,
          "availableUploadFilesSizeTotal": 104857600,
          "usedUploadFileSizeTotal": 0
        },
        "organizationPlan": {
          "id": "16136181-ae0d-4b3f-aaeb-9a6ed251459f",
          "planName": "Free Plan",
          "expiredAt": null
        }
      },
      "isOwner": false,
      "permissions": {
        "hasOrganizationAccessPermission": true,
        "hasChatAccessPermission": false,
        "hasConversationAccessPermission": false,
        "hasChatbotAccessPermission": false,
        "hasWebChatAccessPermission": false
      },
      "createdAt": "1748335331000"
    },
    "createdAt": "1748341252000"
  }
]
```

***

### Bulk Assign AI Assistants to Roles <a href="#ai" id="ai"></a>

POST `/api/organizations/{organizationPk}/groups/{groupPk}/group-chatbots/bulk-create/`

#### Parameters

| Parameter Name   | Required | Type    | Description                                    |
| ---------------- | -------- | ------- | ---------------------------------------------- |
| `groupPk`        | ✅        | string  |                                                |
| `organizationPk` | ✅        | string  | A UUID string identifying this Organization ID |
| `page`           | ❌        | integer | A page number within the paginated result set. |
| `pageSize`       | ❌        | integer | Number of results to return per page.          |
| `query`          | ❌        | string  |                                                |

#### Request Body

**Request Parameters**

| Field    | Type           | Required | Description |
| -------- | -------------- | -------- | ----------- |
| chatbots | array\[string] | Yes      |             |

**Request Structure Example**

```typescript
{
  "chatbots": [
    string (uuid)
  ]
}
```

**Request Example Value**

```json
{
  "chatbots": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Call API Example (Shell)
curl -X POST "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/bulk-create/?page=1&pageSize=1&query=example" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chatbots": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "chatbots": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/bulk-create/?page=1&pageSize=1&query=example", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/bulk-create/?page=1&pageSize=1&query=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
      "chatbots": [
        "550e8400-e29b-41d4-a716-446655440000"
      ]
    }

response = requests.post(url, json=data, headers=headers)
try:
    print("Successfully got response:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/bulk-create/?page=1&pageSize=1&query=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => {
            "chatbots": [
                "550e8400-e29b-41d4-a716-446655440000"
            ]
        }
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 201**

**Response Schema Example**

```typescript
{
  "count": integer
  "next"?: string (uri) // Optional
  "previous"?: string (uri) // Optional
  "results": [
    {
      "id": string (uuid)
      "group": string (uuid)
      "chatbot": { // Adds nested create feature
      {
        "id": string (uuid)
        "name": string // The name of the chatbot. In Agent mode, it has semantic meaning; in other modes, it's just used to differentiate between different chatbots.
        "rag"?: string (uuid) // RAG (Retrieval-Augmented Generation) settings, used to enhance response quality (Optional)
        "largeLanguageModel": string (uuid) // The large language model used by the chatbot to generate responses.
        "embeddingModel"?: string (uuid) // The embedding model used for vectorizing text, an optional field (Optional)
        "rerankerModel"?: string (uuid) // Optional
        "instructions"?: string // The role instructions for the chatbot, used to describe its role and behavior (Optional)
        "knowledgeBases"?: [ // A list of knowledge bases accessible to the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
          }
        ]
        "updatedAt": string (timestamp)
        "organization"?: string (uuid) // The organization the chatbot belongs to. If null, it's a personal chatbot (Optional)
        "builtInWorkflow"?: string (uuid) // Built-in workflow, used for predefined processing flows (Optional)
        "replyMode"?:  // Reply mode: normal reply or streaming reply

* `normal` - Normal
* `template` - Template
* `hybrid` - Hybrid
* `workflow` - Workflow
* `agent` - Agent (Optional)
        {
        }
        "template"?: string // The template used in Template mode and Hybrid mode (Optional)
        "unanswerableTemplate"?: string // The template used when an answer cannot be provided in Template mode and Hybrid mode (Optional)
        "totalWordsCount"?: integer (int64) // Cumulative total word count used (Optional)
        "outputMode"?:  // Output mode: text, table, or custom format

* `text` - Text
* `json_schema` - JSON Schema (Optional)
        {
        }
        "rawOutputFormat"?: object // JSON structure definition for custom output format (Optional)
        "databaseUrl"?: string // Database connection URL (for database query functionality) (Optional)
        "databaseType"?: string // Database type options, including MySQL, PostgreSQL, MSSQL, Oracle (Optional)
        "includeTables"?: object // List of included tables (for database query functionality) (Optional)
        "groups"?: [ // List of groups accessible to the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
          }
        ]
        "toolkits"?: [ // List of toolkits used by the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
            "description": string
            "displayName": string
            "toolType": string
          }
        ]
        "tools"?: [ // List of tools usable by the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
            "description": string
            "displayName": string
            "toolType": string
          }
        ]
        "agentMode"?:  // Agent mode: normal, SQL, or workflow mode

* `normal` - Normal
* `canvas` - Canvas (Optional)
        {
        }
        "numberOfRetrievedChunks"?: integer // The number of retrieved reference chunks, default is 12, minimum is 1 (Optional)
        "enableEvaluation"?: boolean // Optional
        "enableInLineCitations"?: boolean // Enable inline citations, which will insert citation markers in [1][2] format in the response (Optional)
      }
      }
      "createdAt": string (timestamp)
    }
  ]
}
```

**Response Example Value**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "group": "550e8400-e29b-41d4-a716-446655440000",
      "chatbot": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "string",
        "rag": "550e8400-e29b-41d4-a716-446655440000",
        "largeLanguageModel": "550e8400-e29b-41d4-a716-446655440000",
        "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
        "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
        "instructions": "string",
        "knowledgeBases": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "string"
          }
        ],
        "updatedAt": "string",
        "organization": "550e8400-e29b-41d4-a716-446655440000",
        "builtInWorkflow": "550e8400-e29b-41d4-a716-446655440000",
        "replyMode": {},
        "template": "string",
        "unanswerableTemplate": "string",
        "totalWordsCount": 456,
        "outputMode": {},
        "rawOutputFormat": null,
        "databaseUrl": "string",
        "databaseType": "string",
        "includeTables": null,
        "groups": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "string"
          }
        ],
        "toolkits": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "string",
            "description": "string",
            "displayName": "string",
            "toolType": "string"
          }
        ],
        "tools": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "string",
            "description": "string",
            "displayName": "string",
            "toolType": "string"
          }
        ],
        "agentMode": {},
        "numberOfRetrievedChunks": 456,
        "enableEvaluation": false,
        "enableInLineCitations": false
      },
      "createdAt": "string"
    }
  ]
}
```

***

### List Permissions <a href="#undefined" id="undefined"></a>

GET `/api/permissions/`

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/permissions/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/permissions/", config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred during the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/permissions/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/permissions/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'An error occurred during the request: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
[
  {
    "id": string (uuid)
    "name": string
    "description"?: string // Optional
  }
]
```

**Response Example Value**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response String",
    "description": "Response String"
  }
]
```

***

### Get Group List <a href="#undefined" id="undefined"></a>

GET `/api/organizations/{organizationPk}/groups/`

#### Parameters

| Parameter Name   | Required | Type    | Description                                    |
| ---------------- | -------- | ------- | ---------------------------------------------- |
| `organizationPk` | ✅        | string  | A UUID string identifying this Organization ID |
| `page`           | ❌        | integer | A page number within the paginated result set. |
| `pageSize`       | ❌        | integer | Number of results to return per page.          |
| `query`          | ❌        | string  |                                                |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/?page=1&pageSize=1&query=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/?page=1&pageSize=1&query=example", config)
  .then(response => {
    console.log('Successfully retrieved response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/?page=1&pageSize=1&query=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Successfully got response:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/?page=1&pageSize=1&query=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'An error occurred during the request: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "count": integer
  "next"?: string (uri) // optional
  "previous"?: string (uri) // optional
  "results": [
    {
      "id": string (uuid)
      "name": string
      "type": 
      {
      }
      "permissions": [
        {
          "id": string (uuid)
          "name": string
          "description"?: string // optional
        }
      ]
      "createdAt": string (timestamp)
    }
  ]
}
```

**Response Example Value**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response String",
      "type": {},
      "permissions": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Response String",
          "description": "Response String"
        }
      ],
      "createdAt": "Response String"
    }
  ]
}
```

***

### Get Role Details <a href="#undefined" id="undefined"></a>

GET `/api/organizations/{organizationPk}/groups/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `id`             | ✅        | string | A UUID string identifying this Group.          |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Call API Example (Shell)
curl -X GET "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and check the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Successfully retrieved response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Successfully got response:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully got response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Error during request: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "permissions": [
    {
      "id": string (uuid)
      "name": string
      "description"?: string // Optional
    }
  ]
  "createdAt": string (timestamp)
}
```

**Response Example Value**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response String",
  "type": {},
  "permissions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response String",
      "description": "Response String"
    }
  ],
  "createdAt": "Response String"
}
```

***

### Get Role Member List <a href="#undefined" id="undefined"></a>

GET `/api/organizations/{organizationPk}/groups/{groupPk}/group-members/`

#### Parameters

| Parameter Name   | Required | Type    | Description                                    |
| ---------------- | -------- | ------- | ---------------------------------------------- |
| `groupPk`        | ✅        | string  |                                                |
| `organizationPk` | ✅        | string  | A UUID string identifying this organization ID |
| `page`           | ❌        | integer | A page number within the paginated result set. |
| `pageSize`       | ❌        | integer | Number of results to return per page.          |
| `query`          | ❌        | string  |                                                |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/?page=1&pageSize=1&query=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/?page=1&pageSize=1&query=example", config)
  .then(response => {
    console.log('Successfully retrieved response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/?page=1&pageSize=1&query=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Successfully got response:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/?page=1&pageSize=1&query=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'An error occurred during the request: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "count": integer
  "next"?: string (uri) // Optional
  "previous"?: string (uri) // Optional
  "results": [
    {
      "id": string (uuid)
      "member": {
      {
        "id": string (uuid)
        "name": string
        "email": string
        "isOwner": boolean // Check if the member is the organization owner (via OWNER Group)
        "permissions": object
        "createdAt": string (timestamp)
      }
      }
      "createdAt": string (timestamp)
    }
  ]
}
```

**Response Example Value**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "member": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response String",
        "email": "Response String",
        "isOwner": false,
        "permissions": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Example Response Name",
          "description": "Example Response Description"
        },
        "createdAt": "Response String"
      },
      "createdAt": "Response String"
    }
  ]
}
```

***

### View a Specific Role Member <a href="#undefined" id="undefined"></a>

GET `/api/organizations/{organizationPk}/groups/{groupPk}/group-members/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `groupPk`        | ✅        | string |                                                |
| `id`             | ✅        | string | A UUID string identifying this Group Member.   |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Successfully retrieved response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Successfully retrieved response:")
    print(response.json())
except Exception as e:
    print("An error occurred with the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully got response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "id": string (uuid)
  "member": {
  {
    "id": string (uuid)
    "name": string
    "email": string
    "isOwner": boolean // Check if the member is the organization owner (via OWNER Group)
    "permissions": object
    "createdAt": string (timestamp)
  }
  }
  "createdAt": string (timestamp)
}
```

**Response Example Value**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "member": {
    "id": "5e8400-e29b-41d4-a716-446655440000",
    "name": "Response String",
    "email": "Response String",
    "isOwner": false,
    "permissions": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response Sample Name",
      "description": "Response Sample Description"
    },
    "createdAt": "Response String"
  },
  "createdAt": "Response String"
}
```

***

### Get Role's AI Assistant List <a href="#ai" id="ai"></a>

GET `/api/organizations/{organizationPk}/groups/{groupPk}/group-chatbots/`

#### Parameters

| Parameter Name   | Required | Type    | Description                                    |
| ---------------- | -------- | ------- | ---------------------------------------------- |
| `groupPk`        | ✅        | string  |                                                |
| `organizationPk` | ✅        | string  | A UUID string identifying this Organization ID |
| `page`           | ❌        | integer | A page number within the paginated result set. |
| `pageSize`       | ❌        | integer | Number of results to return per page.          |
| `query`          | ❌        | string  |                                                |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/?page=1&pageSize=1&query=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/?page=1&pageSize=1&query=example", config)
  .then(response => {
    console.log('Successfully got response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/?page=1&pageSize=1&query=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Successfully got response:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/?page=1&pageSize=1&query=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully got response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "count": integer
  "next"?: string (uri) // Optional
  "previous"?: string (uri) // Optional
  "results": [
    {
      "id": string (uuid)
      "group": string (uuid)
      "chatbot": { // Adds nested create feature
      {
        "id": string (uuid)
        "name": string // The name of the chatbot. In Agent mode, it has semantic meaning; in other modes, it's just used to differentiate between different chatbots.
        "rag"?: string (uuid) // RAG (Retrieval-Augmented Generation) settings, used to enhance response quality (Optional)
        "largeLanguageModel": string (uuid) // The large language model used by the chatbot to generate responses.
        "embeddingModel"?: string (uuid) // The embedding model used for vectorizing text, an optional item (Optional)
        "rerankerModel"?: string (uuid) // Optional
        "instructions"?: string // The role instructions for the chatbot, used to describe its role and behavior (Optional)
        "knowledgeBases"?: [ // A list of knowledge bases accessible to the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
          }
        ]
        "updatedAt": string (timestamp)
        "organization"?: string (uuid) // The organization the chatbot belongs to. If null, it's a personal chatbot (Optional)
        "builtInWorkflow"?: string (uuid) // Built-in workflow for predefined processing flows (Optional)
        "replyMode"?:  // Reply mode: normal reply or streaming reply

* `normal` - Normal
* `template` - Template
* `hybrid` - Hybrid
* `workflow` - Workflow
* `agent` - Agent (Optional)
        {
        }
        "template"?: string // The template used in template mode and hybrid mode (Optional)
        "unanswerableTemplate"?: string // The template used when template mode or hybrid mode cannot provide an answer (Optional)
        "totalWordsCount"?: integer (int64) // Cumulative total word count used (Optional)
        "outputMode"?:  // Output mode: text, table, or custom format

* `text` - Text
* `json_schema` - JSON Schema (Optional)
        {
        }
        "rawOutputFormat"?: object // JSON structure definition for custom output format (Optional)
        "databaseUrl"?: string // Database connection URL (for database query functionality) (Optional)
        "databaseType"?: string // Database type options, including MySQL, PostgreSQL, MSSQL, Oracle (Optional)
        "includeTables"?: object // List of included tables (for database query functionality) (Optional)
        "groups"?: [ // List of groups accessible to the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
          }
        ]
        "toolkits"?: [ // List of toolkits used by the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
            "description": string
            "displayName": string
            "toolType": string
          }
        ]
        "tools"?: [ // List of tools usable by the chatbot (Optional)
          {
            "id": string (uuid)
            "name": string
            "description": string
            "displayName": string
            "toolType": string
          }
        ]
        "agentMode"?:  // Agent mode: normal, SQL, or workflow mode

* `normal` - Normal
* `canvas` - Canvas (Optional)
        {
        }
        "numberOfRetrievedChunks"?: integer // The number of retrieved reference chunks, default is 12, minimum is 1 (Optional)
        "enableEvaluation"?: boolean // Optional
        "enableInLineCitations"?: boolean // Enable inline citations, which will insert citation markers in [1][2] format in the response (Optional)
      }
      }
      "createdAt": string (timestamp)
    }
  ]
}
```

**Response Example Value**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "group": "550e8400-e29b-41d4-a716-446655440000",
      "chatbot": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response string",
        "rag": "550e8400-e29b-41d4-a716-446655440000",
        "largeLanguageModel": "550e8400-e29b-41d4-a716-446655440000",
        "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
        "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
        "instructions": "Response string",
        "knowledgeBases": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "Response string"
          }
        ],
        "updatedAt": "Response string",
        "organization": "550e8400-e29b-41d4-a716-446655440000",
        "builtInWorkflow": "550e8400-e29b-41d4-a716-446655440000",
        "replyMode": {},
        "template": "Response string",
        "unanswerableTemplate": "Response string",
        "totalWordsCount": 456,
        "outputMode": {},
        "rawOutputFormat": null,
        "databaseUrl": "Response string",
        "databaseType": "Response string",
        "includeTables": null,
        "groups": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "Response string"
          }
        ],
        "toolkits": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "Response string",
            "description": "Response string",
            "displayName": "Response string",
            "toolType": "Response string"
          }
        ],
        "tools": [
          {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "Response string",
            "description": "Response string",
            "displayName": "Response string",
            "toolType": "Response string"
          }
        ],
        "agentMode": {},
        "numberOfRetrievedChunks": 456,
        "enableEvaluation": false,
        "enableInLineCitations": false
      },
      "createdAt": "Response string"
    }
  ]
}
```

***

### Update Role Permissions <a href="#undefined" id="undefined"></a>

PUT `/api/organizations/{organizationPk}/groups/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `id`             | ✅        | string | A UUID string identifying this Group.          |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Request Body

**Request Parameters**

| Field        | Type           | Required | Description |
| ------------ | -------------- | -------- | ----------- |
| name         | string         | Yes      |             |
| organization | string (uuid)  | No       |             |
| permissions  | array\[string] | Yes      |             |

**Request Structure Example**

```typescript
{
  "name": string
  "organization"?: string (uuid) // Optional
  "permissions": [
    string (uuid)
  ]
}
```

**Request Example Value**

```json
{
  "name": "Example Name",
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "permissions": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X PUT "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example Name",
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "permissions": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "name": "Example Name",
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "permissions": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.put("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
      "name": "Sample Name",
      "organization": "550e8400-e29b-41d4-a716-446655440000",
      "permissions": [
        "550e8400-e29b-41d4-a716-446655440000"
      ]
    }

response = requests.put(url, json=data, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => {
            "name": "Sample Name",
            "organization": "550e8400-e29b-41d4-a716-446655440000",
            "permissions": [
                "550e8400-e29b-41d4-a716-446655440000"
            ]
        }
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "permissions": [
    {
      "id": string (uuid)
      "name": string
      "description"?: string // optional
    }
  ]
  "createdAt": string (timestamp)
}
```

**Response Example Value**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response String",
  "type": {},
  "permissions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response String",
      "description": "Response String"
    }
  ],
  "createdAt": "Response String"
}
```

***

### Partially Update Role Permissions <a href="#undefined" id="undefined"></a>

PATCH `/api/organizations/{organizationPk}/groups/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `id`             | ✅        | string | A UUID string identifying this Group.          |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Request Body

**Request Parameters**

| Field        | Type           | Required | Description |
| ------------ | -------------- | -------- | ----------- |
| name         | string         | No       |             |
| organization | string (uuid)  | No       |             |
| permissions  | array\[string] | No       |             |

**Request Structure Example**

```typescript
{
  "name"?: string // Optional
  "organization"?: string (uuid) // Optional
  "permissions"?: [ // Optional
    string (uuid)
  ]
}
```

**Request Example Value**

```json
{
  "name": "Example Name",
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "permissions": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Call API Example (Shell)
curl -X PATCH "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example Name",
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "permissions": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "name": "Example Name",
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "permissions": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.patch("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
      "name": "Sample Name",
      "organization": "550e8400-e29b-41d4-a716-446655440000",
      "permissions": [
        "550e8400-e29b-41d4-a716-446655440000"
      ]
    }

response = requests.patch(url, json=data, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => {
            "name": "Example Name",
            "organization": "550e8400-e29b-41d4-a716-446655440000",
            "permissions": [
                "550e8400-e29b-41d4-a716-446655440000"
            ]
        }
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "permissions": [
    {
      "id": string (uuid)
      "name": string
      "description"?: string // optional
    }
  ]
  "createdAt": string (timestamp)
}
```

**Response Example Value**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response String",
  "type": {},
  "permissions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response String",
      "description": "Response String"
    }
  ],
  "createdAt": "Response String"
}
```

***

### Delete Role <a href="#undefined" id="undefined"></a>

DELETE `/api/organizations/{organizationPk}/groups/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `id`             | ✅        | string | A UUID string identifying this Group.          |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// Request payload
const data = null;

axios.delete("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred during the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'An error occurred during the request: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

| Status Code | Description      |
| ----------- | ---------------- |
| 204         | No response body |

***

### Remove Role Member <a href="#undefined" id="undefined"></a>

DELETE `/api/organizations/{organizationPk}/groups/{groupPk}/group-members/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `groupPk`        | ✅        | string |                                                |
| `id`             | ✅        | string | A UUID string identifying this Group Member.   |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// Request payload
const data = null;

axios.delete("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred during the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-members/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

| Status Code | Description      |
| ----------- | ---------------- |
| 204         | No response body |

***

### Remove AI Assistant from Role <a href="#ai" id="ai"></a>

DELETE `/api/organizations/{organizationPk}/groups/{groupPk}/group-chatbots/{id}/`

#### Parameters

| Parameter Name   | Required | Type   | Description                                    |
| ---------------- | -------- | ------ | ---------------------------------------------- |
| `groupPk`        | ✅        | string |                                                |
| `id`             | ✅        | string | A UUID string identifying this Group Chatbot.  |
| `organizationPk` | ✅        | string | A UUID string identifying this Organization ID |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.
```

{% endtab %}

{% tab title="JavaScript" %}

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

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// Request payload
const data = null;

axios.delete("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Successfully received response:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('An error occurred with the request:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("Successfully received response:")
    print(response.json())
except Exception as e:
    print("An error occurred during the request:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/group-chatbots/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Successfully received response:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'An error occurred with the request: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

| Status Code | Description      |
| ----------- | ---------------- |
| 204         | No response body |

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/api/api-doc-en/api-reference/jue-se-he-quan-xian.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
