Create Socket API Key for CI/CD

Create your Socket API Key

You can either create your API key yourself if you have permissions in your socket.dev account or you can have your Admin create it for you with the scopes listed below. (See Notes section below for the environment variable usages)

  1. Log into the socket.dev dashboard

  2. Go to Settings

  3. Go to the API Tokens tab

  4. Select Create API Token

  5. Give the token a name like CI/CD API Key

  6. Select the scopes for the tools your pipeline runs, from Scopes by tool below. If one key is shared across several tools, or you aren't sure, select all of these:

    1. repo

      1. repo:list
      2. repo:create
    2. full-scans

      1. full-scans:list
      2. full-scans:create
    3. diff-scans

      1. diff-scans:list
      2. diff-scans:create
    4. packages

      1. packages:list
    5. socket-basics

      1. socket-basics:read

    Select security-policy → security-policy:read only if the key is used by an npm Socket CLI older than 1.15.0. In those versions, socket ci and socket scan report call the security policy API. From 1.15.0 they grade reports from each alert's action and do not need the scope.

    The dialog lists each scope under its group. Selecting a whole group also works, but grants more than these tools use.

  7. Click Confirm

  8. Click on Show key

  9. Click on the API Key Token to copy


Scopes by tool

Each tool needs a different set of scopes. A key used by only one tool can leave out the rest.

ScopeSocket Python CLI (socketcli)Socket Basics
full-scans:createEvery runUploading results, and Socket Tier 1 reachability
full-scans:listEvery run that compares scans, which fails without it. Also JSON, SARIF, GitLab Security and license outputNot used
diff-scans:createEvery run that compares scans. Without it the run falls back to an older comparison with only a warningNot used
diff-scans:listEvery run that compares scans, with the same fallbackNot used
repo:listLooking up the repository on runs that compare scansNot used
repo:createCreating the repository on its first comparisonNot used
packages:list--generate-license onlyNot used
socket-basics:readNot usedLoading configuration from the Socket Dashboard, on Enterprise plans

The Python CLI compares scans on pull request and merge request runs, and on any run without --scm github or --scm gitlab whose changed files include a manifest. The Jenkins, Buildkite, Azure DevOps and Bitbucket examples in these docs run it without --scm, so they compare on pushes too.

For every API call each tool makes and the scope it needs, see the Python CLI's token permissions guide and Socket Basics' API token scopes.

The npm Socket CLI lists the permissions each command needs on that command's page, for example socket ci.

Keys created from earlier versions of this guide may also have repo:update, triage:alerts-list and triage:alerts-update. None of the CI/CD integrations on these pages use them, so new keys don't need them, and keys that have them keep working.


Notes:

  • The Socket Python CLI (socketcli) reads your API token from either SOCKET_SECURITY_API_KEY or SOCKET_SECURITY_API_TOKEN (it also accepts SOCKET_API_KEY / SOCKET_API_TOKEN, or the --api-token flag). These work the same whether you run the CLI locally or in a CI/CD integration (GitHub Actions, GitLab, Bitbucket, Jenkins, Azure DevOps).
  • If more than one is set, the Python CLI uses SOCKET_SECURITY_API_KEY first. The CI/CD examples in these docs use SOCKET_SECURITY_API_KEY.
  • The npm Socket CLI reads SOCKET_CLI_API_TOKEN, SOCKET_CLI_API_KEY, SOCKET_SECURITY_API_TOKEN and SOCKET_SECURITY_API_KEY, in that order. It does not read SOCKET_API_KEY or SOCKET_API_TOKEN.
  • When the Python CLI compares scans, it uses the diff-scans scopes to compare the new scan against the repository's baseline. Without them the scan still succeeds, but the CLI logs Diff scan comparison failed with APIAccessDenied(Insufficient permissions) and falls back to a comparison that holds one connection open, which network idle timeouts can cut off on large repositories. For the API calls the Python CLI makes and the scope each one needs, see its token permissions guide.


Did this page help you?