Skip to content

hooks

Accessed as client.repos.hooks; the async client mirrors it.

ReposHooks

The repos.hooks namespace.

git

create

create(
    owner: str,
    repo: str,
    *,
    active: bool | None = None,
    authorization_header: str | None = None,
    branch_filter: str | None = None,
    config: CreateHookOptionConfig,
    events: list[str] | None = None,
    type: CreateHookOptionType,
) -> Hook

Create a hook.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
active bool | None
None
authorization_header str | None
None
branch_filter str | None
None
config CreateHookOptionConfig
required
events list[str] | None
None
type CreateHookOptionType
required

Returns:

Type Description
Hook

Hook.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoCreateHook

delete

delete(owner: str, repo: str, id: int) -> None

Delete a hook in a repository.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

id of the hook to delete

required

Returns:

Type Description
None

No content.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoDeleteHook

get

get(owner: str, repo: str, id: int) -> Hook

Get a hook.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

id of the hook to get

required

Returns:

Type Description
Hook

Hook.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoGetHook

list

list(owner: str, repo: str, *, page: int | None = None, limit: int | None = None) -> Paginated[Hook]

List the hooks in a repository.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
page int | None

1-based page to start iteration at.

None
limit int | None

Page size; the instance caps it server-side.

None

Returns:

Type Description
Paginated[Hook]

HookList.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoListHooks

test

test(owner: str, repo: str, id: int, *, ref: str | None = None) -> None

Test a push webhook.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

id of the hook to test

required
ref str | None

The name of the commit/branch/tag, indicates which commit will be loaded to the webhook payload.

None

Returns:

Type Description
None

No content.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoTestHook

update

update(
    owner: str,
    repo: str,
    id: int,
    *,
    active: bool | None = None,
    authorization_header: str | None = None,
    branch_filter: str | None = None,
    config: dict[str, str] | None = None,
    events: list[str] | None = None,
) -> Hook

Edit a hook in a repository.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

index of the hook

required
active bool | None
None
authorization_header str | None
None
branch_filter str | None
None
config dict[str, str] | None
None
events list[str] | None
None

Returns:

Type Description
Hook

Hook.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoEditHook

AsyncReposHooks

The repos.hooks namespace.

create

create(
    owner: str,
    repo: str,
    *,
    active: bool | None = None,
    authorization_header: str | None = None,
    branch_filter: str | None = None,
    config: CreateHookOptionConfig,
    events: list[str] | None = None,
    type: CreateHookOptionType,
) -> Hook

Create a hook.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
active bool | None
None
authorization_header str | None
None
branch_filter str | None
None
config CreateHookOptionConfig
required
events list[str] | None
None
type CreateHookOptionType
required

Returns:

Type Description
Hook

Hook.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoCreateHook

delete

delete(owner: str, repo: str, id: int) -> None

Delete a hook in a repository.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

id of the hook to delete

required

Returns:

Type Description
None

No content.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoDeleteHook

get

get(owner: str, repo: str, id: int) -> Hook

Get a hook.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

id of the hook to get

required

Returns:

Type Description
Hook

Hook.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoGetHook

list

list(owner: str, repo: str, *, page: int | None = None, limit: int | None = None) -> AsyncPaginated[Hook]

List the hooks in a repository.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
page int | None

1-based page to start iteration at.

None
limit int | None

Page size; the instance caps it server-side.

None

Returns:

Type Description
AsyncPaginated[Hook]

HookList.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoListHooks

test

test(owner: str, repo: str, id: int, *, ref: str | None = None) -> None

Test a push webhook.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

id of the hook to test

required
ref str | None

The name of the commit/branch/tag, indicates which commit will be loaded to the webhook payload.

None

Returns:

Type Description
None

No content.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoTestHook

update

update(
    owner: str,
    repo: str,
    id: int,
    *,
    active: bool | None = None,
    authorization_header: str | None = None,
    branch_filter: str | None = None,
    config: dict[str, str] | None = None,
    events: list[str] | None = None,
) -> Hook

Edit a hook in a repository.

Parameters:

Name Type Description Default
owner str

owner of the repo

required
repo str

name of the repo

required
id int

index of the hook

required
active bool | None
None
authorization_header str | None
None
branch_filter str | None
None
config dict[str, str] | None
None
events list[str] | None
None

Returns:

Type Description
Hook

Hook.

Raises:

Type Description
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: repoEditHook