Webhook Events

Webhooks are currently in beta and schema changes are frequent.

Each webhook event is structured as follows:

{
  "id": "<EVENT_ID>",
  "type": "<EVENT_TYPE>",
  "createdAt": "<UNIX_TIMESTAMP>",
  "data": {
    "object": { ... },
    ... // Additional fields
  }
}
  • id: A unique id to identify this webhook event delivery.
  • type: The triggered webhook event's shortcode.
  • createdAt: A UNIX timestamp of when this event was created.
  • data.object: The object associated with the webhook event. For e.g., in the case of analysis_run.updated webhook event, data.object is an AnalysisRun object.
  • Other than data.object there can be additional fields depending on the webhook event.

Analysis Updated

This event does not conform to the above mentioned webhook event structure and is deprecated in favor of analysis_run.updated event.

Event shortcode: analysis.updated

This event is triggered every time one of the configured analyzer returns a result for a particular run. Note, for a single run, there will be multiple events triggered, one for each analyzer. All the past checks for this run will also be present in the payload (all_checks). The current one is present in current_check.

Sample Payload

{
  "id": "370843415782363013",
  "type": "analysis.updated",
  "created": "2021-09-02T07:58:20.654073",
  "version": "v1.0.0",
  "data": {
    "repository_id": "UmVwb3NpdG9yeTplZGVtZ24=",
    "owner": {
      "id": "T3duZXI6emtyd2t3",
      "login": "acme-corp"
    },
    "last_updated_at": "2021-09-02T07:58:20.101990+00:00",
    "run_id": "ce3844a5-8b09-423c-b020-67d7b0ea9d00",
    "status": "fail",
    "branch_name": "master",
    "commit_sha": "cf5403a9b99384c7e6df02abd935cbda1d979523",
    "total_raised": 110,
    "total_resolved": 0,
    "all_checks": {
      "python": {
        "check_id": "Q2hlY2s6eWx3b2prZw==",
        "raised": 110,
        "resolved": 0
      },
      "javascript": {
        "check_id": "Q2hlY2s6cWRqeWdrZw==",
        "raised": 0,
        "resolved": 0
      }
    },
    "current_check": {
      "python": {
        "check_id": "Q2hlY2s6eWx3b2prZw==",
        "raised": 110,
        "resolved": 0
      }
    },
    "errors": []
  }
}

Analysis Run Updated

Event shortcode: analysis_run.updated

data.object is an AnalysisRun

This event is triggered every time one of the configured analyzer returns a result for a particular run. For a single run, since any number of analyzers can be configured, there will be multiple events triggered: one per analyzer/check.

All the past checks associated with this run will also be present in the payload (checks). The last check in the list is the check that triggered this event.

Sample Payload

{
  "id": "390137996571050950",
  "type": "analysis_run.updated",
  "createdAt": 1642069966,
  "data": {
    "object": {
      "id": "UnVaOmZvcG64eQ==",
      "object": "AnalysisRun",
      "runUid": "75d0dd35-d12c-4f8d-67f1-494b9c1abcdef",
      "status": "PENDING",
      "branchName": "patch-1",
      "baseOid": "07e790b6d5a7e720acf5f2af4b707c2ff1cabceed",
      "commitOid": "99da4fzf3e680e28c3z86afebz3693d3f80bf67b",
      "createdAt": 1642069941,
      "updatedAt": 1642069966,
      "repository": {
        "id": "UmVwb2Npb99yeTp7z3Z23HY=",
        "object": "Repository",
        "name": "demo-go",
        "vcsProvider": "GITHUB",
        "vcsUrl": "https://github.com/deepsourcelabs/demo-go",
        "defaultBranch": "master",
        "latestCommitOid": "07e790b6d5a7e720acf5f2af4b707c2ff1cabceed",
        "isPrivate": false,
        "isActivated": true,
        "account": {
          "id": "T2dzZXIYmm1n2nBi",
          "object": "Account",
          "login": "deepsourcelabs",
          "vcsProvider": "GITHUB",
          "type": "TEAM",
          "avatarUrl": "https://static.deepsource.io/avatars/avatar.png",
          "vcsUrl": "https://github.com/deepsourcelabs"
        }
      },
      "summary": {
        "object": "AnalysisRunSummary",
        "occurrencesIntroduced": 6,
        "occurrencesResolved": 0,
        "occurrenceDistributionByAnalyzer": [
          {
            "object": "OccurrenceDistributionByAnalyzer",
            "analyzerShortcode": "docker",
            "introduced": 0
          },
          {
            "object": "OccurrenceDistributionByAnalyzer",
            "analyzerShortcode": "secrets",
            "introduced": 0
          },
          {
            "object": "OccurrenceDistributionByAnalyzer",
            "analyzerShortcode": "go",
            "introduced": 6
          }
        ],
        "occurrenceDistributionByCategory": [
          {
            "object": "OccurrenceDistributionByCategory",
            "category": "ANTI_PATTERN",
            "introduced": 4
          },
          {
            "object": "OccurrenceDistributionByCategory",
            "category": "BUG_RISK",
            "introduced": 2
          }
        ]
      },
      "checks": [
        {
          "id": "Q5zyY2s2onlyZW53",
          "object": "Check",
          "sequence": 2,
          "status": "PENDING",
          "analyzer": {
            "id": "Q3ZhbZl6ZXI7b1x3cW5i",
            "object": "Analyzer",
            "shortcode": "docker",
            "name": "Docker",
            "logoUrl": "https://static.deepsource.io/analyzer_logos/docker.svg"
          },
          "createdAt": 1642069941,
          "updatedAt": 1642069942,
          "finishedAt": null,
          "summary": {
            "object": "CheckSummary",
            "occurrencesIntroduced": 0,
            "occurrencesResolved": 0,
            "occurrenceDistributionByCategory": []
          }
        },
        {
          "id": "Z8abY2s6YzF4cd5k",
          "object": "Check",
          "sequence": 3,
          "status": "SUCCESS",
          "analyzer": {
            "id": "DZ9hbHl6ZXI6aHpjZW26",
            "object": "Analyzer",
            "shortcode": "secrets",
            "name": "Secrets",
            "logoUrl": "https://static.deepsource.io/analyzer_logos/secrets.svg"
          },
          "createdAt": 1642069941,
          "updatedAt": 1642069946,
          "finishedAt": 1642069945,
          "summary": {
            "object": "CheckSummary",
            "occurrencesIntroduced": 0,
            "occurrencesResolved": 0,
            "occurrenceDistributionByCategory": []
          }
        },
        {
          "id": "P1hlF1s6Ymd2Z3bv",
          "object": "Check",
          "sequence": 1,
          "status": "FAILURE",
          "analyzer": {
            "id": "YU5hbHl6API6c78ieXZ6",
            "object": "Analyzer",
            "shortcode": "go",
            "name": "Go",
            "logoUrl": "https://static.deepsource.io/analyzer_logos/go.svg"
          },
          "createdAt": 1642069941,
          "updatedAt": 1642069966,
          "finishedAt": 1642069966,
          "summary": {
            "object": "CheckSummary",
            "occurrencesIntroduced": 6,
            "occurrencesResolved": 0,
            "occurrenceDistributionByCategory": [
              {
                "object": "OccurrenceDistributionByCategory",
                "category": "ANTI_PATTERN",
                "introduced": 4
              },
              {
                "object": "OccurrenceDistributionByCategory",
                "category": "BUG_RISK",
                "introduced": 2
              }
            ]
          }
        }
      ]
    }
  }
}

Repository Issue Introduced

Event shortcode: repository_issue.introduced

data.object is a RepositoryIssue.

data.issueOccurrencesIntroduced is the total count of issue occurrences introduced.

This event is triggered whenever an issue has been detected in the default branch of the repository.

For instance, if 3 occurrences of issue X and 5 occurrences of issue Y are introduced in the default branch, two events, one for each issue will be triggered.

This event is not triggered for full runs on the default branch. A full run is when your repository's full code base is analyzed. This happens, e.g., when the repository is (re)activated, or if the .deepsource.toml gets updated. This is to prevent noise which can arise from a large number of issues being reported in such runs.

Sample Payload

{
  "id": "380143400734187723",
  "type": "repository_issue.introduced",
  "createdAt": 1642070207,
  "data": {
    "object": {
      "id": "PhVnb3NpdG9yeUl8c3VlOnp4a2E2bA==",
      "object": "RepositoryIssue",
      "repository": {
        "id": "ZAb3b3NpdG9yeTp9b3Z2eHY=",
        "object": "Repository",
        "name": "demo-go",
        "vcsProvider": "GITHUB",
        "vcsUrl": "https://github.com/deepsourcelabs/demo-go",
        "defaultBranch": "master",
        "latestCommitOid": "72df1dcc3dd4d3211746a236f553065416d3766723",
        "isPrivate": false,
        "isActivated": true,
        "account": {
          "id": "Y2duZXI6Y2dd4hBi",
          "object": "Account",
          "login": "deepsourcelabs",
          "vcsProvider": "GITHUB",
          "vcsUrl": "https://github.com/deepsourcelabs",
          "type": "TEAM",
          "avatarUrl": "https://static.deepsource.io/avatar.png"
        }
      },
      "issue": {
        "id": "UIOzdWU6end2b23i",
        "object": "Issue",
        "shortcode": "CRT-A0016",
        "title": "Simplify slice expression to sliced value itself",
        "shortDescription": "If a value is of type slice already, it need not be converted to slice again.",
        "category": "ANTI_PATTERN",
        "autofixAvailable": true,
        "isRecommended": false,
        "analyzer": {
          "id": "TW5hbTl6ZTI6c12ieXZ6",
          "object": "Analyzer",
          "shortcode": "go",
          "name": "Go",
          "logoUrl": "https://static.deepsource.io/analyzer_logos/go.svg"
        }
      },
      "occurrences": [
        {
          "id": "Q10lY2tJc7N1ZTpZeGpxZW9l",
          "object": "Occurrence",
          "title": "could simplify allProducts[:] to allProducts",
          "path": "code.go",
          "beginLine": 160,
          "beginColumn": 14,
          "endLine": 160,
          "endColumn": 14
        }
      ]
    },
    "issueOccurrencesIntroduced": 1
  }
}

Test

Event shortcode: test.event

This event does not correspond to any activity on DeepSource. It is used exclusively for testing and verification of your endpoint.

Sample Payload

{
  "id": "370847944204618991",
  "type": "test.event",
  "createdAt": 1642070207,
  "data": {
    "test": true
  }
}