Webhooks
The SnapTrade API can be configured to send you webhook notifications when certain events happen.
To get started with webhooks, contact your Customer Success Manager. They will need the URL of your webhook handler for webhook notifications to begin to be sent.
Verifying Webhook Authenticity
You can verify the authenticity of any SnapTrade webhook by verifying the webhookSecret
field contained in the body of any webhook.
Contact your customer success manager to get the correct value of this secret.
Aside from webhook secrets:
- SnapTrade supports custom webhook request headers (which are useful if your webhook handler is protected by Cloudflare)
- SnapTrade does not support IP whitelisting at this time
Handling Undeliverable Webhooks
When your webhook handler responds to our requests with a status code that is not 200 or 201, we mark that webhook as undelivered in our system.
We will attempt to resend an undeliverable webhook notification with an exponential backoff (starting at 30 minutes) until it is either delivered successfully, or 10 retry attempts have been made.
Webhook Types
The different webhook event types are outlined below.
USER_REGISTERED
Sent when a new user is successfully registered through the /registerUser/
endpoint.
Example payload is below:
CONNECTION_ATTEMPTED
Sent when a user a user attempts to make a brokerage connection, will also report the result of the attempt.
Example payload is below:
Possible values for the connectionAttemptedResult
field are:
SUCCESS
AUTH_EXPIRED
INVALID_AUTH_CODE
AUTH_NOT_IN_PROGRESS
DIFFERENT_ACCOUNT
UNCAUGHT_ERROR
INVALID_CREDENTIALS
INVALID_MFA_CODE
NO_DATA
CONNECTION_ADDED
Sent when a new brokerage connection is created using the SnapTrade connection portal.
Example payload is below.
CONNECTION_DELETED
Sent when a user deletes an existing connection using the SnapTrade connection portal.
Example payload is below:
CONNECTION_BROKEN
Sent when a user's connection is broken for some reason, usually an inability to handshake with the brokerage's API.
Example payload is below:
CONNECTION_FIXED
Sent when a broken connection is fixed.
Example payload is below:
CONNECTION_UPDATED
Sent when a brokerage connection is updated.
Example payload is below:
CONNECTION_FAILED
Sent when a user’s attempt to connect to a brokerage has failed.
Example payload is below:
NEW_ACCOUNT_AVAILABLE
Sent when a new account is detected through a brokerage connection.
Example payload is below:
ACCOUNT_TRANSACTIONS_INITIAL_UPDATE
Sent the first time that we collect transactions data from a brokerage account.
Example payload is below:
ACCOUNT_TRANSACTIONS_UPDATED
Sent when account transactions are updated.
Example payload is below:
ACCOUNT_REMOVED
Sent when an account is removed from a connection.
Example payload is below:
TRADES_PLACED
Gets sent when new trades are detected in a user's account.
On average, you'll receive a webhook within 30 minutes of activity occurring in the account (we poll once per hour).
We send 1 webhook regardless of how many new trades are identified in your account. So if we identify 1 trade in the account, we'll send 1 webhook; and if we identify 10 trades in the account, we also only send 1 webhook.
Please contact us in order to receive these webhooks as they are disabled by default.
Example payload is below:
ACCOUNT_HOLDINGS_UPDATED
Gets sent when holdings for an account has been updated. Updated does not necessarily mean that the holdings have changed, instead it means that updating holdings with new data has been attempted. In the rare case that a holdings update fails (for example when a brokerage's API is down for maintenance), the webhook will still be sent and details on what failed will be included as part of the details field in the body.
This webhook will be sent when we run our daily account syncs, as well as if a manual account refresh has been requested via: https://docs.snaptrade.com/reference/Connections/Connections_refreshBrokerageAuthorization
Account Holdings in this context refers to:
- Positions
- Balances
- Orders
- Total Account Value
- Account Detail
Historical transactions will be polled for, but will not fetch transactions from the current day
Example payload is below: