Embedded accounts
async function createEmbeddedAccount(email, domain, userId) {
const url = 'https://beta.usemoon.ai/client';
const headers = {
'X-API-KEY': 'YOUR_API_TOKEN',
'Content-Type': 'application/json',
};
const body = JSON.stringify({
name: email,
metadata: {
from: domain,
user: userId,
},
});
const requestOptions = {
method: 'POST',
headers: headers,
body: body,
redirect: 'follow',
};
try {
const response = await fetch(url, requestOptions);
const result = await response.text();
console.log(result);
} catch (error) {
console.error(error);
}
}
createEmbeddedAccount('[email protected]', 'mydomain.com', '1234567890');Last updated