> For the complete documentation index, see [llms.txt](https://paymongo.ossph.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paymongo.ossph.org/reference/api-reference/webhooks.md).

# Webhooks

## The Webhook Resource

A `Webhook` resource primarily refers to a certain URL where we send events that are happening from your account. You can check the [webhook](https://developers.paymongo.com/docs/webhooks) section of our integration guide to find out some good use cases for webhooks.

[More Details](https://developers.paymongo.com/reference/webhook-resource)

## Creating a Webhook

```javascript
/**
 * These are the required properties
 * @param {Object} data Data payload
 * @param {Object} data.attributes Payload attributes
 * @param {string} data.attributes.url The destination URL of the events that happened from your account. Please make sure that the URL is publicly accessible in order for you to receive the event.
 * @param {string[]} data.attributes.events The list of events to be sent to this webhook. Possible value in the meantime is source.chargeable.
 */
const result = await paymongo.webhooks.create(data);

```

#### Payload

```javascript
{
  data: {
    attributes: {
      url: 'https://yourwebsite.com/webook-listener', // Developer's note: this is unique in paymongo. You can't create multiple webhooks with same url.
      events: ['source.chargeable'] // The only event supported for now is 'source.chargeable'.
    }
  }
}

```

## Listing Webhooks

```javascript
const result = await paymongo.webhooks.list();
```

#### Resultjavas

```javascript
{
  data: [] // Array of webhooks
}
```

## Retrieving a Webhook

```javascript
/**
 * @param {string} id Webhook id
 */
const result = await paymongo.webhooks.retrieve(id);

```

## Toggling a Webhook

Enable or disable a webhook.

```javascript
/**
 * @param {string} id Webhook id
 * @param {string} action Toggle options 'enable' or 'disable'
 */
const result = await paymongo.webhooks.toggle(id, action);

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://paymongo.ossph.org/reference/api-reference/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
