# Beta.ServiceAccounts ## Overview ### Available Operations * [create](#create) - Create Service Account * [list](#list) - List Service Accounts * [list_assignable_roles](#list_assignable_roles) - List Assignable Service Account Roles * [get](#get) - Get Service Account * [update](#update) - Update Service Account * [delete](#delete) - Delete Service Account * [set_roles](#set_roles) - Set Service Account Roles * [list_roles](#list_roles) - List Service Account Roles ## create Create a service account in a workspace. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.create(name="", workspace_id="cf2146d0-158c-4b19-b8b1-ca0c68f41143") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | `name` | *str* | :heavy_check_mark: | N/A | | `workspace_id` | *str* | :heavy_check_mark: | N/A | | `description` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | `role_ids` | List[*str*] | :heavy_minus_sign: | Workspace role UUIDs to assign. Omitted or empty lists default to member, which grants no role permissions. Workspace-wide sharing may still grant access. | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response **[models.ServiceAccount](../../models/serviceaccount.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## list List the service accounts in a workspace, or across the organization. Scoped to a workspace, this requires the Workspace admin (`workspace_admin`) role on it. Omitting the workspace lists the whole organization and requires the Organization admin (`organization_admin`) role instead. ``q`` narrows the list to accounts whose name or description contains it. ``order`` sorts by creation time (ascending by default). ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.list(offset=251948, limit=234499, workspace_id="96e67917-4b94-4dc0-b61a-bd713aa8a4e6", include_deleted=False) while res is not None: # Handle items res = res.next() ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `offset` | *int* | :heavy_check_mark: | N/A | | `limit` | *int* | :heavy_check_mark: | N/A | | `workspace_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | `include_deleted` | *Optional[bool]* | :heavy_minus_sign: | N/A | | `q` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | `order` | [Optional[models.SortOrder]](../../models/sortorder.md) | :heavy_minus_sign: | Direction to sort a service-account listing by creation time. | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response **[models.ListServiceAccountsV1ServiceAccountsGetResponse](../../models/listserviceaccountsv1serviceaccountsgetresponse.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## list_assignable_roles List the workspace roles that can be assigned to a service account. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.list_assignable_roles(workspace_id="e9326c4d-7aff-483b-9353-303bf1802e99") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `workspace_id` | *str* | :heavy_check_mark: | N/A | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response **[models.ListAssignableServiceAccountRolesResponse](../../models/listassignableserviceaccountrolesresponse.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## get Retrieve a service account. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.get(service_account_id="68d1ecd2-32cb-473b-ae76-6d87e59f4cd1") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `service_account_id` | *str* | :heavy_check_mark: | N/A | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response **[models.ServiceAccount](../../models/serviceaccount.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## update Update a service account. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.update(service_account_id="2f4d1ce1-d8ad-4a87-b31b-308088fc2a76") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `service_account_id` | *str* | :heavy_check_mark: | N/A | | `description` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response **[models.ServiceAccount](../../models/serviceaccount.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## delete Delete a service account. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: mistral.beta.service_accounts.delete(service_account_id="10f960e0-abaa-4060-9000-249255e07c45") # Use the SDK ... ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `service_account_id` | *str* | :heavy_check_mark: | N/A | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## set_roles Replace the workspace roles assigned to a service account. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.set_roles(service_account_id="d4686916-124a-42f1-966f-9248b120b13c", role_ids=[ "7e69e493-caf6-4671-af60-84951754d9fc", ]) # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | Example | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `service_account_id` | *str* | :heavy_check_mark: | N/A | | | `role_ids` | List[*str*] | :heavy_check_mark: | Workspace role UUIDs to assign. Required and non-empty; omitted or empty lists return 422. Select member explicitly for no role-granted permissions; workspace-wide sharing may still grant access. | [
"7e69e493-caf6-4671-af60-84951754d9fc"
] | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | ### Response **[models.ListServiceAccountRolesResponse](../../models/listserviceaccountrolesresponse.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## list_roles List the workspace roles assigned to a service account. Requires the Workspace admin (`workspace_admin`) role. ### Example Usage ```python from mistralai.client import Mistral import os with Mistral( api_key=os.getenv("MISTRAL_API_KEY", ""), ) as mistral: res = mistral.beta.service_accounts.list_roles(service_account_id="0c629f5d-1a74-4b83-a740-14410ecdea21") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | `service_account_id` | *str* | :heavy_check_mark: | N/A | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | ### Response **[models.ListServiceAccountRolesResponse](../../models/listserviceaccountrolesresponse.md)** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* |