GitHub Pre-Receive API

The Pre-Receive API from GitHub — 4 operation(s) for pre-receive.

Documentation

📖
Documentation
https://docs.github.com/en/rest/apps
📖
Documentation
https://docs.github.com/en/rest/codes-of-conduct/codes-of-conduct
📖
Documentation
https://docs.github.com/en/rest/emojis
📖
Documentation
https://docs.github.com/en/rest/gitignore
📖
Documentation
https://docs.github.com/en/rest/apps/installations
📖
Documentation
https://docs.github.com/en/rest/enterprise-admin
📖
Documentation
https://docs.github.com/en/rest/activity/events
📖
Documentation
https://docs.github.com/en/rest/orgs
📖
Documentation
https://docs.github.com/en/rest/rate-limit
📖
Documentation
https://docs.github.com/en/enterprise-cloud@latest/rest/scim
📖
Documentation
https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api
📖
Documentation
https://docs.github.com/en/rest/teams
📖
Documentation
https://docs.github.com/en/rest/meta/meta
📖
Documentation
https://docs.github.com/en/rest/actions
📖
Documentation
https://docs.github.com/en/rest/branches
📖
Documentation
https://docs.github.com/en/rest/code-scanning
📖
Documentation
https://docs.github.com/en/rest/collaborators
📖
Documentation
https://docs.github.com/en/rest/dependabot
📖
Documentation
https://docs.github.com/en/rest/webhooks
📖
Documentation
https://docs.github.com/en/rest/pulls
📖
Documentation
https://docs.github.com/en/rest/git/tags
📖
Documentation
https://docs.github.com/en/rest/repos/autolinks
📖
Documentation
https://docs.github.com/en/rest/collaborators/invitations

Specifications

Other Resources

OpenAPI Specification

github-pre-receive-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Github Pre Receive API
  version: 1.1.4
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
  termsOfService: https://docs.github.com/articles/github-terms-of-service
  description: 'Operations tagged Pre-Receive across 2 of this provider''s published API definitions: github-organizations-openapi.yml, github-repo-hooks-api-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: '{protocol}://{hostname}/api/v3'
  variables:
    hostname:
      description: Self-hosted Enterprise Server hostname
      default: HOSTNAME
    protocol:
      description: Self-hosted Enterprise Server protocol
      default: http
- url: '{protocol}://{hostname}'
  variables:
    hostname:
      description: Self-hosted Enterprise Server hostname
      default: api.github.com
    protocol:
      description: Self-hosted Enterprise Server protocol
      default: https
tags:
- name: Pre-Receive
paths:
  /orgs/{org}/pre-receive-hooks:
    get:
      summary: GitHub List Pre-receive Hooks for an Organization
      description: List all pre-receive hooks that are enabled or testing for this organization as well as any disabled hooks that can be configured at the organization level. Globally disabled pre-receive hooks that do not allow downstream configuration are not listed.
      operationId: listPrereceiveHooksForAnOrganization
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/org-pre-receive-hooks#list-pre-receive-hooks-for-an-organization
      parameters:
      - $ref: '#/components/parameters/org'
      - $ref: '#/components/parameters/per-page'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/direction'
      - name: sort
        description: The sort order for the response collection.
        in: query
        required: false
        schema:
          type: string
          enum:
          - created
          - updated
          - name
          default: created
        example: created
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/org-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/org-pre-receive-hook-items'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: org-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}/api/v3'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: HOSTNAME
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: http
  /orgs/{org}/pre-receive-hooks/{pre_receive_hook_id}:
    get:
      summary: GitHub Get Pre-receive Hook for an Organization
      description: This API endpoint retrieves detailed information about a specific pre-receive hook configured for a GitHub organization. By making a GET request to `/orgs/{org}/pre-receive-hooks/{pre_receive_hook_id}`, you can fetch the configuration and metadata of a particular pre-receive hook identified by its unique ID within the specified organization. Pre-receive hooks are scripts that run on the GitHub server to enforce custom requirements before commits are accepted into a repository, and this endpoint allows administrators to inspect the settings, enforcement level, and other properties of an individual hook that has been set up at the organization level.
      operationId: getPrereceiveHookForAnOrganization
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/org-pre-receive-hooks#get-a-pre-receive-hook-for-an-organization
      parameters:
      - $ref: '#/components/parameters/org'
      - $ref: '#/components/parameters/pre-receive-hook-id'
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/org-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/org-pre-receive-hook'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: org-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      summary: GitHub Update Pre-receive Hook Enforcement for an Organization
      description: For pre-receive hooks which are allowed to be configured at the org level, you can set `enforcement` and `allow_downstream_configuration`
      operationId: updatePrereceiveHookEnforcementForAnOrganization
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/org-pre-receive-hooks#update-pre-receive-hook-enforcement-for-an-organization
      parameters:
      - $ref: '#/components/parameters/org'
      - $ref: '#/components/parameters/pre-receive-hook-id'
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/org-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/org-pre-receive-hook-2'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                enforcement:
                  description: The state of enforcement for the hook on this repository.
                  type: string
                allow_downstream_configuration:
                  description: Whether repositories can override enforcement.
                  type: boolean
            examples:
              default:
                value:
                  enforcement: enabled
                  allow_downstream_configuration: false
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: org-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    delete:
      summary: GitHub Remove Pre-receive Hook Enforcement for an Organization
      description: Removes any overrides for this hook at the org level for this org.
      operationId: removePrereceiveHookEnforcementForAnOrganization
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/org-pre-receive-hooks#remove-pre-receive-hook-enforcement-for-an-organization
      parameters:
      - $ref: '#/components/parameters/org'
      - $ref: '#/components/parameters/pre-receive-hook-id'
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/org-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/org-pre-receive-hook'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: org-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}/api/v3'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: HOSTNAME
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: http
  /repos/{owner}/{repo}/pre-receive-hooks:
    get:
      summary: GitHub List Pre-receive Hooks for Repository
      description: List all pre-receive hooks that are enabled or testing for this repository as well as any disabled hooks that are allowed to be enabled at the repository level. Pre-receive hooks that are disabled at a higher level and are not configurable will not be listed.
      operationId: listPrereceiveHooksForRepository
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/repo-pre-receive-hooks#list-pre-receive-hooks-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/per-page'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/direction'
      - name: sort
        in: query
        required: false
        schema:
          type: string
          enum:
          - created
          - updated
          - name
          default: created
        example: created
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/repository-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/repository-pre-receive-hook-items'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: repo-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: api.github.com
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: https
  /repos/{owner}/{repo}/pre-receive-hooks/{pre_receive_hook_id}:
    get:
      summary: GitHub Get Pre-receive Hook for Repository
      description: This API endpoint retrieves detailed information about a specific pre-receive hook configured for a GitHub repository. Pre-receive hooks are scripts that run on the GitHub server before code is accepted into a repository, allowing administrators to enforce quality standards or policies. By providing the repository owner, repository name, and the pre-receive hook ID in the URL path, this GET operation returns comprehensive details about that particular hook, including its configuration, enforcement level, and current status within the specified repository.
      operationId: getPrereceiveHookForRepository
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/repo-pre-receive-hooks#get-a-pre-receive-hook-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/pre-receive-hook-id'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/repository-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/repository-pre-receive-hook'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: repo-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      summary: GitHub Update Pre-receive Hook Enforcement for Repository
      description: For pre-receive hooks which are allowed to be configured at the repo level, you can set `enforcement`
      operationId: updatePrereceiveHookEnforcementForRepository
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/repo-pre-receive-hooks#update-pre-receive-hook-enforcement-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/pre-receive-hook-id'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/repository-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/repository-pre-receive-hook-2'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                enforcement:
                  description: The state of enforcement for the hook on this repository.
                  type: string
                  enum:
                  - enabled
                  - disabled
                  - testing
            examples:
              default:
                value:
                  enforcement: enabled
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: repo-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    delete:
      summary: GitHub Remove Pre-receive Hook Enforcement for Repository
      description: 'Deletes any overridden enforcement on this repository for the specified hook.


        Responds with effective values inherited from owner and/or global level.'
      operationId: removePrereceiveHookEnforcementForRepository
      tags:
      - Pre-Receive
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/enterprise-admin/repo-pre-receive-hooks#remove-pre-receive-hook-enforcement-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/pre-receive-hook-id'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Responds with effective values inherited from owner and/or global level.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/repository-pre-receive-hook'
              examples:
                default:
                  $ref: '#/components/examples/repository-pre-receive-hook'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: enterprise-admin
        subcategory: repo-pre-receive-hooks
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: api.github.com
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: https
components:
  examples:
    org-pre-receive-hook-2:
      value:
        id: 42
        name: Check Commits
        enforcement: enabled
        configuration_url: https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42
        allow_downstream_configuration: false
    org-pre-receive-hook:
      value:
        id: 42
        name: Check Commits
        enforcement: disabled
        configuration_url: https://github.example.com/api/v3/admin/pre-receive-hooks/42
        allow_downstream_configuration: true
    org-pre-receive-hook-items:
      value:
      - id: 42
        name: Check Commits
        enforcement: disabled
        configuration_url: https://github.example.com/api/v3/admin/pre-receive-hooks/42
        allow_downstream_configuration: true
    repository-pre-receive-hook-items:
      value:
      - id: 42
        name: Check Commits
        enforcement: disabled
        configuration_url: https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42
    repository-pre-receive-hook-2:
      value:
        id: 42
        name: Check Commits
        enforcement: enabled
        configuration_url: https://github.example.com/api/v3/repos/octocat/hello-world/pre-receive-hooks/42
    repository-pre-receive-hook:
      value:
        id: 42
        name: Check Commits
        enforcement: disabled
        configuration_url: https://github.example.com/api/v3/orgs/octocat/pre-receive-hooks/42
  schemas:
    org-pre-receive-hook:
      type: object
      properties:
        id:
          type: integer
          example: 42
        name:
          type: string
          example: octocat
        enforcement:
          type: string
          example: example_value
        configuration_url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        allow_downstream_configuration:
          type: boolean
          example: true
    repository-pre-receive-hook:
      type: object
      properties:
        id:
          type: integer
          example: 42
        name:
          type: string
          example: octocat
        enforcement:
          type: string
          example: example_value
        configuration_url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
  parameters:
    direction:
      name: direction
      description: The direction to sort the results by.
      in: query
      required: false
      schema:
        type: string
        enum:
        - asc
        - desc
        default: desc
    pre-receive-hook-id:
      name: pre_receive_hook_id
      description: The unique identifier of the pre-receive hook.
      in: path
      required: true
      schema:
        type: integer
    per-page:
      name: per_page
      description: The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
      in: query
      schema:
        type: integer
        default: 30
    org:
      name: org
      description: The organization name. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    page:
      name: page
      description: The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
      in: query
      schema:
        type: integer
        default: 1
    owner:
      name: owner
      description: The account owner of the repository. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    repo:
      name: repo
      description: The name of the repository without the `.git` extension. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
  securitySchemes:
    bearerHttpAuthentication:
      description: Bearer Token
      type: http
      scheme: Bearer
externalDocs:
  description: GitHub Enterprise Developer Docs
  url: https://docs.github.com/enterprise-server@3.9/rest/
x-refined-from:
- github-organizations-openapi.yml
- github-repo-hooks-api-openapi.yml