Create a UserPool

A UserPool represents a group of users and the means to authenticate them. Specifically, issuing and validating authentication tokens called appUserIdTokens.

Anon offers two types of UserPools:

  • Anon-hosted
  • Self-hosted

This guide only covers on Anon-hosted UserPools. Alternatively, learn how to use Self-hosted UserPools.

Anon-hosted UserPools allow you to easily issue appUserIdTokens for your users without external dependencies.

Let’s get started!

The following examples send requests to Anon’s sandbox environment. To use the production environment, replace svc.sandbox.anon.com with svc.prod.anon.com.

First, create an Anon-hosted UserPool:

curl --request POST \
  --url https://svc.sandbox.anon.com/org/userPool \
  --header 'Authorization: Bearer <YOUR_ANON_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "<USER_POOL_NAME>",
    "description": "<USER_POOL_DESCRIPTION>",
  }'

Replace the placeholders:

  • <YOUR_ANON_API_KEY>: Your Anon API key
  • <USER_POOL_NAME>: Name for your UserPool
  • <USER_POOL_DESCRIPTION>: Brief description of the UserPool

Save the returned UserPool ID for future use.

With your UserPool created, you can now generate appUserIdTokens, and create SdkClients to integrate Anon Link into your application.

Create an SdkClient

An SdkClient is used in combination with an appUserIdToken (which we will issue in the next step) to identify your users. An SdkClient is associated with a UserPool.

Create one as follows:

curl --request POST \
  --url https://svc.sandbox.anon.com/org/sdkClient \
  --header 'Authorization: Bearer <YOUR_ANON_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "<SDK_CLIENT_NAME>",
    "kind": { "application": { "userPoolId": "<ANON_USER_POOL_ID>" } },
    "description": "<SDK_CLIENT_DESCRIPTION>"
  }'

Replace the placeholders:

  • <YOUR_ANON_API_KEY>: Your Anon API key
  • <ANON_USER_POOL_ID>: ID of the UserPool you just created
  • <SDK_CLIENT_NAME>: Name for your SdkClient
  • <SDK_CLIENT_DESCRIPTION>: Brief description of the SdkClient

Save the returned SdkClient ID for future use. You’ll need it to create appUserIdTokens and to initialize Anon Link.

Issue an AppUserIdToken

An appUserIdToken is used to identify a single unique user, and should be issued to each individual user of your applications. This credential is sensitive and can be used to save the user’s sessions, so it should be stored securely or not at all. You may call this endpoint whenever necessary to get a new token.

Try creating one with the command below:

curl --request POST \
  --url https://svc.sandbox.anon.com/org/appUserIdToken \
  --header 'Authorization: Bearer <YOUR_ANON_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "sdkClientId": "<ANON_SDK_CLIENT_ID>",
    "appUserId": "<APP_USER_ID>"
  }'

Replace the placeholders:

  • <YOUR_ANON_API_KEY>: Your Anon API key
  • <ANON_SDK_CLIENT_ID>: Name for your SdkClient
  • <APP_USER_ID>: ID of the user you want to issue the token to. This can be any unique identifier.
  • <SDK_CLIENT_DESCRIPTION>: Brief description of the SdkClient

Anon supports several different platforms for Anon Link (see below). Regardless of the platform, the initialization takes two of the credentials we have just created: the SdkClient ID and an appUserIdToken.

Choose Your Platform