- Create - Create a webhook
- List - List all webhooks
- Update - Update a webhook
- Get - Get a webhook
- Delete - Delete a webhook
- Test - Test a webhook
A webhook must have a name, an url and a list of event types. You can also create webhooks in the webhooks settings section of the Dashboard.
package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"github.com/mollie/mollie-api-golang/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.Create(ctx, client.Pointer("123e4567-e89b-12d3-a456-426"), &operations.CreateWebhookRequestBody{
Name: "Webhook #1",
URL: "https://mollie.com/",
EventTypes: operations.CreateCreateWebhookEventTypesWebhookEventTypes(
components.WebhookEventTypesPaymentLinkPaid,
),
Testmode: client.Pointer(false),
})
if err != nil {
log.Fatal(err)
}
if res.CreateWebhook != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
idempotencyKey |
*string |
➖ | A unique key to ensure idempotent requests. This key should be a UUID v4 string. | 123e4567-e89b-12d3-a456-426 |
requestBody |
*operations.CreateWebhookRequestBody | ➖ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateWebhookResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 422 | application/hal+json |
| apierrors.APIError | 4XX, 5XX | */* |
Returns a paginated list of your webhooks. If no webhook endpoints are available, the resulting array will be empty. This request should never throw an error.
package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"github.com/mollie/mollie-api-golang/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithTestmode(false),
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.List(ctx, operations.ListWebhooksRequest{
From: client.Pointer("hook_B2EyhTH5N4KWUnoYPcgiH"),
Limit: client.Pointer[int64](50),
Sort: components.SortingDesc.ToPointer(),
EventTypes: components.WebhookEventTypesPaymentLinkPaid.ToPointer(),
IdempotencyKey: client.Pointer("123e4567-e89b-12d3-a456-426"),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListWebhooksRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.ListWebhooksResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 400 | application/hal+json |
| apierrors.APIError | 4XX, 5XX | */* |
Updates the webhook. You may edit the name, url and the list of subscribed event types.
package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"github.com/mollie/mollie-api-golang/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.Update(ctx, "hook_1234567890", client.Pointer("123e4567-e89b-12d3-a456-426"), &operations.UpdateWebhookRequestBody{
Name: client.Pointer("Webhook #1"),
URL: client.Pointer("https://mollie.com/"),
EventTypes: client.Pointer(operations.CreateUpdateWebhookEventTypesWebhookEventTypes(
components.WebhookEventTypesPaymentLinkPaid,
)),
Testmode: client.Pointer(false),
})
if err != nil {
log.Fatal(err)
}
if res.EntityWebhook != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
webhookID |
string |
✔️ | Provide the ID of the related webhook. | hook_1234567890 |
idempotencyKey |
*string |
➖ | A unique key to ensure idempotent requests. This key should be a UUID v4 string. | 123e4567-e89b-12d3-a456-426 |
requestBody |
*operations.UpdateWebhookRequestBody | ➖ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.UpdateWebhookResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 422 | application/hal+json |
| apierrors.APIError | 4XX, 5XX | */* |
Retrieve a single webhook object by its ID.
package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithTestmode(false),
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.Get(ctx, "hook_1234567890", client.Pointer("123e4567-e89b-12d3-a456-426"))
if err != nil {
log.Fatal(err)
}
if res.EntityWebhook != nil {
// handle response
}
}package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithTestmode(false),
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.Get(ctx, "hook_1234567890", client.Pointer("123e4567-e89b-12d3-a456-426"))
if err != nil {
log.Fatal(err)
}
if res.EntityWebhook != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
webhookID |
string |
✔️ | Provide the ID of the related webhook. | hook_1234567890 |
testmode |
*bool |
➖ | You can enable test mode by setting the testmode query parameter to true.Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa. |
|
idempotencyKey |
*string |
➖ | A unique key to ensure idempotent requests. This key should be a UUID v4 string. | 123e4567-e89b-12d3-a456-426 |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetWebhookResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 422 | application/hal+json |
| apierrors.APIError | 4XX, 5XX | */* |
Delete a single webhook object by its webhook ID.
package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"github.com/mollie/mollie-api-golang/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.Delete(ctx, "hook_1234567890", client.Pointer("123e4567-e89b-12d3-a456-426"), &operations.DeleteWebhookRequestBody{
Testmode: client.Pointer(false),
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
webhookID |
string |
✔️ | Provide the ID of the related webhook. | hook_1234567890 |
idempotencyKey |
*string |
➖ | A unique key to ensure idempotent requests. This key should be a UUID v4 string. | 123e4567-e89b-12d3-a456-426 |
requestBody |
*operations.DeleteWebhookRequestBody | ➖ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DeleteWebhookResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 422 | application/hal+json |
| apierrors.APIError | 4XX, 5XX | */* |
Sends a test event to the webhook to verify the endpoint is working as expected.
package main
import(
"context"
"os"
"github.com/mollie/mollie-api-golang/models/components"
client "github.com/mollie/mollie-api-golang"
"github.com/mollie/mollie-api-golang/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := client.New(
client.WithSecurity(components.Security{
OrganizationAccessToken: client.Pointer(os.Getenv("CLIENT_ORGANIZATION_ACCESS_TOKEN")),
}),
)
res, err := s.Webhooks.Test(ctx, "hook_1234567890", client.Pointer("123e4567-e89b-12d3-a456-426"), &operations.TestWebhookRequestBody{
Testmode: client.Pointer(false),
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
webhookID |
string |
✔️ | Provide the ID of the related webhook. | hook_1234567890 |
idempotencyKey |
*string |
➖ | A unique key to ensure idempotent requests. This key should be a UUID v4 string. | 123e4567-e89b-12d3-a456-426 |
requestBody |
*operations.TestWebhookRequestBody | ➖ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TestWebhookResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 422 | application/hal+json |
| apierrors.APIError | 4XX, 5XX | */* |