Create members using Bettermode's GraphQL API

Migrate members to your site using API

Follow these steps to migrate members to your site using the GraphQL API.

Step 1: Generate a Guest Access Token

Start by generating a guest access token. Use the following query:

query {
  getTokens(networkDomain: "[community.bettermode.com](http://community.bettermode.com/)") {
    accessToken
    role {
      name
      scopes
    }
    member {
      id
      name
    }
  }
}

Important: Replace the networkDomain value with your own domain.

The query returns a response containing your access token and member information.

Step 2: Generate a User Access Token

With your guest access token from Step 1, you can now create a user access token. This token is required for queries, mutations, and other API operations.

Include the guest access token in your request header using this format:

Authorization: Bearer {accessToken}

Use this query to generate the user access token:

query {
  loginNetwork(
    input: { usernameOrEmail: "bettermodeuser", password: "bettermodepassword" }
  ) {
    accessToken
    role {
      name
      scopes
    }
    member {
      id
      name
    }
  }
}

Important: Replace bettermodeuser with the member's email address or username, and bettermodepassword with the member's password.

The query returns a user access token that you can use for subsequent API calls.

Video tutorial: See How to generate a Bettermode Guest and User Access token for a walkthrough of Steps 1 and 2.

Step 3: Create a Member Using the joinNetwork Mutation

Use the user access token from Step 2 with the joinNetwork mutation to create a member on your site:

mutation {
  joinNetwork(
    input: {
      email: "[email protected]",
      name: "Name of the user",
      password: "TestPassword",
      phone: "+919213849901",
      username: "username-of-the-user"
    }
  ) {
    accessToken
    refreshToken
  }
}

The mutation returns access and refresh tokens for the newly created member.

Complete the Migration

You can now automate member creation and data migration by running these queries and mutations programmatically across your member database.

Contact Us

Do you still need help? Learn how to get in touch with the Bettermode Team.