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)
-
Log into the socket.dev dashboard
-
Go to Settings
-
Go to the API Tokens tab
-
Select Create API Token
-
Give the token a name like CI/CD API Key
-
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:
-
repo
- repo:list
- repo:create
-
full-scans
- full-scans:list
- full-scans:create
-
diff-scans
- diff-scans:list
- diff-scans:create
-
packages
- packages:list
-
socket-basics
- socket-basics:read
Select security-policy →
security-policy:readonly if the key is used by an npm Socket CLI older than 1.15.0. In those versions,socket ciandsocket scan reportcall 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.
-
-
Click Confirm
-
Click on Show key
-
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.
| Scope | Socket Python CLI (socketcli) | Socket Basics |
|---|---|---|
full-scans:create | Every run | Uploading results, and Socket Tier 1 reachability |
full-scans:list | Every run that compares scans, which fails without it. Also JSON, SARIF, GitLab Security and license output | Not used |
diff-scans:create | Every run that compares scans. Without it the run falls back to an older comparison with only a warning | Not used |
diff-scans:list | Every run that compares scans, with the same fallback | Not used |
repo:list | Looking up the repository on runs that compare scans | Not used |
repo:create | Creating the repository on its first comparison | Not used |
packages:list | --generate-license only | Not used |
socket-basics:read | Not used | Loading 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 eitherSOCKET_SECURITY_API_KEYorSOCKET_SECURITY_API_TOKEN(it also acceptsSOCKET_API_KEY/SOCKET_API_TOKEN, or the--api-tokenflag). 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_KEYfirst. The CI/CD examples in these docs useSOCKET_SECURITY_API_KEY. - The npm Socket CLI reads
SOCKET_CLI_API_TOKEN,SOCKET_CLI_API_KEY,SOCKET_SECURITY_API_TOKENandSOCKET_SECURITY_API_KEY, in that order. It does not readSOCKET_API_KEYorSOCKET_API_TOKEN. - When the Python CLI compares scans, it uses the
diff-scansscopes to compare the new scan against the repository's baseline. Without them the scan still succeeds, but the CLI logsDiff 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.
Updated 5 days ago