---
title: Execute an Azure DevOps API
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/azure/azure-devops-api
---

The Azure DevOps API action enables you to call any [Azure DevOps REST API](https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-7.1) directly from your workflows, without needing a dedicated action for each operation.

## Execute an Azure DevOps API [#azure-devops-api]

This action allows you to execute any operation documented in the [Azure DevOps REST API reference](https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-7.1). Provide the organization, API path, HTTP method, and optional request body — the action handles authentication automatically.

### Inputs

The following inputs are available for this action:

| Input Field    | Optionality | Type   | Description                                                                                                                                                                                                                            |
| -------------- | ----------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clientId`     | Required    | String | An Azure Service Principal clientId (UUID format). Pass as a secret. See how to [register an Azure app.](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/api/register-app-for-token?tabs=portal)                            |
| `clientSecret` | Required    | String | An Azure Service Principal clientSecret. Pass as a secret. See how to [register an Azure app.](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/api/register-app-for-token?tabs=portal)                                      |
| `tenantId`     | Required    | String | The Azure tenant identifier (UUID format). You can pass as a secret.                                                                                                                                                                   |
| `organization` | Required    | String | The name of the Azure DevOps organization. Example: `"myOrganization"`                                                                                                                                                                 |
| `urlPath`      | Required    | String | The URL path for the [Azure DevOps REST API](https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-7.1) request (max length 1000). Example: `"/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.0"` |
| `method`       | Required    | String | One of [`"GET", "POST", "PUT", "PATCH", "DELETE"`]                                                                                                                                                                                     |
| `body`         | Optional    | Map    | An optional body as a JSON map. Pass it with `PUT`, `PATCH`, and `POST` methods when the request requires a body. Supports secret references.                                                                                          |
| `selectors`    | Optional    | List   | A list of JQ expressions to extract values from the response. Each selector maps a name to a JQ expression. Example: `[{"name": "pipelineId", "expression": ".response.id"}]`                                                          |

### Outputs

This action returns the following outputs:

| Output Field        | Type    | Description                                                                                                                                                                                                                         |
| ------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `success`           | Boolean | `success: true | false`                                                                                                                                                                                                             |
| `errorMessage`      | String  | Contains the failure reason if the action fails.                                                                                                                                                                                    |
| `response`          | Object  | `<azure devops api body response>` Each API endpoint returns a different response. See [Azure DevOps REST API reference](https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-7.1#process-the-response). |
| `asyncResponseUrl`  | String  | The URL to poll for async operations. Read `status` or `state` from `response` to track completion.                                                                                                                                 |
| `retryAfterSeconds` | Integer | Wait time in seconds the server recommends before retrying or polling the async URL.                                                                                                                                                |

### Example

#### Example: Get projects

```yaml
  - name: getProjects
    type: action
    action: azure.devops.api
    version: 1
    inputs:
      clientId: ${{ :secrets:azure-client-id }}
      clientSecret: ${{ :secrets:azure-client-secret }}
      tenantId: ${{ :secrets:azure-client-tenant }}
      organization: ${{ :secrets:organization }}
      urlPath: _apis/projects
      method: GET
```

#### Example: Create a pipeline

```yaml
  - name: createPipeline
    type: action
    action: azure.devops.api
    version: 1
    inputs:
      clientId: ${{ :secrets:azure-client-id }}
      clientSecret: ${{ :secrets:azure-client-secret }}
      tenantId: ${{ :secrets:azure-client-tenant }}
      organization: ${{ :secrets:organization }}
      urlPath: myProject/_apis/pipelines?api-version=7.1
      method: POST
      body:
        name: testPipeline
        folder: \
        configuration:
          type: yaml
          path: pipelineConfig.yml
          repository:
            id: 1a8bcfa4-1412-4b3b-af36-4ff1aa5860a1
            name: testRepository
            type: azureReposGit
      selectors:
        - name: pipelineId
          expression: .response.id
        - name: pipelineName
          expression: .response.name
```

#### Example: Run a pipeline

```yaml
  - name: runPipeline
    type: action
    action: azure.devops.api
    version: 1
    inputs:
      clientId: ${{ :secrets:azure-client-id }}
      clientSecret: ${{ :secrets:azure-client-secret }}
      tenantId: ${{ :secrets:azure-client-tenant }}
      organization: ${{ :secrets:organization }}
      urlPath: myProject/_apis/pipelines/1/runs?api-version=7.1-preview.1
      method: POST
      body:
        resources: {}
        variables: {}
```

#### Example: Delete a pipeline

```yaml
  - name: deletePipeline
    type: action
    action: azure.devops.api
    version: 1
    inputs:
      clientId: ${{ :secrets:azure-client-id }}
      clientSecret: ${{ :secrets:azure-client-secret }}
      tenantId: ${{ :secrets:azure-client-tenant }}
      organization: ${{ :secrets:organization }}
      urlPath: myProject/_apis/build/definitions/1?api-version=7.1-preview.7
      method: DELETE
```
