Skip to content

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.

API method documentation

org
required
string

The organization name. The name is not case sensitive.

pattern_id
required
integer

The ID of the custom pattern.

Media type application/json
Any of:
Secret Scanning Custom Pattern To Update

Fields to update on a custom pattern. At least one updatable field (pattern, start_delimiter, end_delimiter, must_match, or must_not_match) must also be provided. Only provided fields will be updated.

object
pattern
required

The updated regular expression of the custom pattern.

string
start_delimiter

The updated start delimiter regex for the custom pattern.

string
end_delimiter

The updated end delimiter regex for the custom pattern.

string
must_match

Updated list of regexes that the secret must match.

Array<string>
must_not_match

Updated list of regexes that the secret must not match.

Array<string>
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
Examples
Example default
{
"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"
}

Pattern updated successfully.

Media type application/json
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": "updated_secret_[0-9A-Z]{16}",
"slug": "example_custom_pattern",
"state": "published",
"push_protection_enabled": true,
"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",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-06-01T12:00:00Z"
}

Bad Request

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"
}

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"
}

Precondition Failed

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"
}

Validation failed, or the endpoint has been spammed.

Media type application/json
Validation Error

Validation Error

object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
nullable
Example generated
{
"message": "example",
"documentation_url": "example",
"errors": [
{
"resource": "example",
"field": "example",
"message": "example",
"code": "example",
"index": 1,
"value": [
"example"
]
}
]
}