Skip to content

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.

API method documentation

org
required
string

The organization name. The name is not case sensitive.

Media type application/json
object
patterns
required

The list of custom patterns to create.

Array<object>
Secret Scanning Custom Pattern To Create

A custom pattern to create in a bulk operation.

object
name
required

The name of the custom pattern.

string
pattern
required

The regular expression of the custom pattern.

string
start_delimiter

The start delimiter regex for the custom pattern. Defaults to \A|[^0-9A-Za-z] when not specified.

string
default: \A|[^0-9A-Za-z]
end_delimiter

The end delimiter regex for the custom pattern. Defaults to \z|[^0-9A-Za-z] when not specified.

string
default: \z|[^0-9A-Za-z]
must_match

List of regexes that the secret must match.

Array<string>
must_not_match

List of regexes that the secret must not match.

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

All patterns created successfully.

Media type application/json
object
created_patterns

The list of successfully created custom patterns.

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
{
"created_patterns": [
{
"id": 1,
"name": "Example Custom Pattern",
"pattern": "[a-z]+_token_[0-9]+",
"slug": "example-custom-pattern",
"state": "unpublished",
"push_protection_enabled": false,
"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": "unpublished",
"push_protection_enabled": false,
"start_delimiter": "\\b",
"end_delimiter": "\\b",
"must_match": [
"^prefix_prod"
],
"must_not_match": [
"test"
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30: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"
}

Validation failed for one or more patterns.

Media type application/json
object
message

A summary message describing the error.

string
validation_errors

A map of validation errors keyed by the zero-based index of the pattern that failed.

object
key
additional properties
object
errors

List of validation errors for this pattern.

Array<object>
Secret Scanning Custom Pattern Validation Error

A validation error for a custom pattern in a batch operation.

object
code

A machine-readable code describing the error.

string
Allowed values: none config_load compile_db start_delimiter end_delimiter display_name must_match must_not_match custom_pattern_version_mismatch db_size db_size_calculation
message

A human-readable description of the error.

string
Example
{
"validation_errors": {
"additionalProperty": {
"errors": [
{
"code": "none"
}
]
}
}
}