# Commit Message Linter & Changelog API

> Lint commit messages against Conventional Commits, build a CHANGELOG from git log and compute the next semantic version, with fix suggestions.

- Endpoint: `GET | POST https://apibox.io.vn/v1/commit-lint`
- Category: Developer utilities
- HTML docs: https://apibox.io.vn/docs/commit-lint/ (Vietnamese: https://apibox.io.vn/vi/docs/commit-lint/)
- Online tool: https://apibox.io.vn/tools/commit-lint/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Three actions on one endpoint. `lint` checks one `message`, a list of `commits` or pasted `git log` output against Conventional Commits 1.0.0 with the rules of the popular config-conventional preset (type enum and case, scope case, subject case and full stop, header / body line length, blank lines, BREAKING CHANGE footers) or the stricter `angular` preset; customise with `types`, `scopes`, `header_max`, `require_scope`. Merge, revert and fixup commits are skipped. Every invalid message gets a corrected `suggestion` (synonyms such as feature → feat, past tense → imperative).

`changelog` groups commits into BREAKING CHANGES, Features, Bug Fixes, Performance and Reverts (`all_types=1` adds docs, refactor, CI…), links issues and commits when you pass `repo_url` (GitHub or GitLab), and writes English or Vietnamese headings (`lang=vi`). `bump` returns the next version from `current_version` (breaking → major, feat → minor, fix / perf → patch; 0.x versions bump minor for breaking changes unless `pre_major=0`; `prerelease=beta` for pre-releases).

Accepted log formats: default `git log`, `git log --oneline`, or messages separated by `---`. No configuration files are executed: everything is passed as parameters. Use it in GitLab / Bitbucket / Gitea pipelines, chat bots or release scripts without installing Node tooling.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `action` | body|query | string | no | `lint` | `lint`, `changelog` or `bump` (also as path: /v1/commit-lint/changelog; alias `mode`). |
| `message` | body|query | string | no |  | One commit message (header, body, footers). |
| `commits` | body | array | no |  | Messages as strings or `{hash, message}` objects (max 2000). |
| `log` | body | string | no |  | Pasted `git log` / `git log --oneline` output. |
| `preset` | body|query | string | no | `conventional` | `conventional` (config-conventional) or `angular`. |
| `types` | body|query | string | no |  | Comma-separated allowed types (replaces the preset list). |
| `scopes` | body|query | string | no |  | Comma-separated allowed scopes. |
| `header_max` | body|query | number | no | `100` | Maximum header length (angular: 72). |
| `require_scope` | body|query | boolean | no |  | Require a scope. |
| `current_version` | body|query | string | no |  | Current version for `bump` / `changelog`, e.g. `1.4.2` or `v1.4.2`. |
| `prerelease` | body|query | string | no |  | Pre-release identifier, e.g. `beta`. |
| `repo_url` | body|query | string | no |  | https://github.com/owner/repo (or GitLab) for issue / commit / compare links. |
| `version` | body|query | string | no |  | Changelog version heading (default: computed next version or "Unreleased"). |
| `lang` | body|query | string | no | `en` | `en` or `vi` group headings. |
| `all_types` | body|query | boolean | no |  | Include docs / refactor / test / build / CI / chore groups. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/commit-lint" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message":"Fixed login redirect."}'
```

## Example response

```json
{
  "valid": false,
  "commits": 1,
  "invalid": 1,
  "ignored": 0,
  "config": {
    "preset": "conventional",
    "types": [
      "build",
      "chore",
      "ci",
      "docs",
      "feat",
      "fix",
      "perf",
      "refactor",
      "revert",
      "style",
      "test"
    ],
    "scopes": null,
    "header_max": 100
  },
  "results": [
    {
      "header": "Fixed login redirect.",
      "valid": false,
      "parsed": {
        "type": null,
        "scope": null,
        "subject": null,
        "breaking": false
      },
      "issues": [
        {
          "rule": "type-empty",
          "severity": "error",
          "message": "No type: the header must start with a type such as feat, fix, docs (\"type(scope): subject\")"
        },
        {
          "rule": "subject-empty",
          "severity": "error",
          "message": "No subject after \"type: \""
        }
      ],
      "suggestion": "fix: login redirect"
    }
  ],
  "spec": "https://www.conventionalcommits.org/en/v1.0.0/"
}
```

## Use cases

- Reject non-conventional commit messages in a GitLab or Bitbucket pipeline
- Generate release notes from the commits since the last tag
- Compute the next semantic version in a deploy script
- Show contributors a corrected commit message in a review bot

## FAQ

### Which rules are applied?

The rule set of @commitlint/config-conventional (type, scope, subject, header and body length, blank lines) re-implemented server-side, or the angular preset; types, scopes and lengths can be customised.

### How is the next version decided?

Any breaking change (! or a BREAKING CHANGE footer) → major, any feat → minor, fix / perf / revert → patch, otherwise no release. Versions below 1.0.0 bump minor for breaking changes by default.

### Can it read my repository?

No: paste the output of git log (or send the messages). Nothing is stored.
