---
title: "Bulk create repository custom patterns"
method: POST
path: "/repos/{owner}/{repo}/secret-scanning/custom-patterns"
tags: ["secret-scanning"]
---

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

## Path parameters

- `owner` string, required
- `repo` string, required

## Request body

- object
  - `patterns` SecretScanningCustomPatternToCreate[], required — The list of custom patterns to create.
    - `name` string, required — The name of the custom pattern.
    - `pattern` string, required — The regular expression of the custom pattern.
    - `start_delimiter` string — The start delimiter regex for the custom pattern. Defaults to `\A|[^0-9A-Za-z]` when not specified.
    - `end_delimiter` string — The end delimiter regex for the custom pattern. Defaults to `\z|[^0-9A-Za-z]` when not specified.
    - `must_match` string[] — List of regexes that the secret must match.
    - `must_not_match` string[] — List of regexes that the secret must not match.

## Response `201`

All patterns created successfully.

- object
  - `created_patterns` SecretScanningCustomPattern[] — The list of successfully created custom patterns.
    - `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
- `422` — Validation failed for one or more patterns.

---

[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)
