Provides real-time updates regarding new user registrations from your application.
const WebSocket = require('ws')
const ws = new WebSocket('wss://ws.sfox.com/ws')
ws.on('open', function() {
const authMessage = {
type: 'authenticate',
apiKey: `process.env.ENTERPRISE_API_KEY`,
enterprise: 'true'
}
ws.send(JSON.stringify(authMessage))
})
// After successful authentication, subscribe to users feed
const subscribeMsg = {
type: 'subscribe',
feeds: ['private.enterprise.users']
}
ws.send(JSON.stringify(subscribeMsg))
import asyncio
import json
import websockets
import os
async def main(uri):
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"type": "authenticate",
"apiKey": f"{os.environ['ENTERPRISE_API_KEY']}",
"enterprise": "true"
}))
# After successful authentication message, subscribe to the users feed
await ws.send(json.dumps({
"type": "subscribe",
"feeds": ["private.enterprise.users"]
}))
async for msg in ws:
print(msg)
asyncio.run(main("wss://ws.sfox.com/ws"))
{
"sequence": 5,
"recipient": "private.enterprise.users",
"timestamp": 1717005327995988841,
"payload": {
"user_id": "client_09e487c9-9b75-4ef5-be06-b3e5661f68e5",
"first_name": "Brando",
"last_name": "Marks",
"email": "bruno@mailinator.com",
"phone_number": "+12223334444",
"account_role": "Client",
"account_type": "individual",
"status": "PENDING",
"user_token": {
"token": "2000611ea497d8ae4832c52166e0a26162cbb74716ab2662c50f8b47cdad3979",
"expires": "2024-05-30T17:55:27.981Z",
"partner_user_id": "client_09e487c9-9b75-4ef5-be06-b3e5661f68e5"
},
"requirements": {
"sms": true,
"email": true
}
}
}
{
"sequence": 5,
"recipient": "private.enterprise.users",
"timestamp": 1717005327995988841,
"payload": {
"user_id": "client_09e487c9-9b75-4ef5-be06-b3e5661f68e5",
"first_name": "Brando",
"last_name": "Marks",
"email": "bruno@mailinator.com",
"phone_number": "+12223334444",
"account_role": "Client",
"account_type": "individual",
"status": "VERIFIED",
"user_token": {
"token": "2000611ea497d8ae4832c52166e0a26162cbb74716ab2662c50f8b47cdad3979",
"expires": "2024-05-30T17:55:27.981Z",
"partner_user_id": "client_09e487c9-9b75-4ef5-be06-b3e5661f68e5"
},
"requirements": {
"sms": false,
"email": false
}
}
}