It fails if the member was already added (email or cryptoAddress) — check the user before adding.
Copy
import zootools from 'zootools'zootools.setApiToken("YOUR_ZOOTOOLS_API_KEY_FROM_THE_DASHBOARD")const { contact, error } = await zootools.contacts.addOrUpdate({ firstName: 'Jorge', lastName: 'Ferreiro', email: '[email protected]',})if (!error) { console.log('contact', contact) // (optional) if you need it, you can store in your database the contact id (contact.id) in case // you want to keep a reference of zootools contacts into your system} else { console.log('error', error)}import axios from 'axios';const endpoint = 'https://api.zootools.co/v1/audience/contacts';const YOUR_ZOOTOOLS_API_TOKEN = 'your_api_token';axios .post(endpoint, { firstName: 'Jorge', lastName: 'Ferreiro', email: '[email protected]', }, { headers: { Authorization: Bearer ${YOUR_ZOOTOOLS_API_TOKEN}, } }) .then((response) => { console.log(response.data); // prints out the new member }) .catch((error) => { console.error(error); // there was an error... });
Copy
ENDPOINT- https://audience-consumer-api.zootools.co/v1/lists/{id}/membersPARAMS- listId*: string; // Get this id in the URL of the form.PAYLOAD// You must pass either an email, a cryptoAddress or both. One is required.- email**: string;- cryptoAddress**: string;- referral: string; // memberId who referred the user.- firstName: string;- lastName: string;- location: string;- twitter: string;- ... based on your form, you can pass extra values here.HEADERS:{ headers: { Authorization: `Bearer API_TOKEN_YOU_GOT_FROM_US`, }}// **Either Email or cryptoAddress are required. You can pass an email,// a wallet or both. If you don't pass any of them, the endpoint will raise// a 400 invalid argumentsRESPONSE{ member: Member (member object), // Unique user identifier. You can use this to uniquely fetch a user. jsonWebToken: string;}ERRORS// Anti BOTS!// If the user is banned in our system or it's a bot you will receive this.// If the user is using a temporary email address it will also raise this error.{ "statusCode": 401, "error": "Bad Request", "message": "lists/user_banned"}// If no parameters are provided{ "statusCode": 400, "error": "Bad Request", "message": "lists/email_or_crypto_address_required"}// User already exists in the database (either via email or contractAddress){ "statusCode": 400, "error": "Not Found", "message": "lists/already_member"}// NOT found list. most likely you pass a wrong listId{ "statusCode": 404, "error": "Not Found", "message": "lists/not_found"}// Internal error. Try again.{ "statusCode": 500, "error": "Internal error", "message": "lists/adding_member_internal_error"}
The default value that’s designed to be a prefix for the authentication input field.E.g. If an inputPrefix of AuthKey would inherit the default input result of the authentication field as AuthKey.