- List - List webhook subscriptions
- Create - Create webhook subscription
- Get - Get webhook subscription
- Update - Update webhook subscription
- Delete - Delete webhook subscription
List all webhook subscriptions
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Webhook.Webhooks.List(ctx, nil, sdkgo.Pointer[int64](20))
if err != nil {
log.Fatal(err)
}
if res.GetWebhooksResponse != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
appID |
*string |
➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
cursor |
*string |
➖ | Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response. | |
limit |
*int64 |
➖ | Number of results to return. Minimum 1, Maximum 200, Default 20 | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhookWebhooksAllResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Create a webhook subscription to receive events.
Delivery URL Validation: The provided delivery_url will be validated synchronously by sending an HTTP POST request with an HMAC signature. If validation fails (network error, timeout, non-2xx response), the webhook will still be created but with status: "disabled" and disabled_reason: "delivery_url_validation_failed".
Important: Always check the status and disabled_reason fields in the response to ensure the webhook is active.
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Webhook.Webhooks.Create(ctx, components.CreateWebhookRequest{
Description: sdkgo.Pointer("A description"),
UnifiedAPI: components.UnifiedAPIIDCrm,
Status: components.StatusEnabled,
DeliveryURL: "https://example.com/my/webhook/endpoint",
Events: []components.WebhookEventType{
components.WebhookEventTypeVaultConnectionCreated,
components.WebhookEventTypeVaultConnectionUpdated,
},
})
if err != nil {
log.Fatal(err)
}
if res.CreateWebhookResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
createWebhookRequest |
components.CreateWebhookRequest | ✔️ | N/A | |
appID |
*string |
➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhookWebhooksAddResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Get the webhook subscription details
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Webhook.Webhooks.Get(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.GetWebhookResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | JWT Webhook token that represents the unifiedApi and applicationId associated to the event source. | |
appID |
*string |
➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhookWebhooksOneResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Update a webhook subscription.
Delivery URL Validation: When updating the delivery_url, it will be validated synchronously by sending an HTTP POST request with an HMAC signature. If validation fails (network error, timeout, non-2xx response), the webhook will still be updated but with status: "disabled" and disabled_reason: "delivery_url_validation_failed". Validation only occurs when the URL is changed.
Important: Always check the status and disabled_reason fields in the response to ensure the webhook is active.
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Webhook.Webhooks.Update(ctx, "<id>", components.UpdateWebhookRequest{
Description: sdkgo.Pointer("A description"),
Status: components.StatusEnabled.ToPointer(),
DeliveryURL: sdkgo.Pointer("https://example.com/my/webhook/endpoint"),
Events: []components.WebhookEventType{
components.WebhookEventTypeVaultConnectionCreated,
components.WebhookEventTypeVaultConnectionUpdated,
},
})
if err != nil {
log.Fatal(err)
}
if res.UpdateWebhookResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | JWT Webhook token that represents the unifiedApi and applicationId associated to the event source. | |
updateWebhookRequest |
components.UpdateWebhookRequest | ✔️ | N/A | |
appID |
*string |
➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhookWebhooksUpdateResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Delete a webhook subscription
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Webhook.Webhooks.Delete(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.DeleteWebhookResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
id |
string |
✔️ | JWT Webhook token that represents the unifiedApi and applicationId associated to the event source. | |
appID |
*string |
➖ | The ID of your Unify application | dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhookWebhooksDeleteResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |