---
title: "Create a pre-receive hook"
method: POST
path: "/admin/pre-receive-hooks"
tags: ["enterprise-admin"]
---

# Create a pre-receive hook

`POST /admin/pre-receive-hooks`

## Request body

- object
  - `name` string, required — The name of the hook.
  - `script` string, required — The script that the hook runs.
  - `script_repository` object, required — The GitHub repository where the script is kept.
  - `environment` object, required — The pre-receive environment where the script is executed.
  - `enforcement` string — The state of enforcement for this hook. default: `disabled`
  - `allow_downstream_configuration` boolean — Whether enforcement can be overridden at the org or repo level. default: `false`

## Response `201`

Response

- PreReceiveHook
  - `id` integer
  - `name` string
  - `enforcement` string
  - `script` string
  - `script_repository` object
    - `id` integer
    - `full_name` string
    - `url` string
    - `html_url` string
  - `environment` object
    - `id` integer
    - `name` string
    - `image_url` string
    - `url` string
    - `html_url` string
    - `default_environment` boolean
    - `created_at` string
    - `hooks_count` integer
    - `download` object
      - `url` string
      - `state` string
      - `downloaded_at` string, nullable
      - `message` string, nullable
  - `allow_downstream_configuration` boolean

---

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