> ## Documentation Index
> Fetch the complete documentation index at: https://docs.custoden.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scan a lockfile

> Checks every package in a lockfile for known malware and vulnerabilities in one request.

Send a whole lockfile and get back every package in it that is known malware, has known vulnerabilities, or is installed from git instead of the registry. This covers transitive dependencies too, which a list of direct dependencies misses.

Supported files:

| File | Ecosystem |
| - | - |
| `package-lock.json`, `npm-shrinkwrap.json` | npm |
| `pnpm-lock.yaml` | npm |
| `yarn.lock` (classic and Berry) | npm |
| `poetry.lock`, `uv.lock` | PyPI |
| `requirements.txt` (and `requirements-*.txt`) | PyPI |

The file is analyzed in memory and not stored. Each request costs 5 units of your [rate limit](https://docs.custoden.com/getting-started/rate-limits.md). The body can be up to 5 MB.

## Request

Send the file as the raw body and its name as `?filename=`:

```bash theme={null}
curl -X POST "https://api.custoden.com/v1/packages/lockfile?filename=package-lock.json" \
  --data-binary @package-lock.json
```

Or as JSON:

```json theme={null}
{ "filename": "package-lock.json", "content": "<file contents>" }
```

| Field | Type | Description |
| - | - | - |
| `filename` | string | File name, used to pick the format. A path is accepted, only the last part is used |
| `content` | string | Full file contents |

## Example

```json theme={null}
{
  "lockfile": { "filename": "package-lock.json", "ecosystem": "npm", "packages": 412 },
  "summary": { "critical": 1, "high": 1, "medium": 0, "low": 0, "info": 0, "total": 2 },
  "findings": [
    {
      "rule": "known-malicious",
      "severity": "critical",
      "title": "chalk@5.6.1 is a known malicious package",
      "detail": "...",
      "line": null,
      "package": { "ecosystem": "npm", "name": "chalk", "version": "5.6.1" },
      "remediation": "Remove the package, rotate every credential the install could reach, and rebuild affected machines.",
      "references": ["https://osv.dev/vulnerability/MAL-..."]
    },
    {
      "rule": "vulnerable-dependency",
      "severity": "high",
      "title": "undici@7.28.0 has 2 known vulnerabilities",
      "detail": "GHSA-...: ...",
      "line": null,
      "package": { "ecosystem": "npm", "name": "undici", "version": "7.28.0" },
      "remediation": "Upgrade to 7.29.0 or later.",
      "references": ["https://osv.dev/vulnerability/GHSA-..."]
    }
  ],
  "checks": { "vulnerabilities": { "status": "complete" } },
  "checked_at": "2026-11-30T13:40:12.512Z"
}
```

## Response

| Field | Type | Description |
| - | - | - |
| `lockfile` | object | `filename`, `ecosystem` and `packages` (distinct package versions found) |
| `summary` | object | Count of findings per severity, plus `total` |
| `findings` | array | All findings, sorted by severity. Same fields as a [repository scan finding](https://docs.custoden.com/api-reference/scan-a-repository.md#finding), without `category` and `path` |
| `checks.vulnerabilities` | object | `status` of `complete`, `partial` or `skipped`, and a `reason` when it is not `complete` |
| `checked_at` | string | ISO 8601 timestamp |

In a `requirements.txt`, only exact pins (`==`) can be checked. Other lines are counted in `packages` but make the check `partial` and add an `unpinned-dependencies` finding. `line` is set for findings in a `requirements.txt` and `null` for lockfiles.

## Rules

| Rule | Severity | Meaning |
| - | - | - |
| `known-malicious` | critical | The package version is listed as malware in OSV |
| `vulnerable-dependency` | highest advisory severity | The package version has known vulnerabilities. Advisories without a severity count as medium |
| `dependency-from-url` | medium | Installed from git or a URL instead of the registry |
| `insecure-registry-url` | medium | The lockfile downloads packages over plain `http://` |
| `unpinned-dependencies` | low | A requirements file does not pin exact versions |

To check a single package in more depth, including install scripts, typosquatting, maintainers and release history, use [Check a package](https://docs.custoden.com/api-reference/check-a-package.md).

## Errors

| Status | Code | When |
| - | - | - |
| 400 | `invalid_json` | JSON body is not valid JSON |
| 400 | `invalid_request` | No `?filename=`, or the JSON body lacks `filename` or `content` |
| 400 | `unsupported_lockfile` | The file name is not one of the supported files |
| 400 | `invalid_lockfile` | The file is empty or no packages could be read from it |
| 413 | `payload_too_large` | Body exceeds 5 MB |
| 429 | `rate_limited` | See [Rate limits](https://docs.custoden.com/getting-started/rate-limits.md) |

Rejected requests are not charged.


## OpenAPI

````yaml POST /v1/packages/lockfile
openapi: 3.1.0
info:
  title: Custoden API
  version: v1
  description: >-
    Free, keyless API for checking open-source packages, GitHub Actions
    workflows and public repositories.
  contact:
    url: https://github.com/Custoden/docs
servers:
  - url: https://api.custoden.com
security: []
paths:
  /v1/packages/lockfile:
    post:
      summary: Scan a lockfile
      description: >-
        Costs 5 rate limit units. Body up to 5 MB. Send the file as the raw body
        with `?filename=`, or as JSON.
      operationId: scanLockfile
      parameters:
        - name: filename
          in: query
          required: false
          description: >-
            Required for a raw body. One of package-lock.json,
            npm-shrinkwrap.json, pnpm-lock.yaml, yarn.lock, poetry.lock, uv.lock
            or requirements.txt (requirements-*.txt is also accepted).
          schema:
            type: string
      requestBody:
        required: true
        content:
          text/plain:
            schema:
              type: string
              description: Lockfile contents
          application/json:
            schema:
              type: object
              required:
                - filename
                - content
              properties:
                filename:
                  type: string
                content:
                  type: string
      responses:
        '200':
          description: Lockfile report
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LockfileReport'
        '400':
          $ref: '#/components/responses/Error'
        '413':
          $ref: '#/components/responses/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  headers:
    RateLimit-Limit:
      description: >-
        Units allowed in the current minute. On repository scans, scans allowed
        in the current hour
      schema:
        type: integer
    RateLimit-Remaining:
      description: >-
        Units left in the current minute. On repository scans, scans left in the
        current hour
      schema:
        type: integer
    RateLimit-Reset:
      description: Seconds until the current window resets
      schema:
        type: integer
  schemas:
    LockfileReport:
      type: object
      required:
        - lockfile
        - summary
        - findings
        - checks
        - checked_at
      properties:
        lockfile:
          type: object
          properties:
            filename:
              type: string
            ecosystem:
              type: string
              enum:
                - npm
                - pypi
            packages:
              type: integer
              description: Distinct package versions found
        summary:
          $ref: '#/components/schemas/SeveritySummary'
        findings:
          type: array
          items:
            type: object
            required:
              - rule
              - severity
              - title
              - detail
              - line
            properties:
              rule:
                type: string
                enum:
                  - known-malicious
                  - vulnerable-dependency
                  - dependency-from-url
                  - insecure-registry-url
                  - unpinned-dependencies
              severity:
                $ref: '#/components/schemas/Severity'
              title:
                type: string
              detail:
                type: string
              line:
                type:
                  - integer
                  - 'null'
                description: Set for requirements files
              package:
                type: object
                properties:
                  ecosystem:
                    type: string
                    enum:
                      - npm
                      - pypi
                  name:
                    type: string
                  version:
                    type:
                      - string
                      - 'null'
              remediation:
                type: string
              references:
                type: array
                items:
                  type: string
                  format: uri
        checks:
          type: object
          properties:
            vulnerabilities:
              $ref: '#/components/schemas/RepoCheck'
        checked_at:
          type: string
          format: date-time
    SeveritySummary:
      type: object
      required:
        - critical
        - high
        - medium
        - low
        - info
        - total
      properties:
        critical:
          type: integer
        high:
          type: integer
        medium:
          type: integer
        low:
          type: integer
        info:
          type: integer
        total:
          type: integer
    Severity:
      type: string
      enum:
        - critical
        - high
        - medium
        - low
        - info
    RepoCheck:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - complete
            - partial
            - skipped
        reason:
          type: string
    ErrorResponse:
      type: object
      required:
        - error
        - request_id
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
        request_id:
          type: string
    ErrorBody:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type: object
  responses:
    Error:
      description: Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Rate limit exceeded
      headers:
        Retry-After:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.