---
title: "Update a repository custom pattern"
method: PATCH
path: "/repos/{owner}/{repo}/secret-scanning/custom-patterns/{pattern_id}"
tags: ["secret-scanning"]
---

# 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.

## Path parameters

- `owner` string, required
- `repo` string, required
- `pattern_id` integer, required

## Request body

- union — 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` string, required — The updated regular expression of the custom pattern.
    - `start_delimiter` string — The updated start delimiter regex for the custom pattern.
    - `end_delimiter` string — The updated end delimiter regex for the custom pattern.
    - `must_match` string[] — Updated list of regexes that the secret must match.
    - `must_not_match` string[] — Updated list of regexes that the secret must not match.
    - `custom_pattern_version` string, nullable, required — 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.
  - object
    - `pattern` string — The updated regular expression of the custom pattern.
    - `start_delimiter` string, required — The updated start delimiter regex for the custom pattern.
    - `end_delimiter` string — The updated end delimiter regex for the custom pattern.
    - `must_match` string[] — Updated list of regexes that the secret must match.
    - `must_not_match` string[] — Updated list of regexes that the secret must not match.
    - `custom_pattern_version` string, nullable, required — 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.
  - object
    - `pattern` string — The updated regular expression of the custom pattern.
    - `start_delimiter` string — The updated start delimiter regex for the custom pattern.
    - `end_delimiter` string, required — The updated end delimiter regex for the custom pattern.
    - `must_match` string[] — Updated list of regexes that the secret must match.
    - `must_not_match` string[] — Updated list of regexes that the secret must not match.
    - `custom_pattern_version` string, nullable, required — 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.
  - object
    - `pattern` string — The updated regular expression of the custom pattern.
    - `start_delimiter` string — The updated start delimiter regex for the custom pattern.
    - `end_delimiter` string — The updated end delimiter regex for the custom pattern.
    - `must_match` string[], required — Updated list of regexes that the secret must match.
    - `must_not_match` string[] — Updated list of regexes that the secret must not match.
    - `custom_pattern_version` string, nullable, required — 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.
  - object
    - `pattern` string — The updated regular expression of the custom pattern.
    - `start_delimiter` string — The updated start delimiter regex for the custom pattern.
    - `end_delimiter` string — The updated end delimiter regex for the custom pattern.
    - `must_match` string[] — Updated list of regexes that the secret must match.
    - `must_not_match` string[], required — Updated list of regexes that the secret must not match.
    - `custom_pattern_version` string, nullable, required — 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.

## Response `200`

Pattern updated successfully.

- SecretScanningCustomPattern — A custom pattern for secret scanning.
  - `id` integer, required — The ID of the custom pattern.
  - `name` string, required — The name of the custom pattern.
  - `pattern` string, required — The regular expression of the custom pattern.
  - `slug` string, required — A URL-friendly identifier for the custom pattern, derived from its name.
  - `state` 'published' | 'unpublished', required — The state of the custom pattern.
  - `push_protection_enabled` boolean, required — Whether push protection is enabled for this custom pattern.
  - `start_delimiter` string, nullable — The start delimiter regex for the custom pattern.
  - `end_delimiter` string, nullable — The end delimiter regex for the custom pattern.
  - `must_match` string[], nullable — List of regexes that the secret must match.
  - `must_not_match` string[], nullable — List of regexes that the secret must not match.
  - `custom_pattern_version` string, nullable — 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.
  - `created_at` string, date-time — The date and time the custom pattern was created in ISO 8601 format.
  - `updated_at` string, date-time — The date and time the custom pattern was last updated in ISO 8601 format.

## Other responses

- `400` — Bad Request
- `403` — Forbidden
- `404` — Resource not found
- `412` — Precondition Failed
- `422` — Validation failed, or the endpoint has been spammed.

---

[API](https://skmtc.net/github/apis/github-v3-rest-api.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api/versions/a367f7028301/schema)
