(Webhook.Webhooks)
- 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.WithSecurity(os.Getenv("APIDECK_API_KEY")),
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
)
res, err := s.Webhook.Webhooks.List(ctx, nil, nil)
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 |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
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
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.WithSecurity(os.Getenv("APIDECK_API_KEY")),
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
)
res, err := s.Webhook.Webhooks.Create(ctx, components.CreateWebhookRequest{
Description: sdkgo.String("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 |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.CreateWebhookRequest | ✔️ | The request object to use for the request. |
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.WithSecurity(os.Getenv("APIDECK_API_KEY")),
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
)
res, err := s.Webhook.Webhooks.Get(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.GetWebhookResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
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. |
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
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.WithSecurity(os.Getenv("APIDECK_API_KEY")),
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
)
res, err := s.Webhook.Webhooks.Update(ctx, "<id>", components.UpdateWebhookRequest{
Description: sdkgo.String("A description"),
Status: components.StatusEnabled.ToPointer(),
DeliveryURL: sdkgo.String("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 |
---|---|---|---|
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 |
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.WithSecurity(os.Getenv("APIDECK_API_KEY")),
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
)
res, err := s.Webhook.Webhooks.Delete(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.DeleteWebhookResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
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. |
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 | */* |