Overview
This blog will help us understand how to use Managed Metadata Services (MMS) REST API in an SPFx solution and what endpoints are available in MMS REST API
In the latest release of SharePoint Online, REST APIs Microsoft Team came up with REST APIs for MMS. They came up with below entities in TermStore which can be manipulated:
- Groups
- Term Sets
- Terms
Let's see all the CRUD Operations available for the entities.
Groups
We can do all the CRUD operations on Groups. For all the below operations, we require a Bearer Token. To fetch this bearer token, please follow my below blog.
For SPFx sample Code, use this link.
Read
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups
- Method : GET
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
Output
- {
- "@odata.context": "https://testinglala.sharepoint.com/_api/v2.1/$metadata#termStores('root')/groups",
- "value": [
- {
- "id": "f27b8ac4-c866-4f3c-8d12-9848809e983a",
- "description": "From Code",
- "name": "New Group",
- "createdDateTime": "2020-05-16T07:54:11.1Z",
- "lastModifiedDateTime": "2020-05-16T07:54:11.11Z",
- "type": "RegularGroup"
- },
- {
- "id": "122d92ab-d7a8-479f-9888-8d4421f8218f",
- "description": "",
- "name": "People",
- "createdDateTime": "2019-11-05T02:32:07.853Z",
- "lastModifiedDateTime": "2020-05-16T06:48:46.76Z",
- "type": "RegularGroup"
- },
- {
- "id": "d87b6a37-c801-4a36-9046-6296d4779c87",
- "description": "",
- "name": "Search Dictionaries",
- "createdDateTime": "2020-04-21T11:49:57.587Z",
- "lastModifiedDateTime": "2020-05-16T06:48:41.65Z",
- "type": "RegularGroup"
- }
- ]
- }
Create
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups
- Method : POST
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
- Body : {"name":"FromRESTAPI", "description":"Description For FromRESTAPI"}

Update
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/bea867f8-9348-4ea4-976e-21f79f4f3212
- Method : PATCH
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
- Body : {"name":"FromRESTAPI", "description":"Updated Description For FromRESTAPI"}

Delete
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/bea867f8-9348-4ea4-976e-21f79f4f3212
- Method : DELETE
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
Please note that the response code is 204 when successfully executed.
Term Sets
We can do all the CRUD operations on Term Sets. Please note that for example purposes, we are using People Group which can be viewed in the first image in the Groups REST API.
Read
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets
- Method : GET
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
Output
- {
- "@odata.context": "https://testinglala.sharepoint.com/_api/v2.1/$metadata#termStores('root')/groups('122d92ab-d7a8-479f-9888-8d4421f8218f')/sets",
- "value": [
- {
- "id": "8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f",
- "description": "",
- "childrenCount": 1,
- "createdDateTime": "2019-11-05T02:32:07.89Z",
- "isOpen": true,
- "groupId": "122d92ab-d7a8-479f-9888-8d4421f8218f",
- "localizedNames": [
- {
- "name": "Department",
- "languageTag": "en-US"
- }
- ]
- },
- {
- "id": "386095d1-c68d-4c6d-b587-48ddaf1aecc9",
- "description": "",
- "childrenCount": 2,
- "createdDateTime": "2019-11-05T02:32:07.887Z",
- "isOpen": true,
- "groupId": "122d92ab-d7a8-479f-9888-8d4421f8218f",
- "localizedNames": [
- {
- "name": "Job Title",
- "languageTag": "en-US"
- }
- ]
- },
- {
- "id": "b49f64b3-4722-4336-9a5c-56c326b344d4",
- "description": "",
- "childrenCount": 0,
- "createdDateTime": "2019-11-05T02:32:07.89Z",
- "isOpen": true,
- "groupId": "122d92ab-d7a8-479f-9888-8d4421f8218f",
- "localizedNames": [
- {
- "name": "Location",
- "languageTag": "en-US"
- }
- ]
- }
- ]
- }
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets
- Method : POST
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
- Body : {"description": "","localizedNames": [{"name": "OperationLevel","languageTag": "en-US"}]}

Update
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/dbc06a0b-7f38-42dc-84a7-0b734f350303
- Method : PATCH
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
- Body : {"description": "Added description","localizedNames": [{"name": "OperationLevelUpdated","languageTag": "en-US"}]}

Delete
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/dbc06a0b-7f38-42dc-84a7-0b734f350303
- Method : DELETE
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
Terms
Read
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms
- Method : GET
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
Output
- {
- "@odata.context": "https://testinglala.sharepoint.com/_api/v2.1/$metadata#termStores('root')/groups('122d92ab-d7a8-479f-9888-8d4421f8218f')/sets('8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f')/terms",
- "value": [
- {
- "id": "4ac622b1-330b-4aaa-a4fc-6946260948b7",
- "isDeprecated": false,
- "childrenCount": 0,
- "createdDateTime": "2020-04-05T04:34:48.203Z",
- "lastModifiedDateTime": "2020-05-16T02:52:39.5Z",
- "labels": [
- {
- "name": "Digital",
- "isDefault": true,
- "languageTag": "en-US"
- }
- ],
- "descriptions": [
- {
- "description": "Digital Innovation",
- "languageTag": "en-US"
- }
- ],
- "isAvailableForTagging": [
- {
- "setId": "8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f",
- "isAvailable": true
- }
- ]
- }
- ]
- }
Create
Note
The endpoint use in this REST API is different compared to the others here. You can see that "children" is used instead of "terms"
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/children
- Method : POST
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
- Body : {"labels": [{"name": "AI","isDefault":true,"languageTag": "en-US"}],"descriptions": [{"description": "AI Innovation","languageTag": "en-US"}]}

Update
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms/b8b3e828-cdf7-46b2-889e-f5f797a05aa3
- Method : PATCH
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}
- Body : {"labels": [{"name": "AI Updated","isDefault":true,"languageTag": "en-US"}],"descriptions": [{"description": "AI Innovation Updated","languageTag": "en-US"}]}

Delete
- Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms/b8b3e828-cdf7-46b2-889e-f5f797a05aa3
- Method : DELETE
- Headers : {"Content-Type": "application/json",
- "Authorization": "Bearer <Bearer Token>"}

Tejas darjiPosted Apr 26, 2023, 10:29 AM
How can we get parentId or PathOfTerm on this?
AlessandroPosted Dec 16, 2021, 1:53 PM
How can i search directly a specific termName in a specific language? In Terms Read method, i 'can't specify any term name. where can i found documentation for rest http ?
Andre TerbrackPosted Dec 10, 2020, 1:03 PM
Hi, do you have any experience with custom properties? How to get this information?
Paul HillPosted Sep 8, 2020, 9:07 AM
This information has been very useful - I'm writing client names into the default label and description fields in a termset on add and update of a SharePoint list using Power Automate. The only thing I've struggled with is when a client name is entered with an ampersand or forward slash character in it the REST POST or PATCH call fails. If I escape the ampersand to %26 and the slash to %2F it executes but the %26 and %2f text is written to the term. Do you have any suggestions or ideas on how to get round that?