Off-Exchange Settlement: Activate Client Connections - Partner
Build an endpoint to receive and process client connection requests from BitGo. See the Guide.
-
You build an endpoint that receives connection requests from BitGo when clients link their Go Network account to their account on your platform. Your endpoint must verify the authenticity of the request and the connection token before creating the connection. Ensure you validate that each connection is for a new account with no existing assets, and create only one connection per client account.
Prerequisites: You must verify the request signature and implement idempotent request handling.
// 1. Activate Client Connection
// BitGo sends this request to your endpoint: POST /bitgo/v1/connections
// Example incoming request from BitGo:
POST /bitgo/v1/connections
Request Headers:
{
"X-BitGo-Signature": "string"
}
Request Body:
{
"clientId": "UUID",
"clientWalletId": "string",
"connectionId": "UUID",
"connectionToken": "string",
"partnerId": "UUID"
}
// Your endpoint must respond with:
{
"clientId": "UUID",
"connectionId": "UUID",
"partnersClientId": "string",
"partnersConnectionId": "string"
}
// 1. Activate Client Connection
// Implement this endpoint on your server to receive BitGo's connection requests
import express from 'express';
import crypto from 'crypto';
const app = express();
app.use(express.json());
app.post('/bitgo/v1/connections', async (req, res) => {
try {
// Verify the signature from X-BitGo-Signature header
const signature = req.headers['x-bitgo-signature'];
// Implement signature verification logic here
const { clientId, clientWalletId, connectionId, connectionToken, partnerId } = req.body;
// Validate that this is a new account with no existing assets
// Ensure only 1 connection per client account
// Verify the connection token matches what the client provided
// Create the connection in your system
const connection = {
clientId: clientId,
connectionId: connectionId,
partnersClientId: "your-internal-client-id",
partnersConnectionId: "your-internal-connection-id"
};
// Return the connection details
res.status(200).json(connection);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(3000, () => {
console.log('Partner API listening on port 3000');
});
Response
// 1. Activate Client Connection Response
{
"clientId": "UUID",
"connectionId": "UUID",
"partnersClientId": "string",
"partnersConnectionId": "string"
}