:doc:`Organizations <../../organizations>` / Client / delete_organizational_unit

**************************
delete_organizational_unit
**************************



.. py:method:: Organizations.Client.delete_organizational_unit(**kwargs)

  

  Deletes an organizational unit (OU) from a root or another OU. You must first remove all accounts and child OUs from the OU that you want to delete.

   

  You can only call this operation from the management account.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/organizations-2016-11-28/DeleteOrganizationalUnit>`_  


  **Request Syntax**
  ::

    response = client.delete_organizational_unit(
        OrganizationalUnitId='string'
    )
    
  :type OrganizationalUnitId: string
  :param OrganizationalUnitId: **[REQUIRED]** 

    ID for the organizational unit that you want to delete. You can get the ID from the  ListOrganizationalUnitsForParent operation.

     

    The `regex pattern <http://wikipedia.org/wiki/regex>`__ for an organizational unit ID string requires "ou-" followed by from 4 to 32 lowercase letters or digits (the ID of the root that contains the OU). This string is followed by a second "-" dash and from 8 to 32 additional lowercase letters or digits.

    

  
  
  :returns: None
  **Exceptions**
  
  *   :py:class:`Organizations.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`Organizations.Client.exceptions.AWSOrganizationsNotInUseException`

  
  *   :py:class:`Organizations.Client.exceptions.ConcurrentModificationException`

  
  *   :py:class:`Organizations.Client.exceptions.InvalidInputException`

  
  *   :py:class:`Organizations.Client.exceptions.OrganizationalUnitNotEmptyException`

  
  *   :py:class:`Organizations.Client.exceptions.OrganizationalUnitNotFoundException`

  
  *   :py:class:`Organizations.Client.exceptions.ServiceException`

  
  *   :py:class:`Organizations.Client.exceptions.TooManyRequestsException`

  

  **Examples**

  The following example shows how to delete an OU. The example assumes that you previously removed all accounts and other OUs from the OU:


  ::

    response = client.delete_organizational_unit(
        OrganizationalUnitId='ou-examplerootid111-exampleouid111',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'ResponseMetadata': {
            '...': '...',
        },
    }

  