Skip to main content

[POST] Add or update a contact

It fails if the member was already added (email or cryptoAddress) — check the user before adding.
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...
    });

ENDPOINT
- https://audience-consumer-api.zootools.co/v1/lists/{id}/members

PARAMS
- 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 arguments

RESPONSE

{
	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"
}

Properties

name
string
required
Name of your project. Used for the global title.Example: mintlify
navigation
Navigation[]
required
An array of groups with all the pages within that group
Path to logo image or object with path to “light” and “dark” mode logo images
favicon
string
Path to the favicon image
colors
Colors
Hex color codes for your global theme
Array of names and urls of links you want to include in the topbar
topbarCtaButton
Call to Action
versions
string[]
Array of version names. Only use this if you want to show different versions of docs with a dropdown in the navigation bar.
anchors
Anchor[]
An array of the anchors, includes the icon, color, and url.
topAnchor
Object
Override the default configurations for the top-most anchor.
tabs
Tabs[]
An array of navigational tabs.
api
API
Configuration for API settings. Learn more about API pages at API Components.
openapi
string | string[]
A string or an array of strings of URL(s) or relative path(s) pointing to your OpenAPI file.Examples:
"openapi": "https://example.com/openapi.json"
An object of social media accounts where the key:property pair represents the social media platform and the account url.Example:
{
  "twitter": "https://twitter.com/mintlify",
  "website": "https://mintlify.com"
}
feedback
Feedback
Configurations to enable feedback buttons
modeToggle
ModeToggle
Customize the dark mode toggle.
backgroundImage
string
A background image to be displayed behind every page. See example with Infisical and FRPC.