Inxmail - 123formbuilder - Zapier (javascript code)
Tue May 20 2025 11:50:25 GMT+0000 (Coordinated Universal Time)
Saved by
@abm
const url = 'https://api.inxmail.com/taconova/rest/v1/events/subscriptions/'; // Inxmail API endpoint
// Client ID and Secret (replace these with your actual values)
const clientId = 'CAS-genesisWorld247b5346-afad-4850-b5bb-afcd21c77978'; // Removed newline
const clientSecret = 'AOcVdS5XVYBvKWnJsCWJSSlZYfSoRraQwMphKNNknftJm-9cx5lC1g-y-ZJrDHp7LlpITpGqkpMev8F3o_oftPs'; // Replace with your actual Client Secret
const email = inputData.email || ''; // Email from the form submission
const Vorname = inputData.Vorname || ''; // Optional: first name
const Name = inputData.Name || ''; // Trimmed last name to remove newline
const Firma = inputData.Firma || '';
const Anrede = inputData.Anrede
const listId = 137; // List ID (use the list where you want to add the contact)
// Encode credentials for Basic Authentication (Base64-encoded 'clientId:clientSecret')
const authValue = `${clientId}:${clientSecret}`;
const base64Auth = Buffer.from(authValue).toString('base64'); // Encoding the credentials to Base64
// Request data to send to the Inxmail API
const requestData = {
email: email,
listId: listId,
attributes: {
Vorname: Vorname,
Name: Name,
Anrede: Anrede,
Firma: Firma
},
trackingPermission: "GRANTED", // You can set this as "GRANTED" for accepted tracking permission
source: "Web Form" // Example source, you can modify as needed
};
// Request options for the fetch call
const options = {
method: 'POST',
headers: {
'Authorization': `Basic ${base64Auth}`, // Basic Auth with Base64-encoded credentials
'Content-Type': 'application/json', // Set the correct content type for JSON
},
body: JSON.stringify(requestData), // Send the data as JSON in the request body
};
// Function to send the request
async function sendRequest() {
try {
const response = await fetch(url, options);
if (!response.ok) {
const errorText = await response.text(); // Get the error response text for debugging
throw new Error(`Inxmail API request failed: ${errorText}`);
}
const responseBody = await response.json(); // Process the response as JSON
// Return success and the response data
return {
success: true,
data: responseBody,
};
} catch (error) {
// Handle errors and return the error message
return {
success: false,
error: error.message,
};
}
}
// Execute the request and assign the result to output
output = await sendRequest();
content_copyCOPY
https://zapier.com/editor/296374873/published/296378499/
Comments