import Global from '../../_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# spo term list

Lists taxonomy terms from the given term set

## Usage

```sh
m365 spo term list [options]
```

## Options

```md definition-list
`-u, --webUrl [webUrl]`
: If specified, allows you to list terms from the tenant term store as well as the sitecollection specific term store. Defaults to the tenant admin site.

`--termGroupId [termGroupId]`
: ID of the term group where the term set is located. Specify `termGroupId` or `termGroupName` but not both.

`--termGroupName [termGroupName]`
: Name of the term group where the term set is located. Specify `termGroupId` or `termGroupName` but not both.

`--termSetId [termSetId]`
: ID of the term set for which to retrieve terms. Specify `termSetId` or `termSetName` but not both.

`--termSetName [termSetName]`
: Name of the term set for which to retrieve terms. Specify `termSetId` or `termSetName` but not both.

`--withChildTerms`
: If specified, child terms are loaded as well.
```

<Global />

## Remarks

:::info

To use this command without the --webUrl option you have to have permissions to access the tenant admin site.

:::

When using the `--webUrl` option you can connect to the term store with limited permissions, and do not need the SharePoint Administrator role. You need to be a site visitor or more. It allows you to list terms from the tenant term store as well as terms from the sitecollection term store.

## Examples

List taxonomy terms from the specified sitecollection, the term group and term set with the given name

```sh
m365 spo term list --webUrl https://contoso.sharepoint.com/sites/project-x --termGroupName PnPTermSets --termSetName PnP-Organizations
```

List taxonomy terms from the term group and term set with the given name.

```sh
m365 spo term list --termGroupName PnPTermSets --termSetName PnP-Organizations
```

List taxonomy terms from the term group and term set with the given ID.

```sh
m365 spo term list --termGroupId 0e8f395e-ff58-4d45-9ff7-e331ab728beb --termSetId 0e8f395e-ff58-4d45-9ff7-e331ab728bec
```

List taxonomy terms from the term group and term set with the given ID including child terms if any are found.

```sh
m365 spo term list --termGroupId 0e8f395e-ff58-4d45-9ff7-e331ab728beb --termSetId 0e8f395e-ff58-4d45-9ff7-e331ab728bec --withChildTerms
```

## Response

### Standard response

<Tabs>
  <TabItem value="JSON">

  ```json
  [
    {
      "_ObjectType_": "SP.Taxonomy.Term",
      "_ObjectIdentity_": "430486a0-200a-6000-02cc-2eb89d8dd424|fec14c62-7c3b-481b-851b-c80d7802b224:te:kTm3XibpGUiE5nxBtVMTf14Jch8b6X1EtvEo9yq4/mCesjVWlBPHRaBqFOZeTRSNsaKRf7N4K0qppo4zwLIRZg==",
      "CreatedDate": "2021-10-12T09:42:44.880Z",
      "Id": "7f91a2b1-78b3-4a2b-a9a6-8e33c0b21166",
      "LastModifiedDate": "2021-10-12T09:42:45.237Z",
      "Name": "Departments",
      "CustomProperties": {},
      "CustomSortOrder": null,
      "IsAvailableForTagging": true,
      "Owner": "i:0#.f|membership|admin@contoso.onmicrosoft.com",
      "Description": "",
      "IsDeprecated": false,
      "IsKeyword": false,
      "IsPinned": false,
      "IsPinnedRoot": false,
      "IsReused": false,
      "IsRoot": true,
      "IsSourceTerm": true,
      "LocalCustomProperties": {
        "Id": "termDepartments"
      },
      "MergedTermIds": [],
      "PathOfTerm": "Departments",
      "TermsCount": 1
    }
  ]
  ```

  </TabItem>
  <TabItem value="Text">

  ```text
  Id                                    Name      
  ------------------------------------  ---------
  c387e91c-b553-4b92-886b-9af717cd73b0  Financing
  ```

  </TabItem>
  <TabItem value="CSV">

  ```csv
  Id,Name
  c387e91c-b553-4b92-886b-9af717cd73b0,Financing
  ```

  </TabItem>
  <TabItem value="Markdown">

  ```md
  # spo term list --termGroupName "PnPTermSets" --termSetName "PnP-Organizations"

  Date: 5/8/2023

  ## Financing (c387e91c-b553-4b92-886b-9af717cd73b0)

  Property | Value
  ---------|-------
  \_ObjectType\_ | SP.Taxonomy.Term
  \_ObjectIdentity\_ | b6d6b0a0-50c8-2000-41be-bd745120140b\|fec14c62-7c3b-481b-851b-c80d7802b224:te:aCf0Cz4D9UOS7+b/OlUY5XrNqUp10tpPhLK4MIXc7g/qydiOUnAdTKTXucEL/+pvpnFcKyvXqEmjv9gGNthbRA==
  CreatedDate | 2021-07-07T09:42:02.283Z
  Id | c387e91c-b553-4b92-886b-9af717cd73b0
  LastModifiedDate | 2021-07-07T09:42:02.283Z
  Name | Financing
  IsAvailableForTagging | true
  Owner | NT Service\SPTimerV4
  Description |
  IsDeprecated | false
  IsKeyword | false
  IsPinned | false
  IsPinnedRoot | false
  IsReused | false
  IsRoot | true
  IsSourceTerm | true
  PathOfTerm | Financing
  TermsCount | 0
  ```

  </TabItem>
</Tabs>

### `withChildTerms` response

When we make use of the option `withChildTerms` the response will differ. 

<Tabs>
  <TabItem value="JSON">

  ```json
  [
    {
      "_ObjectType_": "SP.Taxonomy.Term",
      "_ObjectIdentity_": "430486a0-200a-6000-02cc-2eb89d8dd424|fec14c62-7c3b-481b-851b-c80d7802b224:te:kTm3XibpGUiE5nxBtVMTf14Jch8b6X1EtvEo9yq4/mCesjVWlBPHRaBqFOZeTRSNsaKRf7N4K0qppo4zwLIRZg==",
      "CreatedDate": "2021-10-12T09:42:44.880Z",
      "Id": "7f91a2b1-78b3-4a2b-a9a6-8e33c0b21166",
      "LastModifiedDate": "2021-10-12T09:42:45.237Z",
      "Name": "Departments",
      "CustomProperties": {},
      "CustomSortOrder": null,
      "IsAvailableForTagging": true,
      "Owner": "i:0#.f|membership|admin@contoso.onmicrosoft.com",
      "Description": "",
      "IsDeprecated": false,
      "IsKeyword": false,
      "IsPinned": false,
      "IsPinnedRoot": false,
      "IsReused": false,
      "IsRoot": true,
      "IsSourceTerm": true,
      "LocalCustomProperties": {
        "Id": "termDepartments"
      },
      "MergedTermIds": [],
      "PathOfTerm": "Departments",
      "TermsCount": 1,
      "Children": [{
        "_ObjectType_": "SP.Taxonomy.Term",
        "_ObjectIdentity_": "d10486a0-4067-5000-de97-bf1ab5bff53c|fec14c62-7c3b-481b-851b-c80d7802b224:te:kTm3XibpGUiE5nxBtVMTf14Jch8b6X1EtvEo9yq4/mCesjVWlBPHRaBqFOZeTRSNf5ybB0mfG0Kx6YO5CODZ1A==",
        "CreatedDate": "2022-12-25T23:59:15.200Z",
        "Id": "079b9c7f-9f49-421b-b1e9-83b908e0d9d4",
        "LastModifiedDate": "2022-12-25T23:59:15.200Z",
        "Name": "Financing",
        "CustomProperties": {},
        "CustomSortOrder": null,
        "IsAvailableForTagging": true,
        "Owner": "i:0#.f|membership|admin@contoso.onmicrosoft.com",
        "Description": "",
        "IsDeprecated": false,
        "IsKeyword": false,
        "IsPinned": false,
        "IsPinnedRoot": false,
        "IsReused": false,
        "IsRoot": false,
        "IsSourceTerm": true,
        "LocalCustomProperties": {},
        "MergedTermIds": [],
        "PathOfTerm": "Departments;Financing",
        "TermsCount": 0
      }]
    }
  ]
  ```

  </TabItem>
  <TabItem value="Text">

  ```text
  Id                                    Name       ParentTermId
  ------------------------------------  ---------  ------------------------------------
  c387e91c-b553-4b92-886b-9af717cd73b0  Financing  079b9c7f-9f49-421b-b1e9-83b908e0d9d4
  ```

  </TabItem>
  <TabItem value="CSV">

  ```csv
  Id,Name,ParentTermId
  c387e91c-b553-4b92-886b-9af717cd73b0,Financing,079b9c7f-9f49-421b-b1e9-83b908e0d9d4
  ```

  </TabItem>
  <TabItem value="Markdown">

  ```md
  # spo term list --termGroupName "PnPTermSets" --termSetName "PnP-Organizations" --withChildTerms "true"

  Date: 5/8/2023

  ## Financing (c387e91c-b553-4b92-886b-9af717cd73b0)

  Property | Value
  ---------|-------
  \_ObjectType\_ | SP.Taxonomy.Term
  \_ObjectIdentity\_ | b6d6b0a0-50c8-2000-41be-bd745120140b\|fec14c62-7c3b-481b-851b-c80d7802b224:te:aCf0Cz4D9UOS7+b/OlUY5XrNqUp10tpPhLK4MIXc7g/qydiOUnAdTKTXucEL/+pvpnFcKyvXqEmjv9gGNthbRA==
  CreatedDate | 2021-07-07T09:42:02.283Z
  Id | c387e91c-b553-4b92-886b-9af717cd73b0
  LastModifiedDate | 2021-07-07T09:42:02.283Z
  Name | Financing
  IsAvailableForTagging | true
  Owner | NT Service\SPTimerV4
  Description |
  IsDeprecated | false
  IsKeyword | false
  IsPinned | false
  IsPinnedRoot | false
  IsReused | false
  IsRoot | true
  IsSourceTerm | true
  PathOfTerm | Financing
  TermsCount | 0
  ```

  </TabItem>
</Tabs>

