Skip to content

Register Device

Request URL

POST /prospect/registration

Description

This API is used to register a device to be used by this prospect. Either an existing user could be trying to register a new device or a completely new prospect (not yet a user) could be registering a device.

If the registration request is made by an existing user, the preSegment value will be "recovery". If registration is successful, the IP address of the new device is recorded in the database.

If the registration request is made by a prospect that is not a pre-existing user, the prospect will first be converted to an idle user and then to a user.

In order to convert to an idle user, first an ampliFi user object is created. A random AFiUserId will be generated and the database will be checked to verify that the AFiUserId is unique. The ampliFi user object (see example below) will be inserted into the ampliFi database and the new user's deviceTag will be marked as registered.

For a prospect (to new user) registration, after the new ampliFi user object is successfully inserted into the ampliFi database, the new user registration must be finalized. If the new user has a referral code, a task will be registered with the referree AFiUserId and the associated referral code so that a referral bonus can be paid to the referree.

Schema

Property table for prospect/registration

Property Description Required Schema
deviceTag The device tag (id) Yes {
  "type": "string"
}
preSegment The original category of prospect (ex. teacher, adult) Yes {
  "type": "string"
}
deviceData A device-specific set of data Yes {
  "additionalProperties": true,
  "type": "object",
  "required": []
}
referral A code from a friend No {
  "type": "string",
  "nullable": true
}

Request Body

  {
    "preSegment": "demo_uoiuqwehflkipahgoqq",
    "deviceData": {
        "platform": "android",
        "build": "0.0.01"
    },
    "deviceTag": "o1vd1oc0nw8",
    "referral": "BBQFCHQXN"
  }

Snippet Examples

javascript

const axios = require('axios');
const data =   {
    "preSegment": "demo_uoiuqwehflkipahgoqq",
    "deviceData": {
        "platform": "android",
        "build": "0.0.01"
    },
    "deviceTag": "o1vd1oc0nw8",
    "referral": "BBQFCHQXN"
  };
const config = {
  method: 'POST',
  url: '${AMPLIFI_BASE_URL}/prospect/registration',
  headers: {
    'Content-Type': "application/json",
    'token': "A long random string token received from /token request"
  },
  data
};

let result;
try {
  result = await axios.request(config);
  if (result.status === 200) {
    console.log(JSON.stringify(result.data));
  }
} catch (err) {
  console.log({
    errCode: err.code,
    responseStatus: err.response && err.response.status,
    data: err.response && JSON.stringify(err.response.data)
  });
}

cURL

curl --location "AMPLIFI_BASE_URL/prospect/registration" --data "  {    \"preSegment\":\"demo_uoiuqwehflkipahgoqq\",   \"deviceData\":{        \"platform\":\"android\",       \"build\":\"0.0.01\"    },   \"deviceTag\":\"o1vd1oc0nw8\",   \"referral\":\"BBQFCHQXN\"  }" --header "Content-Type: application/json" --header "token: A long random string token received from /token request" 

Successful Response Examples

200 PROSPECT/REGISTRATION SUCCESSFUL RESPONSE FOR REGISTERING A DEVICE

HEADERS

Header Value
Content-Type application/json
token A long random string token received from /token request

REQUEST BODY

  {
    "preSegment": "demo_uoiuqwehflkipahgoqq",
    "deviceData": {
        "platform": "android",
        "build": "0.0.01"
    },
    "deviceTag": "o1vd1oc0nw8",
    "referral": "BBQFCHQXN"
  }

RESPONSE BODY

{
    "success": true,
    "segment": "standby",
    "serverSecret": "iaegegmmwuubndyehasfgflqokkfhqrjpugufablfvtywrenngoncncwviqbfuqocbatozmvluljrlbujezkyjybykgaabxtrospzlcrqcjqlrurldawrvoutvdvzjff"
}