Azure Repos Commits API

Operations for accessing commit details and commit history within a repository, including diffs and changes.

Documentation

Specifications

Other Resources

OpenAPI Specification

microsoft-azure-repo-commits-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Azure Repos Git Commits API
  description: REST API for managing Git repositories, branches, commits, pull requests, pushes, and items in Azure Repos. Provides full programmatic control over Git-based source code hosted in Azure DevOps, including creating and reviewing pull requests, managing branches and tags, browsing repository content, and pushing commits.
  version: '7.1'
  contact:
    name: Microsoft Azure DevOps
    url: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  termsOfService: https://azure.microsoft.com/en-us/support/legal/
servers:
- url: https://dev.azure.com/{organization}/{project}/_apis
  description: Azure DevOps Services
  variables:
    organization:
      description: The name of the Azure DevOps organization
      default: myorganization
    project:
      description: Project ID or project name
      default: myproject
security:
- oauth2: []
- basicAuth: []
tags:
- name: Commits
  description: Operations for accessing commit details and commit history within a repository, including diffs and changes.
paths:
  /git/repositories/{repositoryId}/commits:
    get:
      operationId: commits_list
      summary: Azure Repos List commits
      description: Retrieve commit history for a repository. Supports filtering by branch, author, date range, item path, and various search criteria. Results are ordered by commit date descending.
      tags:
      - Commits
      parameters:
      - $ref: '#/components/parameters/repositoryId'
      - name: searchCriteria.itemVersion.version
        in: query
        description: Branch name or tag to search (e.g., main, develop)
        schema:
          type: string
      - name: searchCriteria.itemVersion.versionType
        in: query
        description: Type of version identifier
        schema:
          type: string
          enum:
          - branch
          - tag
          - commit
      - name: searchCriteria.itemPath
        in: query
        description: Path of an item to filter commits that changed this path
        schema:
          type: string
      - name: searchCriteria.fromDate
        in: query
        description: Start date for filtering commits
        schema:
          type: string
          format: date-time
      - name: searchCriteria.toDate
        in: query
        description: End date for filtering commits
        schema:
          type: string
          format: date-time
      - name: searchCriteria.author
        in: query
        description: Filter by author name or email
        schema:
          type: string
      - name: searchCriteria.$top
        in: query
        description: Maximum number of commits to return
        schema:
          type: integer
          format: int32
      - name: searchCriteria.$skip
        in: query
        description: Number of commits to skip
        schema:
          type: integer
          format: int32
      responses:
        '200':
          description: Successfully retrieved commits
          content:
            application/json:
              schema:
                type: object
                properties:
                  count:
                    type: integer
                  value:
                    type: array
                    items:
                      $ref: '#/components/schemas/GitCommitRef'
        '401':
          description: Unauthorized
        '404':
          description: Repository not found
  /git/repositories/{repositoryId}/commits/{commitId}:
    get:
      operationId: commits_get
      summary: Azure Repos Get a commit
      description: Retrieve a specific commit by its SHA-1 ID. Returns the full commit details including author, committer, message, parent commits, and optionally the list of changes.
      tags:
      - Commits
      parameters:
      - $ref: '#/components/parameters/repositoryId'
      - name: commitId
        in: path
        required: true
        description: The SHA-1 hash of the commit
        schema:
          type: string
      - name: changeCount
        in: query
        description: Maximum number of changes to include
        schema:
          type: integer
          format: int32
      responses:
        '200':
          description: Successfully retrieved commit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GitCommitRef'
        '401':
          description: Unauthorized
        '404':
          description: Commit or repository not found
components:
  schemas:
    GitUserDate:
      type: object
      description: User info and date for Git operations
      properties:
        name:
          type: string
          description: Name of the user
        email:
          type: string
          format: email
          description: Email address of the user
        date:
          type: string
          format: date-time
          description: Date of the Git operation
        imageUrl:
          type: string
          format: uri
          description: Avatar URL for the user
    GitStatus:
      type: object
      description: Status metadata posted by a service or extension against a commit or pull request, such as build results or policy checks.
      properties:
        id:
          type: integer
          format: int32
          description: Status identifier
        state:
          type: string
          enum:
          - notSet
          - pending
          - succeeded
          - failed
          - error
          - notApplicable
          description: State of the status
        description:
          type: string
          description: Status description
        context:
          type: object
          properties:
            name:
              type: string
              description: Name of the status context
            genre:
              type: string
              description: Genre of the status
        targetUrl:
          type: string
          format: uri
          description: URL with status details
        createdBy:
          $ref: '#/components/schemas/IdentityRef'
        creationDate:
          type: string
          format: date-time
        updatedDate:
          type: string
          format: date-time
    GitChange:
      type: object
      description: Represents a change to an item in a commit
      properties:
        changeId:
          type: integer
          format: int32
          description: ID of the change within the group
        changeType:
          type: string
          enum:
          - add
          - edit
          - delete
          - rename
          - merge
          - lock
          - branch
          - rollback
          - none
          description: Type of change made to the item
        item:
          type: object
          description: The affected item
          properties:
            objectId:
              type: string
            originalObjectId:
              type: string
            gitObjectType:
              type: string
            commitId:
              type: string
            path:
              type: string
            url:
              type: string
        originalPath:
          type: string
          description: Original path if the item was renamed
        url:
          type: string
          description: URL to retrieve the item
    IdentityRef:
      type: object
      description: Reference to an Azure DevOps identity (user or group)
      properties:
        id:
          type: string
          format: uuid
          description: Unique identity ID
        displayName:
          type: string
          description: Display name of the identity
        uniqueName:
          type: string
          description: Unique name (typically email)
        url:
          type: string
          format: uri
          description: REST API URL for this identity
        imageUrl:
          type: string
          format: uri
          description: URL to the identity's avatar image
        descriptor:
          type: string
          description: Graph descriptor for the identity
        isContainer:
          type: boolean
          description: Whether this identity is a group
    ResourceRef:
      type: object
      description: Generic reference to a resource
      properties:
        id:
          type: string
          description: Resource ID
        url:
          type: string
          format: uri
          description: Resource URL
    GitCommitRef:
      type: object
      description: Properties describing a Git commit and associated metadata including author, committer, message, and related resources.
      properties:
        commitId:
          type: string
          description: SHA-1 hash of the commit
        author:
          $ref: '#/components/schemas/GitUserDate'
        committer:
          $ref: '#/components/schemas/GitUserDate'
        comment:
          type: string
          description: Commit message
        commentTruncated:
          type: boolean
          description: Whether the comment was truncated
        changeCounts:
          type: object
          description: Counts of change types in the commit
          additionalProperties:
            type: integer
        changes:
          type: array
          items:
            $ref: '#/components/schemas/GitChange'
          description: List of changes in the commit
        parents:
          type: array
          items:
            type: string
          description: SHA-1 hashes of parent commits
        url:
          type: string
          format: uri
          description: REST API URL for this commit
        remoteUrl:
          type: string
          format: uri
          description: Web URL to view the commit
        statuses:
          type: array
          items:
            $ref: '#/components/schemas/GitStatus'
          description: Status checks posted against this commit
        workItems:
          type: array
          items:
            $ref: '#/components/schemas/ResourceRef'
          description: Linked work items
        push:
          type: object
          description: Push that included this commit
          properties:
            pushId:
              type: integer
              format: int32
            date:
              type: string
              format: date-time
            pushedBy:
              $ref: '#/components/schemas/IdentityRef'
            url:
              type: string
              format: uri
  parameters:
    repositoryId:
      name: repositoryId
      in: path
      required: true
      description: The ID or name of the repository
      schema:
        type: string
  securitySchemes:
    oauth2:
      type: oauth2
      description: OAuth 2.0 authorization code flow for Azure DevOps Services. Requires the vso.code scope for read operations and vso.code_write for write operations.
      flows:
        authorizationCode:
          authorizationUrl: https://app.vssps.visualstudio.com/oauth2/authorize
          tokenUrl: https://app.vssps.visualstudio.com/oauth2/token
          scopes:
            vso.code: Read source code and metadata about commits, changesets, branches, and other version control artifacts
            vso.code_write: Read, create, and manage pull requests and code
            vso.code_manage: Read, create, manage, and delete repositories and branches
    basicAuth:
      type: http
      scheme: basic
      description: HTTP Basic authentication using a Personal Access Token (PAT). Use any string for the username and the PAT as the password.
externalDocs:
  description: Azure DevOps Git REST API Reference
  url: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/?view=azure-devops-rest-7.1