PAT Lifecycle Management Create API Returning 401 Unauthorized Error

Copper Contributor

Hey Everyone,

Hope you all are doing well,

I am trying to create an Azure DevOps Personal Access Token via PAT Lifecycle Management API to utilize Work Items API but I am getting 401 unauthorized Error.
Here's the curl request -
curl --location ''
--header 'Content-Type: application/json'
--header 'Authorization: Basic [Redacted]'
--header 'Cookie: VstsSession=%7B%22PersistentSessionId%22%3A%229e3cefcb-0bf3-42cb-b3e3-9c76748cb94d%22%2C%22PendingAuthenticationSessionId%22%3A%2200000000-0000-0000-0000-000000000000%22%2C%22CurrentAuthenticationSessionId%22%3A%2200000000-0000-0000-0000-000000000000%22%2C%22SignInState%22%3A%7B%7D%7D; X-VSS-UseRequestRouting=True'
--data '
"displayName": "new_token",
"scope": "app_token",
"validTo": "2023-12-01T23:46:23.319Z",
"allOrgs": true
I tried passing the token in different formats like API Key, Basic and Bearer just to hit and try but getting the same error for all of them, Any insights will be highly appreciated.


2 Replies
Check out pre-requisite, looks like your AD token(you) does not have required permission. please reference below article.


Manage personal access tokens using API - Azure DevOps | Microsoft Learn 



It typically related to lack of valid authentication credentials, please verify this part