The Autopilot screen allows users to view and manage their recurring investment/savings automations. Users can see their active automations and toggle them on or off.
Automations set up direct debit payments from a linked bank account on a specified day each month.
For top-up automations, funds are automatically invested proportionally across the user’s existing holdings.
Data sources
Prerequisites
Backend access to the M2M endpoints
Bearer token with required scopes
User must have at least one bank account set up
What to fetch
Use Get automations to retrieve all automations for a user. Returns:
Automation ID, status, and category
Monthly investment amount and currency
Day of month for collection (-1 for last day of month, 0-28 for specific day)
Linked mandate information (status, bank account)
Use Cancel automation when the user toggles off an automation.
Sends a POST request to /automations/{id}/cancel
Returns 202 Accepted on success
Pending deposits not yet submitted will be cancelled
Example: fetch automations
const BASE = 'https://api.wealthyhood.com' ;
async function fetchAutopilotScreen ({ token , userId }) {
const headers = {
'Authorization' : `Bearer ${ token } ` ,
'x-user-id' : userId ,
'Accept' : 'application/json'
};
const response = await fetch ( ` ${ BASE } /automations` , { headers });
if ( ! response . ok ) {
throw new Error ( `Failed to fetch automations: ${ response . status } ` );
}
const { data : automations } = await response . json ();
return {
automations: automations . map ( automation => ({
id: automation . id ,
isActive: automation . status === 'Active' ,
amount: automation . amount ,
currency: automation . currency ,
dayOfMonth: automation . dayOfMonth ,
mandateStatus: automation . mandate . status ,
bankAccountId: automation . mandate . bankAccountId
}))
};
}
Example: toggle automation off
When a user toggles off an automation, call the cancel endpoint:
async function cancelAutomation ({ token , userId , automationId }) {
const headers = {
'Authorization' : `Bearer ${ token } ` ,
'x-user-id' : userId ,
'Accept' : 'application/json'
};
const response = await fetch (
` ${ BASE } /automations/ ${ automationId } /cancel` ,
{ method: 'POST' , headers }
);
if ( response . status === 202 ) {
// Automation cancelled successfully
return { success: true };
}
throw new Error ( `Failed to cancel automation: ${ response . status } ` );
}
Example: enable new automation
To create (enable) a new automation, use the Create automation endpoint:
async function createAutomation ({ token , userId , bankAccountId , amount , dayOfMonth }) {
const headers = {
'Authorization' : `Bearer ${ token } ` ,
'x-user-id' : userId ,
'Content-Type' : 'application/json' ,
'Accept' : 'application/json'
};
const response = await fetch ( ` ${ BASE } /automations` , {
method: 'POST' ,
headers ,
body: JSON . stringify ({
category: 'TopUpAutomation' ,
bankAccountId ,
orderAmount: amount ,
dayOfMonth
})
});
if ( ! response . ok ) {
const error = await response . json ();
throw new Error ( error . error ?. message || 'Failed to create automation' );
}
return response . json ();
}
When creating an automation, a direct debit mandate will be automatically created for the specified
bank account if one doesn’t already exist. The mandate status will initially be Pending until
confirmed by the payment provider.
See also