Hi @Chang, Linda
Thank you for reaching out to Microsoft Q&A.
You can refer below steps to create an Azure devops release pipeline via Rest API:
REST API – Create Release Pipeline (Release Definition)
Endpoint
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=7.1-preview.4
Replace:
-
{organization}→ your Azure DevOps org name -
{project}→ your project name
Headers (Postman)
Content-Type: application/json
Authorization: Basic <BASE64_ENCODED_PAT>
PAT format
username:PAT
Sample Request Body (Minimal Working Release Pipeline)
{
"name": "Sample-Release-Pipeline",
"description": "Release pipeline created using REST API",
"releaseNameFormat": "Release-$(rev:r)",
"artifacts": [
{
"alias": "BuildArtifact",
"type": "Build",
"definitionReference": {
"definition": {
"id": "12",
"name": "Sample-Build-Pipeline"
},
"project": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "MyProject"
}
},
"isPrimary": true
}
],
"environments": [
{
"name": "Dev",
"rank": 1,
"conditions": [],
"preDeployApprovals": {
"approvals": [],
"approvalOptions": {
"requiredApproverCount": null,
"releaseCreatorCanBeApprover": false,
"autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped": false
}
},
"deployPhases": [
{
"name": "Agent phase",
"phaseType": "agentBasedDeployment",
"rank": 1,
"deploymentInput": {
"queueId": 1,
"agentSpecification": {
"identifier": "windows-latest"
}
},
"workflowTasks": []
}
],
"environmentOptions": {
"emailNotificationType": "OnlyOnFailure",
"emailRecipients": "release.environment.owner"
}
}
],
"triggers": [],
"variables": {
"Env": {
"value": "Dev",
"allowOverride": false
}
}
}