# Create an organization webhook

From **GitHub v3 REST API**.

`POST /orgs/{org}/hooks`

Here's how you can create a hook that posts payloads in JSON format:

## Parameters

### `org`

- Location: path
- Required: true
- Type: `string`

## Request body

- Required: true
### `application/json`

- Type: `object`

```json
{
  "active": true,
  "config": {
    "content_type": "json",
    "url": "http://example.com/webhook"
  },
  "events": [
    "push",
    "pull_request"
  ],
  "name": "web"
}
```

```json
{"properties":{"active":{"default":true,"description":"Determines if notifications are sent when the webhook is triggered. Set to `true` to send notifications.","type":"boolean"},"config":{"description":"Key/value pairs to provide settings for this webhook. [These are defined below](https://docs.github.com/enterprise-server@3.0/rest/reference/orgs#create-hook-config-params).","properties":{"content_type":{"$ref":"#/components/schemas/webhook-config-content-type"},"insecure_ssl":{"$ref":"#/components/schemas/webhook-config-insecure-ssl"},"password":{"example":"\"password\"","type":"string"},"secret":{"$ref":"#/components/schemas/webhook-config-secret"},"url":{"$ref":"#/components/schemas/webhook-config-url"},"username":{"example":"\"kdaigle\"","type":"string"}},"required":["url"],"type":"object"},"events":{"default":["push"],"description":"Determines what [events](https://docs.github.com/enterprise-server@3.0/webhooks/event-payloads) the hook is triggered for.","items":{"type":"string"},"type":"array"},"name":{"description":"Must be passed as \"web\".","type":"string"}},"required":["name","config"],"type":"object"}
```

## Responses

### `201`

Response

#### Headers

##### `Location`

- Type: `string`

- Example: `https://api.github.com/orgs/octocat/hooks/1`

### `application/json`

- Type: `object`

Org Hook

```json
{
  "active": true,
  "config": {
    "content_type": "json",
    "url": "http://example.com"
  },
  "created_at": "2011-09-06T17:26:27Z",
  "events": [
    "push",
    "pull_request"
  ],
  "id": 1,
  "name": "web",
  "ping_url": "https://api.github.com/orgs/octocat/hooks/1/pings",
  "type": "Organization",
  "updated_at": "2011-09-06T20:39:23Z",
  "url": "https://api.github.com/orgs/octocat/hooks/1"
}
```

```json
{"description":"Org Hook","properties":{"active":{"example":true,"type":"boolean"},"config":{"properties":{"content_type":{"example":"\"form\"","type":"string"},"insecure_ssl":{"example":"\"0\"","type":"string"},"secret":{"example":"\"********\"","type":"string"},"url":{"example":"\"http://example.com/2\"","type":"string"}},"type":"object"},"created_at":{"example":"2011-09-06T17:26:27Z","format":"date-time","type":"string"},"events":{"example":["push","pull_request"],"items":{"type":"string"},"type":"array"},"id":{"example":1,"type":"integer"},"name":{"example":"web","type":"string"},"ping_url":{"example":"https://api.github.com/orgs/octocat/hooks/1/pings","format":"uri","type":"string"},"type":{"type":"string"},"updated_at":{"example":"2011-09-06T20:39:23Z","format":"date-time","type":"string"},"url":{"example":"https://api.github.com/orgs/octocat/hooks/1","format":"uri","type":"string"}},"required":["id","url","type","name","active","events","config","ping_url","created_at","updated_at"],"title":"Org Hook","type":"object"}
```

### `404`

Resource not found

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request POST \
  --url {protocol}://{hostname}/api/v3/orgs/{org}/hooks \
  --header 'content-type: application/json' \
  --data '{
  "active": true,
  "config": {
    "content_type": "json",
    "url": "http://example.com/webhook"
  },
  "events": [
    "push",
    "pull_request"
  ],
  "name": "web"
}'
```
