REST API endpoints for secret scanning custom patterns

Use the REST API to manage custom patterns for secret scanning.

Note

Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.

List organization custom patterns

GET /orgs/{org}/secret-scanning/custom-patterns

Lists secret scanning custom patterns for an organization.
Personal access tokens (classic) need the read:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/secret-scanning/custom-patterns

Response schema (Status: 200):

Array of Secret Scanning Custom Pattern:

Bulk create organization custom patterns

POST /orgs/{org}/secret-scanning/custom-patterns

Bulk creates secret scanning custom patterns for an organization.
Personal access tokens (classic) need the write:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/orgs/ORG/secret-scanning/custom-patterns \
  -d '{
  "patterns": [
    {
      "name": "Example Custom Pattern",
      "pattern": "[a-z]+_token_[0-9]+"
    },
    {
      "name": "Another Custom Pattern",
      "pattern": "prefix_[a-zA-Z0-9]{32}",
      "start_delimiter": "\\b",
      "end_delimiter": "\\b",
      "must_match": [
        "^prefix_prod"
      ],
      "must_not_match": [
        "test"
      ]
    }
  ]
}'

Response schema (Status: 201):

Bulk delete organization custom patterns

DELETE /orgs/{org}/secret-scanning/custom-patterns

Bulk deletes secret scanning custom patterns for an organization.
Personal access tokens (classic) need the write:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/orgs/ORG/secret-scanning/custom-patterns \
  -d '{
  "patterns": [
    {
      "pattern_id": 2,
      "custom_pattern_version": "0ujsswThIGTUYm2K8FjOOfXtY1K"
    }
  ]
}'

Response schema (Status: 204):

Update an organization custom pattern

PATCH /orgs/{org}/secret-scanning/custom-patterns/{pattern_id}

Updates a secret scanning custom pattern for an organization.
Personal access tokens (classic) need the write:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PATCH \
  https://api.github.com/orgs/ORG/secret-scanning/custom-patterns/PATTERN_ID \
  -d '{
  "pattern": "updated_secret_[0-9A-Z]{16}",
  "start_delimiter": "[^0-9A-Za-z]",
  "end_delimiter": "[^0-9A-Za-z]",
  "must_match": [
    "updated_secret_[0-9]{2}*"
  ],
  "must_not_match": [
    "updated_secret_1234567890ABCDEF"
  ],
  "custom_pattern_version": "0ujsswThIGTUYm2K8FjOOfXtY1K"
}'

Response schema (Status: 200):

List repository custom patterns

GET /repos/{owner}/{repo}/secret-scanning/custom-patterns

Lists secret scanning custom patterns for a repository.
OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/secret-scanning/custom-patterns

Response schema (Status: 200):

Same response schema as List organization custom patterns.

Bulk create repository custom patterns

POST /repos/{owner}/{repo}/secret-scanning/custom-patterns

Bulk creates secret scanning custom patterns for a repository.
OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/secret-scanning/custom-patterns \
  -d '{
  "patterns": [
    {
      "name": "Example Custom Pattern",
      "pattern": "[a-z]+_token_[0-9]+"
    },
    {
      "name": "Another Custom Pattern",
      "pattern": "prefix_[a-zA-Z0-9]{32}",
      "start_delimiter": "\\b",
      "end_delimiter": "\\b",
      "must_match": [
        "^prefix_prod"
      ],
      "must_not_match": [
        "test"
      ]
    }
  ]
}'

Response schema (Status: 201):

Same response schema as Bulk create organization custom patterns.

Bulk delete repository custom patterns

DELETE /repos/{owner}/{repo}/secret-scanning/custom-patterns

Bulk deletes secret scanning custom patterns for a repository.
OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/secret-scanning/custom-patterns \
  -d '{
  "patterns": [
    {
      "pattern_id": 2,
      "custom_pattern_version": "0ujsswThIGTUYm2K8FjOOfXtY1K"
    }
  ]
}'

Response schema (Status: 204):

Update a repository custom pattern

PATCH /repos/{owner}/{repo}/secret-scanning/custom-patterns/{pattern_id}

Updates a secret scanning custom pattern for a repository.
OAuth app tokens and personal access tokens (classic) need the repo or security_events scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the public_repo scope instead.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PATCH \
  https://api.github.com/repos/OWNER/REPO/secret-scanning/custom-patterns/PATTERN_ID \
  -d '{
  "pattern": "updated_secret_[0-9A-Z]{16}",
  "start_delimiter": "[^0-9A-Za-z]",
  "end_delimiter": "[^0-9A-Za-z]",
  "must_match": [
    "updated_secret_[0-9]{2}*"
  ],
  "must_not_match": [
    "updated_secret_1234567890ABCDEF"
  ],
  "custom_pattern_version": "0ujsswThIGTUYm2K8FjOOfXtY1K"
}'

Response schema (Status: 200):

Same response schema as Update an organization custom pattern.