# Git Provider Webhook Payload Normalizer to One Event Schema (`kingii98/git-provider-webhook-payload-normalizer-to-one-event-schema`) Actor

Convert GitHub, GitLab, and Bitbucket webhook payloads into one stable event schema.

- **URL**: https://apify.com/kingii98/git-provider-webhook-payload-normalizer-to-one-event-schema.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 actor starts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Git Provider Webhook Payload Normalizer

This Actor converts raw GitHub, GitLab, and Bitbucket webhook payloads into one event schema. It makes no network calls. The transform is deterministic.

### Input

`payloads` is an array of up to 500 items. Each item has these keys:

- `headers`: the provider event headers. The Actor reads `X-GitHub-Event`, `X-Gitlab-Event`, or `X-Event-Key`. Header names are not case sensitive.
- `body`: the payload as an object or as a JSON string. The maximum size is 1 MB.

An empty input runs the Actor on three built-in sample payloads.

### Output

The Actor writes one dataset row for each payload that it normalizes. Each row has:

- `schemaVersion`, `provider`, `providerEventType`, `eventType`, `action`
- `repository` (`id`, `name`, `fullName`, `url`)
- `actor` (`id`, `login`)
- `pullRequest` (`id`, `number`, `title`, `url`, `state`), or `null` if the event is not a pull request event
- `ref` and `commits` (`sha`, `message`, `url`, `timestamp`)
- `timestamps.eventAt`
- `missingFields`: the list of schema fields that the source payload did not contain
- `sourceIndex`: the position of the payload in the input

`eventType` is `push`, `tag_push`, `pull_request`, or `unknown`. The original provider event name stays in `providerEventType`.

A payload that does not parse goes to the key-value store record `REJECTED`. This record is a list of `{index, reason}` objects. Reasons include: item is not an object, headers are not an object, no provider header, body is not valid JSON, body is not a JSON object, payload too large, and batch limit exceeded. Payloads after the 500th are rejected.

A rejected payload is a result, not an error. The run still succeeds. The status message gives the counts.

### Pay-per-event pricing

| Event | Unit | Charged |
| --- | --- | --- |
| `actor-start` | One run started | One time for each run |
| `payload-normalized` | One payload normalized | One time with `count` equal to the number of dataset rows |

The Actor does not charge for rejected payloads.

### Development

```
uv run pytest
uv run ruff check .
```

# Actor input Schema

## `payloads` (type: `array`):

Up to 500 items. Each item has `headers` (the provider event headers) and `body` (the payload as an object or a JSON string, up to 1 MB).

## Actor input object example

```json
{
  "payloads": [
    {
      "headers": {
        "X-GitHub-Event": "push"
      },
      "body": {
        "ref": "refs/heads/main",
        "repository": {
          "id": 1,
          "name": "demo",
          "full_name": "octo/demo",
          "html_url": "https://github.com/octo/demo"
        },
        "sender": {
          "id": 7,
          "login": "octo"
        },
        "commits": [
          {
            "id": "abc123",
            "message": "Fix bug",
            "url": "https://github.com/octo/demo/commit/abc123",
            "timestamp": "2026-01-01T00:00:00Z"
          }
        ],
        "head_commit": {
          "id": "abc123",
          "timestamp": "2026-01-01T00:00:00Z"
        }
      }
    },
    {
      "headers": {
        "X-Gitlab-Event": "Merge Request Hook"
      },
      "body": {
        "user": {
          "id": 5,
          "username": "glu"
        },
        "project": {
          "id": 2,
          "name": "demo",
          "path_with_namespace": "glu/demo",
          "web_url": "https://gitlab.com/glu/demo"
        },
        "object_attributes": {
          "id": 50,
          "iid": 4,
          "title": "Add feature",
          "url": "https://gitlab.com/glu/demo/-/merge_requests/4",
          "state": "opened",
          "action": "open",
          "updated_at": "2026-01-04 00:00:00 UTC"
        }
      }
    },
    {
      "headers": {
        "X-Event-Key": "pullrequest:fulfilled"
      },
      "body": {
        "actor": {
          "uuid": "{u-1}",
          "nickname": "bbu"
        },
        "repository": {
          "uuid": "{r-1}",
          "name": "demo",
          "full_name": "bbu/demo",
          "links": {
            "html": {
              "href": "https://bitbucket.org/bbu/demo"
            }
          }
        },
        "pullrequest": {
          "id": 8,
          "title": "Merge it",
          "state": "MERGED",
          "updated_on": "2026-01-06T00:00:00+00:00",
          "links": {
            "html": {
              "href": "https://bitbucket.org/bbu/demo/pull-requests/8"
            }
          }
        }
      }
    }
  ]
}
```

# Actor output Schema

## `events` (type: `string`):

No description

## `rejected` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "payloads": [
        {
            "headers": {
                "X-GitHub-Event": "push"
            },
            "body": {
                "ref": "refs/heads/main",
                "repository": {
                    "id": 1,
                    "name": "demo",
                    "full_name": "octo/demo",
                    "html_url": "https://github.com/octo/demo"
                },
                "sender": {
                    "id": 7,
                    "login": "octo"
                },
                "commits": [
                    {
                        "id": "abc123",
                        "message": "Fix bug",
                        "url": "https://github.com/octo/demo/commit/abc123",
                        "timestamp": "2026-01-01T00:00:00Z"
                    }
                ],
                "head_commit": {
                    "id": "abc123",
                    "timestamp": "2026-01-01T00:00:00Z"
                }
            }
        },
        {
            "headers": {
                "X-Gitlab-Event": "Merge Request Hook"
            },
            "body": {
                "user": {
                    "id": 5,
                    "username": "glu"
                },
                "project": {
                    "id": 2,
                    "name": "demo",
                    "path_with_namespace": "glu/demo",
                    "web_url": "https://gitlab.com/glu/demo"
                },
                "object_attributes": {
                    "id": 50,
                    "iid": 4,
                    "title": "Add feature",
                    "url": "https://gitlab.com/glu/demo/-/merge_requests/4",
                    "state": "opened",
                    "action": "open",
                    "updated_at": "2026-01-04 00:00:00 UTC"
                }
            }
        },
        {
            "headers": {
                "X-Event-Key": "pullrequest:fulfilled"
            },
            "body": {
                "actor": {
                    "uuid": "{u-1}",
                    "nickname": "bbu"
                },
                "repository": {
                    "uuid": "{r-1}",
                    "name": "demo",
                    "full_name": "bbu/demo",
                    "links": {
                        "html": {
                            "href": "https://bitbucket.org/bbu/demo"
                        }
                    }
                },
                "pullrequest": {
                    "id": 8,
                    "title": "Merge it",
                    "state": "MERGED",
                    "updated_on": "2026-01-06T00:00:00+00:00",
                    "links": {
                        "html": {
                            "href": "https://bitbucket.org/bbu/demo/pull-requests/8"
                        }
                    }
                }
            }
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/git-provider-webhook-payload-normalizer-to-one-event-schema").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "payloads": [
        {
            "headers": { "X-GitHub-Event": "push" },
            "body": {
                "ref": "refs/heads/main",
                "repository": {
                    "id": 1,
                    "name": "demo",
                    "full_name": "octo/demo",
                    "html_url": "https://github.com/octo/demo",
                },
                "sender": {
                    "id": 7,
                    "login": "octo",
                },
                "commits": [{
                        "id": "abc123",
                        "message": "Fix bug",
                        "url": "https://github.com/octo/demo/commit/abc123",
                        "timestamp": "2026-01-01T00:00:00Z",
                    }],
                "head_commit": {
                    "id": "abc123",
                    "timestamp": "2026-01-01T00:00:00Z",
                },
            },
        },
        {
            "headers": { "X-Gitlab-Event": "Merge Request Hook" },
            "body": {
                "user": {
                    "id": 5,
                    "username": "glu",
                },
                "project": {
                    "id": 2,
                    "name": "demo",
                    "path_with_namespace": "glu/demo",
                    "web_url": "https://gitlab.com/glu/demo",
                },
                "object_attributes": {
                    "id": 50,
                    "iid": 4,
                    "title": "Add feature",
                    "url": "https://gitlab.com/glu/demo/-/merge_requests/4",
                    "state": "opened",
                    "action": "open",
                    "updated_at": "2026-01-04 00:00:00 UTC",
                },
            },
        },
        {
            "headers": { "X-Event-Key": "pullrequest:fulfilled" },
            "body": {
                "actor": {
                    "uuid": "{u-1}",
                    "nickname": "bbu",
                },
                "repository": {
                    "uuid": "{r-1}",
                    "name": "demo",
                    "full_name": "bbu/demo",
                    "links": { "html": { "href": "https://bitbucket.org/bbu/demo" } },
                },
                "pullrequest": {
                    "id": 8,
                    "title": "Merge it",
                    "state": "MERGED",
                    "updated_on": "2026-01-06T00:00:00+00:00",
                    "links": { "html": { "href": "https://bitbucket.org/bbu/demo/pull-requests/8" } },
                },
            },
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kingii98/git-provider-webhook-payload-normalizer-to-one-event-schema").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "payloads": [
    {
      "headers": {
        "X-GitHub-Event": "push"
      },
      "body": {
        "ref": "refs/heads/main",
        "repository": {
          "id": 1,
          "name": "demo",
          "full_name": "octo/demo",
          "html_url": "https://github.com/octo/demo"
        },
        "sender": {
          "id": 7,
          "login": "octo"
        },
        "commits": [
          {
            "id": "abc123",
            "message": "Fix bug",
            "url": "https://github.com/octo/demo/commit/abc123",
            "timestamp": "2026-01-01T00:00:00Z"
          }
        ],
        "head_commit": {
          "id": "abc123",
          "timestamp": "2026-01-01T00:00:00Z"
        }
      }
    },
    {
      "headers": {
        "X-Gitlab-Event": "Merge Request Hook"
      },
      "body": {
        "user": {
          "id": 5,
          "username": "glu"
        },
        "project": {
          "id": 2,
          "name": "demo",
          "path_with_namespace": "glu/demo",
          "web_url": "https://gitlab.com/glu/demo"
        },
        "object_attributes": {
          "id": 50,
          "iid": 4,
          "title": "Add feature",
          "url": "https://gitlab.com/glu/demo/-/merge_requests/4",
          "state": "opened",
          "action": "open",
          "updated_at": "2026-01-04 00:00:00 UTC"
        }
      }
    },
    {
      "headers": {
        "X-Event-Key": "pullrequest:fulfilled"
      },
      "body": {
        "actor": {
          "uuid": "{u-1}",
          "nickname": "bbu"
        },
        "repository": {
          "uuid": "{r-1}",
          "name": "demo",
          "full_name": "bbu/demo",
          "links": {
            "html": {
              "href": "https://bitbucket.org/bbu/demo"
            }
          }
        },
        "pullrequest": {
          "id": 8,
          "title": "Merge it",
          "state": "MERGED",
          "updated_on": "2026-01-06T00:00:00+00:00",
          "links": {
            "html": {
              "href": "https://bitbucket.org/bbu/demo/pull-requests/8"
            }
          }
        }
      }
    }
  ]
}' |
apify call kingii98/git-provider-webhook-payload-normalizer-to-one-event-schema --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/git-provider-webhook-payload-normalizer-to-one-event-schema"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LIzpPv05YRSY4tagC/builds/fxxAp9Mk8PTe9kMhD/openapi.json
