Skip to content

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.

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

state
string
Allowed values: published unpublished

Filter custom patterns by state. When absent, returns patterns in all states.

push_protection
string
Allowed values: enabled disabled

Filter custom patterns by whether push protection is enabled. When absent, returns patterns regardless of push protection status.

sort
string
default: created
Allowed values: created updated name

The property to sort the results by.

direction
string
default: desc
Allowed values: asc desc

The direction to sort the results by.

page
integer
default: 1

The page number of the results to fetch. For more information, see “Using pagination in the REST API.”

per_page
integer
default: 30

The number of results per page (max 100). For more information, see “Using pagination in the REST API.”

Response

Media type application/json
Array<object>
Secret Scanning Custom Pattern

A custom pattern for secret scanning.

object
id
required

The ID of the custom pattern.

integer
name
required

The name of the custom pattern.

string
pattern
required

The regular expression of the custom pattern.

string
slug
required

A URL-friendly identifier for the custom pattern, derived from its name.

string
state
required

The state of the custom pattern.

string
Allowed values: published unpublished
push_protection_enabled
required

Whether push protection is enabled for this custom pattern.

boolean
start_delimiter

The start delimiter regex for the custom pattern.

string
nullable
end_delimiter

The end delimiter regex for the custom pattern.

string
nullable
must_match

List of regexes that the secret must match.

Array<string>
nullable
must_not_match

List of regexes that the secret must not match.

Array<string>
nullable
custom_pattern_version

The version of the entity. This is used to confirm you’re updating the current version of the entity and mitigate unintentionally overriding someone else’s update.

string
nullable
created_at

The date and time the custom pattern was created in ISO 8601 format.

string format: date-time
updated_at

The date and time the custom pattern was last updated in ISO 8601 format.

string format: date-time
Examples
Example default
[
{
"id": 1,
"name": "Example Custom Pattern",
"pattern": "[a-z]+_token_[0-9]+",
"slug": "example-custom-pattern",
"state": "published",
"push_protection_enabled": true,
"start_delimiter": null,
"end_delimiter": null,
"must_match": null,
"must_not_match": null,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
{
"id": 2,
"name": "Another Custom Pattern",
"pattern": "prefix_[a-zA-Z0-9]{32}",
"slug": "another-custom-pattern",
"state": "published",
"push_protection_enabled": false,
"start_delimiter": "\\b",
"end_delimiter": "\\b",
"must_match": [
"^prefix_prod"
],
"must_not_match": [
"test"
],
"created_at": "2024-01-16T14:20:00Z",
"updated_at": "2024-01-17T09:15:00Z"
}
]
Link
string
Example
<https://api.github.com/resource?page=2>; rel="next", <https://api.github.com/resource?page=5>; rel="last"

Forbidden

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Resource not found

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}