πŸ‘© User Management

Overview

The Co:Create API provides functionality for user management, including creating new users, updating user information, and retrieving user data.

Each user in the Co:Create system has a hosted wallet (Co:Create wallet) created for them. This wallet allows non-web3 users to store and interact with various web3 assets. You also have the option to link any external wallets associated with the user in their user profile. These can be self-custodial or any other kind of wallet that you have associated with the user in your system.

User Model

The user model includes the following properties:

  • email: the email address of the user - this is the primary key
  • first_name: the first name of the user
  • last_name: the last name of the user
  • phone_number: the phone number of the user
  • external_wallets: a list of external wallets associated with the user
  • cocreate_wallet_address: the Co:Create wallet address associated with the user
  • balances: the token balances associated with the user's cocreate_wallet_address

Methods

The following methods are available for user management:

  • POST /alpha/user: creates a new user
  • PATCH /alpha/user: updates an existing user
  • GET /alpha/user: retrieves an existing user

Guide

Creating a User

To create a new user, make a POST request to the Users API with the user's email address.

If the user does not already exist, a new user will be created with the given email address. If the user already exists, the existing user data will be returned.

πŸ“˜

All Co:Create Users Get Wallets

When you create a Co:Create user, a fresh wallet will be created and assigned to them. No need to integrate a wallet connection library and have the user bring their own. Unless you want to support that, of course!

Example request:

curl --request POST \
  --url 'https://api.testcocrt.xyz/alpha/user' \
  --header 'Authorization: Bearer <YOUR_API_KEY_HERE>' \
  --data '{"email":"[email protected]"}'

Example response:

{
  "data": {
    "email": "[email protected]",
    "first_name": "",
    "last_name": "",
    "phone_number": "",
    "cocreate_wallet_address": "0xd82a3c8d9d20868c664d91e62ddb0469f699902e",
    "external_wallets": [],
    "balances": {
      "0xd82a3c8d9d20868c664d91e62ddb0469f699902e": {
        "erc1155": [],
        "erc20": [],
        "erc721": []
      }
    }
  }
}

Getting a User

To retrieve an existing user, make a GET request to Users API with the email address of the user as a query parameter.

Example request:

curl --request GET \
  --url 'https://api.testcocrt.xyz/alpha/user?email=foo%40bar.com' \
  --header 'Authorization: Bearer <YOUR_API_KEY_HERE>'

Example response:

{
  "data": {
    "email": "[email protected]",
    "first_name": "foo",
    "last_name": "bar",
    "phone_number": "",
    "cocreate_wallet_address": "0x37cca6d8fa7ccf3b4c7f2c6892938fa607ff634f",
    "external_wallets": [],
    "balances": {
      "0x37cca6d8fa7ccf3b4c7f2c6892938fa607ff634f": {
        "erc1155": [],
        "erc20": [
          {
            "amount": 100,
            "chain": "polygon_mumbai",
            "co_create_issued": true,
            "contract_address": "0xfd1a39002814a66dfcf4f61006057505cba40599",
            "id": "5fc1c111-458e-48c0-8170-44aedfc9ccff",
            "symbol": "BREW"
          }
        ],
        "erc721": []
      }
    }
  }
}

Update User

To update a user, send a PATCH request to the Users API with the parameters to update.

πŸ“˜

Add External Wallets with Update User

Want to enable users to bring their own wallets? You can use Rainbow Kit or similar to allow the user to connect their wallet to your application and then update their Co:Create user profile with the wallet address public key.

Example request:

curl --request PATCH \
     --url https://api.testcocrt.xyz/alpha/user \
     --header 'Authorization: Bearer zpka_0f437243ad3844899135a956a37f7b4d_506049a6' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "email": "[email protected]",
  "first_name": "John",
  "last_name": "Smith"
}
'

Example response:

{
  "data": {
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Smith",
    "phone_number": "",
    "cocreate_wallet_address": "0x37cca6d8fa7ccf3b4c7f2c6892938fa607ff634f",
    "external_wallets": [
      "0x30391925ab782008febe2fbf05ea043ec966831c"
    ],
    "balances": {
      "0x37cca6d8fa7ccf3b4c7f2c6892938fa607ff634f": {
        "erc1155": [],
        "erc20": [
          {
            "amount": 100,
            "chain": "polygon_mumbai",
            "co_create_issued": true,
            "contract_address": "0xfd1a39002814a66dfcf4f61006057505cba40599",
            "id": "5fc1c111-458e-48c0-8170-44aedfc9ccff",
            "symbol": "BREW"
          }
        ],
        "erc721": []
      },
      "0x30391925ab782008febe2fbf05ea043ec966831c": {
        "erc1155": [],
        "erc20": [],
        "erc721": []
      }
    }
  }
}

πŸ‘

Get Help

If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].