svix

package
v1.58.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 18 Imported by: 20

README

Svix - Webhooks as a service

Website | Documentation | Community Slack

Go library for interacting with the Svix API and verifying webhook signatures

GitHub tag PkgGoDev

Join our slack

Usage Documentation

You can find general usage documentation at https://docs.svix.com. For complete API documentation with code examples for each endpoint in all of our official client libraries head over to our API documentation site at https://api.svix.com.

Language Support

⚡️ Features ⚡️
Officially Supported
API Support
Signature Verification
Caveats None! 🚀

Development

First checkout the core README for details on how to generate our API bindings, then follow the steps below.

Requirements

  • go >= 1.16

Contributing

Before opening a PR be sure to format your code!

go fmt ./...

Running Tests

Simply run:

go test ./...

Publishing

Releases use go modules and are automatically published by tagging the release commit.

Documentation

Overview

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Package svix this file is @generated DO NOT EDIT

Index

Constants

View Source
const Version = "1.58.1"

Variables

This section is empty.

Functions

func NewMessageInRaw added in v1.43.0

func NewMessageInRaw(
	eventType string,
	payload string,
	contentType *string,
) *models.MessageIn

Instantiates a new MessageIn object with a raw string payload. The payload is not normalized on the server. Normally, payloads are required to be JSON, and Svix will minify the payload before sending the webhook (for example, by removing extraneous whitespace or unnecessarily escaped characters in strings). With this function, the payload will be sent "as is", without any minification or other processing.

The `contentType` parameter can be used to change the `content-type` header of the webhook sent by Svix overriding the default of `application/json`.

See the class documentation for details about the other parameters.

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func (*Application) Create

func (application *Application) Create(
	ctx context.Context,
	applicationIn models.ApplicationIn,
	o *ApplicationCreateOptions,
) (*models.ApplicationOut, error)

Create a new application.

func (*Application) Delete

func (application *Application) Delete(
	ctx context.Context,
	appId string,
) error

Delete an application.

func (*Application) Get

func (application *Application) Get(
	ctx context.Context,
	appId string,
) (*models.ApplicationOut, error)

Get an application.

func (*Application) GetOrCreate added in v0.52.0

func (application *Application) GetOrCreate(
	ctx context.Context,
	applicationIn models.ApplicationIn,
	o *ApplicationCreateOptions,
) (*models.ApplicationOut, error)

Get or create a new application.

func (*Application) List

List of all the organization's applications.

func (*Application) Patch added in v1.6.0

func (application *Application) Patch(
	ctx context.Context,
	appId string,
	applicationPatch models.ApplicationPatch,
) (*models.ApplicationOut, error)

Partially update an application.

func (*Application) Update

func (application *Application) Update(
	ctx context.Context,
	appId string,
	applicationIn models.ApplicationIn,
) (*models.ApplicationOut, error)

Update an application.

type ApplicationCreateOptions added in v1.57.0

type ApplicationCreateOptions struct {
	IdempotencyKey *string
}

type ApplicationListOptions

type ApplicationListOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// The sorting order of the returned items
	Order *models.Ordering
}

type Authentication

type Authentication struct {
	// contains filtered or unexported fields
}

func (*Authentication) AppPortalAccess added in v0.75.0

func (authentication *Authentication) AppPortalAccess(
	ctx context.Context,
	appId string,
	appPortalAccessIn models.AppPortalAccessIn,
	o *AuthenticationAppPortalAccessOptions,
) (*models.AppPortalAccessOut, error)

Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal.

func (*Authentication) DashboardAccess

func (authentication *Authentication) DashboardAccess(
	ctx context.Context,
	appId string,
	o *AuthenticationDashboardAccessOptions,
) (*models.DashboardAccessOut, error)

DEPRECATED: Please use `app-portal-access` instead.

Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal.

func (*Authentication) ExpireAll added in v1.57.0

func (authentication *Authentication) ExpireAll(
	ctx context.Context,
	appId string,
	applicationTokenExpireIn models.ApplicationTokenExpireIn,
	o *AuthenticationExpireAllOptions,
) error

Expire all of the tokens associated with a specific application.

func (*Authentication) Logout

func (authentication *Authentication) Logout(
	ctx context.Context,
	o *AuthenticationLogoutOptions,
) error

Logout an app token.

Trying to log out other tokens will fail.

type AuthenticationAppPortalAccessOptions added in v1.57.0

type AuthenticationAppPortalAccessOptions struct {
	IdempotencyKey *string
}

type AuthenticationDashboardAccessOptions added in v1.57.0

type AuthenticationDashboardAccessOptions struct {
	IdempotencyKey *string
}

type AuthenticationExpireAllOptions added in v1.57.0

type AuthenticationExpireAllOptions struct {
	IdempotencyKey *string
}

type AuthenticationLogoutOptions added in v1.57.0

type AuthenticationLogoutOptions struct {
	IdempotencyKey *string
}

type BackgroundTask added in v1.4.12

type BackgroundTask struct {
	// contains filtered or unexported fields
}

func (*BackgroundTask) Get added in v1.4.12

func (backgroundTask *BackgroundTask) Get(
	ctx context.Context,
	taskId string,
) (*models.BackgroundTaskOut, error)

Get a background task by ID.

func (*BackgroundTask) List added in v1.4.12

List background tasks executed in the past 90 days.

type BackgroundTaskListOptions added in v1.4.12

type BackgroundTaskListOptions struct {

	// Filter the response based on the status.
	Status *models.BackgroundTaskStatus

	// Filter the response based on the type.
	Task *models.BackgroundTaskType
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// The sorting order of the returned items
	Order *models.Ordering
}

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

func (*Endpoint) Create

func (endpoint *Endpoint) Create(
	ctx context.Context,
	appId string,
	endpointIn models.EndpointIn,
	o *EndpointCreateOptions,
) (*models.EndpointOut, error)

Create a new endpoint for the application.

When `secret` is `null` the secret is automatically generated (recommended).

func (*Endpoint) Delete

func (endpoint *Endpoint) Delete(
	ctx context.Context,
	appId string,
	endpointId string,
) error

Delete an endpoint.

func (*Endpoint) Get

func (endpoint *Endpoint) Get(
	ctx context.Context,
	appId string,
	endpointId string,
) (*models.EndpointOut, error)

Get an endpoint.

func (*Endpoint) GetHeaders

func (endpoint *Endpoint) GetHeaders(
	ctx context.Context,
	appId string,
	endpointId string,
) (*models.EndpointHeadersOut, error)

Get the additional headers to be sent with the webhook.

func (*Endpoint) GetSecret

func (endpoint *Endpoint) GetSecret(
	ctx context.Context,
	appId string,
	endpointId string,
) (*models.EndpointSecretOut, error)

Get the endpoint's signing secret.

This is used to verify the authenticity of the webhook. For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).

func (*Endpoint) GetStats added in v0.66.0

func (endpoint *Endpoint) GetStats(
	ctx context.Context,
	appId string,
	endpointId string,
	o *EndpointGetStatsOptions,
) (*models.EndpointStats, error)

Get basic statistics for the endpoint.

func (*Endpoint) List

func (endpoint *Endpoint) List(
	ctx context.Context,
	appId string,
	o *EndpointListOptions,
) (*models.ListResponseEndpointOut, error)

List the application's endpoints.

func (*Endpoint) Patch added in v1.6.0

func (endpoint *Endpoint) Patch(
	ctx context.Context,
	appId string,
	endpointId string,
	endpointPatch models.EndpointPatch,
) (*models.EndpointOut, error)

Partially update an endpoint.

func (*Endpoint) PatchHeaders

func (endpoint *Endpoint) PatchHeaders(
	ctx context.Context,
	appId string,
	endpointId string,
	endpointHeadersPatchIn models.EndpointHeadersPatchIn,
) error

Partially set the additional headers to be sent with the webhook.

func (*Endpoint) Recover

func (endpoint *Endpoint) Recover(
	ctx context.Context,
	appId string,
	endpointId string,
	recoverIn models.RecoverIn,
	o *EndpointRecoverOptions,
) (*models.RecoverOut, error)

Resend all failed messages since a given time.

Messages that were sent successfully, even if failed initially, are not resent.

func (*Endpoint) ReplayMissing added in v0.76.1

func (endpoint *Endpoint) ReplayMissing(
	ctx context.Context,
	appId string,
	endpointId string,
	replayIn models.ReplayIn,
	o *EndpointReplayMissingOptions,
) (*models.ReplayOut, error)

Replays messages to the endpoint.

Only messages that were created after `since` will be sent. Messages that were previously sent to the endpoint are not resent.

func (*Endpoint) RotateSecret

func (endpoint *Endpoint) RotateSecret(
	ctx context.Context,
	appId string,
	endpointId string,
	endpointSecretRotateIn models.EndpointSecretRotateIn,
	o *EndpointRotateSecretOptions,
) error

Rotates the endpoint's signing secret.

The previous secret will remain valid for the next 24 hours.

func (*Endpoint) SendExample added in v0.83.0

func (endpoint *Endpoint) SendExample(
	ctx context.Context,
	appId string,
	endpointId string,
	eventExampleIn models.EventExampleIn,
	o *EndpointSendExampleOptions,
) (*models.MessageOut, error)

Send an example message for an event.

func (*Endpoint) TransformationGet added in v0.76.0

func (endpoint *Endpoint) TransformationGet(
	ctx context.Context,
	appId string,
	endpointId string,
) (*models.EndpointTransformationOut, error)

Get the transformation code associated with this endpoint.

func (*Endpoint) TransformationPartialUpdate added in v1.14.0

func (endpoint *Endpoint) TransformationPartialUpdate(
	ctx context.Context,
	appId string,
	endpointId string,
	endpointTransformationIn models.EndpointTransformationIn,
) error

Set or unset the transformation code associated with this endpoint.

func (*Endpoint) Update

func (endpoint *Endpoint) Update(
	ctx context.Context,
	appId string,
	endpointId string,
	endpointUpdate models.EndpointUpdate,
) (*models.EndpointOut, error)

Update an endpoint.

func (*Endpoint) UpdateHeaders

func (endpoint *Endpoint) UpdateHeaders(
	ctx context.Context,
	appId string,
	endpointId string,
	endpointHeadersIn models.EndpointHeadersIn,
) error

Set the additional headers to be sent with the webhook.

type EndpointCreateOptions added in v1.57.0

type EndpointCreateOptions struct {
	IdempotencyKey *string
}

type EndpointGetStatsOptions added in v1.57.0

type EndpointGetStatsOptions struct {
	// Filter the range to data starting from this date.
	Since *time.Time
	// Filter the range to data ending by this date.
	Until *time.Time
}

type EndpointListOptions

type EndpointListOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// The sorting order of the returned items
	Order *models.Ordering
}

type EndpointRecoverOptions added in v1.57.0

type EndpointRecoverOptions struct {
	IdempotencyKey *string
}

type EndpointReplayMissingOptions added in v1.57.0

type EndpointReplayMissingOptions struct {
	IdempotencyKey *string
}

type EndpointRotateSecretOptions added in v1.57.0

type EndpointRotateSecretOptions struct {
	IdempotencyKey *string
}

type EndpointSendExampleOptions added in v1.57.0

type EndpointSendExampleOptions struct {
	IdempotencyKey *string
}

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error provides access to the body, status, and error on returned errors.

func (Error) Body

func (e Error) Body() []byte

Body returns the raw bytes of the response.

func (Error) Error

func (e Error) Error() string

Error returns non-empty string if there was an error.

func (Error) Status

func (e Error) Status() int

Status returns the HTTP status of the error.

type EventType

type EventType struct {
	// contains filtered or unexported fields
}

func (*EventType) Create

func (eventType *EventType) Create(
	ctx context.Context,
	eventTypeIn models.EventTypeIn,
	o *EventTypeCreateOptions,
) (*models.EventTypeOut, error)

Create new or unarchive existing event type.

Unarchiving an event type will allow endpoints to filter on it and messages to be sent with it. Endpoints filtering on the event type before archival will continue to filter on it. This operation does not preserve the description and schemas.

func (*EventType) Delete

func (eventType *EventType) Delete(
	ctx context.Context,
	eventTypeName string,
	o *EventTypeDeleteOptions,
) error

Archive an event type.

Endpoints already configured to filter on an event type will continue to do so after archival. However, new messages can not be sent with it and endpoints can not filter on it. An event type can be unarchived with the [create operation](#operation/create_event_type_api_v1_event_type__post).

func (*EventType) Get

func (eventType *EventType) Get(
	ctx context.Context,
	eventTypeName string,
) (*models.EventTypeOut, error)

Get an event type.

func (*EventType) ImportOpenapi added in v1.57.0

func (eventType *EventType) ImportOpenapi(
	ctx context.Context,
	eventTypeImportOpenApiIn models.EventTypeImportOpenApiIn,
	o *EventTypeImportOpenapiOptions,
) (*models.EventTypeImportOpenApiOut, error)

Given an OpenAPI spec, create new or update existing event types. If an existing `archived` event type is updated, it will be unarchived.

The importer will convert all webhooks found in the either the `webhooks` or `x-webhooks` top-level.

func (*EventType) List

Return the list of event types.

func (*EventType) Patch added in v1.6.0

func (eventType *EventType) Patch(
	ctx context.Context,
	eventTypeName string,
	eventTypePatch models.EventTypePatch,
) (*models.EventTypeOut, error)

Partially update an event type.

func (*EventType) Update

func (eventType *EventType) Update(
	ctx context.Context,
	eventTypeName string,
	eventTypeUpdate models.EventTypeUpdate,
) (*models.EventTypeOut, error)

Update an event type.

type EventTypeCreateOptions added in v1.57.0

type EventTypeCreateOptions struct {
	IdempotencyKey *string
}

type EventTypeDeleteOptions added in v1.13.0

type EventTypeDeleteOptions struct {
	// By default event types are archived when "deleted". Passing this to `true` deletes them entirely.
	Expunge *bool
}

type EventTypeImportOpenapiOptions added in v1.57.0

type EventTypeImportOpenapiOptions struct {
	IdempotencyKey *string
}

type EventTypeListOptions

type EventTypeListOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// The sorting order of the returned items
	Order *models.Ordering
	// When `true` archived (deleted but not expunged) items are included in the response.
	IncludeArchived *bool
	// When `true` the full item (including the schema) is included in the response.
	WithContent *bool
}

type Integration

type Integration struct {
	// contains filtered or unexported fields
}

func (*Integration) Create

func (integration *Integration) Create(
	ctx context.Context,
	appId string,
	integrationIn models.IntegrationIn,
	o *IntegrationCreateOptions,
) (*models.IntegrationOut, error)

Create an integration.

func (*Integration) Delete

func (integration *Integration) Delete(
	ctx context.Context,
	appId string,
	integId string,
) error

Delete an integration.

func (*Integration) Get

func (integration *Integration) Get(
	ctx context.Context,
	appId string,
	integId string,
) (*models.IntegrationOut, error)

Get an integration.

func (*Integration) GetKey deprecated

func (integration *Integration) GetKey(
	ctx context.Context,
	appId string,
	integId string,
) (*models.IntegrationKeyOut, error)

Get an integration's key.

Deprecated: GetKey is deprecated.

func (*Integration) List

List the application's integrations.

func (*Integration) RotateKey

func (integration *Integration) RotateKey(
	ctx context.Context,
	appId string,
	integId string,
	o *IntegrationRotateKeyOptions,
) (*models.IntegrationKeyOut, error)

Rotate the integration's key. The previous key will be immediately revoked.

func (*Integration) Update

func (integration *Integration) Update(
	ctx context.Context,
	appId string,
	integId string,
	integrationUpdate models.IntegrationUpdate,
) (*models.IntegrationOut, error)

Update an integration.

type IntegrationCreateOptions added in v1.57.0

type IntegrationCreateOptions struct {
	IdempotencyKey *string
}

type IntegrationListOptions

type IntegrationListOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// The sorting order of the returned items
	Order *models.Ordering
}

type IntegrationRotateKeyOptions added in v1.57.0

type IntegrationRotateKeyOptions struct {
	IdempotencyKey *string
}

type Message

type Message struct {
	// contains filtered or unexported fields
}

func (*Message) Create

func (message *Message) Create(
	ctx context.Context,
	appId string,
	messageIn models.MessageIn,
	o *MessageCreateOptions,
) (*models.MessageOut, error)

Creates a new message and dispatches it to all of the application's endpoints.

The `eventId` is an optional custom unique ID. It's verified to be unique only up to a day, after that no verification will be made. If a message with the same `eventId` already exists for the application, a 409 conflict error will be returned.

The `eventType` indicates the type and schema of the event. All messages of a certain `eventType` are expected to have the same schema. Endpoints can choose to only listen to specific event types. Messages can also have `channels`, which similar to event types let endpoints filter by them. Unlike event types, messages can have multiple channels, and channels don't imply a specific message content or schema.

The `payload` property is the webhook's body (the actual webhook message). Svix supports payload sizes of up to ~350kb, though it's generally a good idea to keep webhook payloads small, probably no larger than 40kb.

func (*Message) ExpungeContent added in v0.76.0

func (message *Message) ExpungeContent(
	ctx context.Context,
	appId string,
	msgId string,
) error

Delete the given message's payload.

Useful in cases when a message was accidentally sent with sensitive content. The message can't be replayed or resent once its payload has been deleted or expired.

func (*Message) Get

func (message *Message) Get(
	ctx context.Context,
	appId string,
	msgId string,
	o *MessageGetOptions,
) (*models.MessageOut, error)

Get a message by its ID or eventID.

func (*Message) List

func (message *Message) List(
	ctx context.Context,
	appId string,
	o *MessageListOptions,
) (*models.ListResponseMessageOut, error)

List all of the application's messages.

The `before` and `after` parameters let you filter all items created before or after a certain date. These can be used alongside an iterator to paginate over results within a certain window.

Note that by default this endpoint is limited to retrieving 90 days' worth of data relative to now or, if an iterator is provided, 90 days before/after the time indicated by the iterator ID. If you require data beyond those time ranges, you will need to explicitly set the `before` or `after` parameter as appropriate.

type MessageAttempt

type MessageAttempt struct {
	// contains filtered or unexported fields
}

func (*MessageAttempt) ExpungeContent added in v0.76.0

func (messageAttempt *MessageAttempt) ExpungeContent(
	ctx context.Context,
	appId string,
	msgId string,
	attemptId string,
) error

Deletes the given attempt's response body.

Useful when an endpoint accidentally returned sensitive content. The message can't be replayed or resent once its payload has been deleted or expired.

func (*MessageAttempt) Get

func (messageAttempt *MessageAttempt) Get(
	ctx context.Context,
	appId string,
	msgId string,
	attemptId string,
) (*models.MessageAttemptOut, error)

`msg_id`: Use a message id or a message `eventId`

func (*MessageAttempt) ListAttemptedDestinations

func (messageAttempt *MessageAttempt) ListAttemptedDestinations(
	ctx context.Context,
	appId string,
	msgId string,
	o *MessageAttemptListAttemptedDestinationsOptions,
) (*models.ListResponseMessageEndpointOut, error)

List endpoints attempted by a given message.

Additionally includes metadata about the latest message attempt. By default, endpoints are listed in ascending order by ID.

func (*MessageAttempt) ListAttemptedMessages

func (messageAttempt *MessageAttempt) ListAttemptedMessages(
	ctx context.Context,
	appId string,
	endpointId string,
	o *MessageAttemptListAttemptedMessagesOptions,
) (*models.ListResponseEndpointMessageOut, error)

List messages for a particular endpoint. Additionally includes metadata about the latest message attempt.

The `before` parameter lets you filter all items created before a certain date and is ignored if an iterator is passed.

Note that by default this endpoint is limited to retrieving 90 days' worth of data relative to now or, if an iterator is provided, 90 days before/after the time indicated by the iterator ID. If you require data beyond those time ranges, you will need to explicitly set the `before` or `after` parameter as appropriate.

func (*MessageAttempt) ListByEndpoint added in v0.48.0

func (messageAttempt *MessageAttempt) ListByEndpoint(
	ctx context.Context,
	appId string,
	endpointId string,
	o *MessageAttemptListByEndpointOptions,
) (*models.ListResponseMessageAttemptOut, error)

List attempts by endpoint id

Note that by default this endpoint is limited to retrieving 90 days' worth of data relative to now or, if an iterator is provided, 90 days before/after the time indicated by the iterator ID. If you require data beyond those time ranges, you will need to explicitly set the `before` or `after` parameter as appropriate.

func (*MessageAttempt) ListByMsg added in v0.48.0

List attempts by message ID.

Note that by default this endpoint is limited to retrieving 90 days' worth of data relative to now or, if an iterator is provided, 90 days before/after the time indicated by the iterator ID. If you require data beyond those time ranges, you will need to explicitly set the `before` or `after` parameter as appropriate.

func (*MessageAttempt) Resend

func (messageAttempt *MessageAttempt) Resend(
	ctx context.Context,
	appId string,
	msgId string,
	endpointId string,
	o *MessageAttemptResendOptions,
) error

Resend a message to the specified endpoint.

type MessageAttemptListAttemptedDestinationsOptions added in v1.57.0

type MessageAttemptListAttemptedDestinationsOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string
}

type MessageAttemptListAttemptedMessagesOptions added in v1.57.0

type MessageAttemptListAttemptedMessagesOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string
	// Filter response based on the channel
	Channel *string
	// Filter response based on the message tags
	Tag *string

	// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
	Status *models.MessageStatus
	// Only include items created before a certain date
	Before *time.Time
	// Only include items created after a certain date
	After *time.Time
	// When `true` message payloads are included in the response
	WithContent *bool
	// Filter response based on the event type
	EventTypes *[]string
}

type MessageAttemptListByEndpointOptions added in v1.57.0

type MessageAttemptListByEndpointOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
	Status *models.MessageStatus

	// Filter response based on the HTTP status code
	StatusCodeClass *models.StatusCodeClass
	// Filter response based on the channel
	Channel *string
	// Filter response based on the tag
	Tag *string
	// Only include items created before a certain date
	Before *time.Time
	// Only include items created after a certain date
	After *time.Time
	// When `true` attempt content is included in the response
	WithContent *bool
	// When `true`, the message information is included in the response
	WithMsg *bool
	// Filter response based on the event type
	EventTypes *[]string
}

type MessageAttemptListByMsgOptions added in v1.57.0

type MessageAttemptListByMsgOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
	Status *models.MessageStatus

	// Filter response based on the HTTP status code
	StatusCodeClass *models.StatusCodeClass
	// Filter response based on the channel
	Channel *string
	// Filter response based on the tag
	Tag *string
	// Filter the attempts based on the attempted endpoint
	EndpointId *string
	// Only include items created before a certain date
	Before *time.Time
	// Only include items created after a certain date
	After *time.Time
	// When `true` attempt content is included in the response
	WithContent *bool
	// Filter response based on the event type
	EventTypes *[]string
}

type MessageAttemptResendOptions added in v1.57.0

type MessageAttemptResendOptions struct {
	IdempotencyKey *string
}

type MessageCreateOptions added in v1.57.0

type MessageCreateOptions struct {
	// When `true`, message payloads are included in the response.
	WithContent    *bool
	IdempotencyKey *string
}

type MessageGetOptions added in v1.57.0

type MessageGetOptions struct {
	// When `true` message payloads are included in the response.
	WithContent *bool
}

type MessageListOptions

type MessageListOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string
	// Filter response based on the channel.
	Channel *string
	// Only include items created before a certain date.
	Before *time.Time
	// Only include items created after a certain date.
	After *time.Time
	// When `true` message payloads are included in the response.
	WithContent *bool
	// Filter messages matching the provided tag.
	Tag *string
	// Filter response based on the event type
	EventTypes *[]string
}

type OperationalWebhookEndpoint added in v1.39.0

type OperationalWebhookEndpoint struct {
	// contains filtered or unexported fields
}

func (*OperationalWebhookEndpoint) Create added in v1.39.0

Create an operational webhook endpoint.

func (*OperationalWebhookEndpoint) Delete added in v1.39.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Delete(
	ctx context.Context,
	endpointId string,
) error

Delete an operational webhook endpoint.

func (*OperationalWebhookEndpoint) Get added in v1.39.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Get(
	ctx context.Context,
	endpointId string,
) (*models.OperationalWebhookEndpointOut, error)

Get an operational webhook endpoint.

func (*OperationalWebhookEndpoint) GetHeaders added in v1.57.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) GetHeaders(
	ctx context.Context,
	endpointId string,
) (*models.OperationalWebhookEndpointHeadersOut, error)

Get the additional headers to be sent with the operational webhook.

func (*OperationalWebhookEndpoint) GetSecret added in v1.39.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) GetSecret(
	ctx context.Context,
	endpointId string,
) (*models.OperationalWebhookEndpointSecretOut, error)

Get an operational webhook endpoint's signing secret.

This is used to verify the authenticity of the webhook. For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).

func (*OperationalWebhookEndpoint) List added in v1.39.0

List operational webhook endpoints.

func (*OperationalWebhookEndpoint) RotateSecret added in v1.39.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) RotateSecret(
	ctx context.Context,
	endpointId string,
	operationalWebhookEndpointSecretIn models.OperationalWebhookEndpointSecretIn,
	o *OperationalWebhookEndpointRotateSecretOptions,
) error

Rotates an operational webhook endpoint's signing secret.

The previous secret will remain valid for the next 24 hours.

func (*OperationalWebhookEndpoint) Update added in v1.39.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) Update(
	ctx context.Context,
	endpointId string,
	operationalWebhookEndpointUpdate models.OperationalWebhookEndpointUpdate,
) (*models.OperationalWebhookEndpointOut, error)

Update an operational webhook endpoint.

func (*OperationalWebhookEndpoint) UpdateHeaders added in v1.57.0

func (operationalWebhookEndpoint *OperationalWebhookEndpoint) UpdateHeaders(
	ctx context.Context,
	endpointId string,
	operationalWebhookEndpointHeadersIn models.OperationalWebhookEndpointHeadersIn,
) error

Set the additional headers to be sent with the operational webhook.

type OperationalWebhookEndpointCreateOptions added in v1.57.0

type OperationalWebhookEndpointCreateOptions struct {
	IdempotencyKey *string
}

type OperationalWebhookEndpointListOptions added in v1.39.0

type OperationalWebhookEndpointListOptions struct {
	// Limit the number of returned items
	Limit *uint64
	// The iterator returned from a prior invocation
	Iterator *string

	// The sorting order of the returned items
	Order *models.Ordering
}

type OperationalWebhookEndpointRotateSecretOptions added in v1.57.0

type OperationalWebhookEndpointRotateSecretOptions struct {
	IdempotencyKey *string
}

type Statistics added in v1.14.0

type Statistics struct {
	// contains filtered or unexported fields
}

func (*Statistics) AggregateAppStats added in v1.14.0

func (statistics *Statistics) AggregateAppStats(
	ctx context.Context,
	appUsageStatsIn models.AppUsageStatsIn,
	o *StatisticsAggregateAppStatsOptions,
) (*models.AppUsageStatsOut, error)

Creates a background task to calculate the message destinations for all applications in the environment.

Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation.

func (*Statistics) AggregateEventTypes added in v1.14.0

func (statistics *Statistics) AggregateEventTypes(
	ctx context.Context,
) (*models.AggregateEventTypesOut, error)

Creates a background task to calculate the listed event types for all apps in the organization.

Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation.

type StatisticsAggregateAppStatsOptions added in v1.57.0

type StatisticsAggregateAppStatsOptions struct {
	IdempotencyKey *string
}

type Svix

type Svix struct {
	Authentication             *Authentication
	Application                *Application
	Endpoint                   *Endpoint
	EventType                  *EventType
	Integration                *Integration
	Message                    *Message
	MessageAttempt             *MessageAttempt
	Statistics                 *Statistics
	OperationalWebhookEndpoint *OperationalWebhookEndpoint
}

func New

func New(token string, options *SvixOptions) (*Svix, error)

type SvixHttpClient added in v1.57.0

type SvixHttpClient struct {
	DefaultHeaders map[string]string
	HTTPClient     *http.Client
	RetrySchedule  []time.Duration
	BaseURL        string
	Debug          bool
}

type SvixOptions

type SvixOptions struct {
	ServerUrl     *url.URL
	HTTPClient    *http.Client
	RetrySchedule *[]time.Duration
	Debug         bool
}

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook(secret string) (*Webhook, error)

func NewWebhookRaw added in v0.63.0

func NewWebhookRaw(secret []byte) (*Webhook, error)

func (*Webhook) Sign

func (wh *Webhook) Sign(msgId string, timestamp time.Time, payload []byte) (string, error)

func (*Webhook) Verify

func (wh *Webhook) Verify(payload []byte, headers http.Header) error

Verify validates the payload against the svix signature headers using the webhooks signing secret.

Returns an error if the body or headers are missing/unreadable or if the signature doesn't match.

func (*Webhook) VerifyIgnoringTimestamp

func (wh *Webhook) VerifyIgnoringTimestamp(payload []byte, headers http.Header) error

VerifyIgnoringTimestamp validates the payload against the svix signature headers using the webhooks signing secret.

Returns an error if the body or headers are missing/unreadable or if the signature doesn't match.

WARNING: This function does not check the signature's timestamp. We recommend using the `Verify` function instead.

Directories

Path Synopsis
Package svix this file is @generated DO NOT EDIT
Package svix this file is @generated DO NOT EDIT

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL