:doc:`ComputeOptimizerAutomation <../../compute-optimizer-automation>` / Client / list_accounts

*************
list_accounts
*************



.. py:method:: ComputeOptimizerAutomation.Client.list_accounts(**kwargs)

  

  Lists the accounts in your organization that are enrolled in Compute Optimizer and whether they have enabled Automation.

   

  .. note::

    

    Only the management account or a delegated administrator can perform this action.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/compute-optimizer-automation-2025-09-22/ListAccounts>`_  


  **Request Syntax**
  ::

    response = client.list_accounts(
        maxResults=123,
        nextToken='string'
    )
    
  :type maxResults: integer
  :param maxResults: 

    The maximum number of results to return in a single call.

    

  
  :type nextToken: string
  :param nextToken: 

    The token for the next page of results.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'accounts': [
              {
                  'accountId': 'string',
                  'status': 'Active'|'Inactive'|'Pending'|'Failed',
                  'organizationRuleMode': 'AnyAllowed'|'NoneAllowed',
                  'statusReason': 'string',
                  'lastUpdatedTimestamp': datetime(2015, 1, 1)
              },
          ],
          'nextToken': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **accounts** *(list) --* 

        The list of accounts in your organization enrolled in Compute Optimizer

        
        

        - *(dict) --* 

          Contains information about an Amazon Web Services account's enrollment and association status with Compute Optimizer Automation.

          
          

          - **accountId** *(string) --* 

            The ID of the Amazon Web Services account.

            
          

          - **status** *(string) --* 

            The enrollment status of the account: Active, Inactive, Pending, or Failed.

            
          

          - **organizationRuleMode** *(string) --* 

            Specifies whether the management account can create Automation rules that implement optimization actions for this account.

            
          

          - **statusReason** *(string) --* 

            The reason for the current Automation enrollment status.

            
          

          - **lastUpdatedTimestamp** *(datetime) --* 

            The timestamp when the account's Automation enrollment status was last updated.

            
      
    
      

      - **nextToken** *(string) --* 

        The token to use to retrieve the next page of results.

        
  
  **Exceptions**
  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.InvalidParameterValueException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.ForbiddenException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.OptInRequiredException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.ThrottlingException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.InternalServerException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.NotManagementAccountException`

  
  *   :py:class:`ComputeOptimizerAutomation.Client.exceptions.ServiceUnavailableException`

  