Skip to main content

user.created

Overview

When a participant associated with your group initiates a check-in through Okaya, there are two potential scenarios:

  1. First-time Connection: If this is the participant's first interaction via your group and you have not yet received an Okaya personalized ID for this user, you should provide us with the participant's email address. We will take it from there, creating an account and associating it with an external ID.

  2. Subsequent Interactions: For any future check-ins, simply forward us the external ID to access this participant's information.

Webhook Cycle for New User Creation

Upon receiving your URL forward request, we perform a search within our platform. If the user is not found or is not yet associated with your group, we will proceed to create an account for them in a seamless, behind-the-scenes process, ensuring immediate integration.

Webhook Payload

When a new user is created, a webhook will POST a JSON payload to the HTTPS endpoint you've configured in your admin dashboard or via API. The payload is structured as follows:

{
"id": "evt_ef5096988221f70dee7bde5a6cf1723ea86e10afdf81a2c7",
"object": "event",
"type": "user.created",
"data": {
"object": {
"groupID": 38000,
"userIdentifier": "ok_bb9efc4535f074482691455b975ac26f24cd9700250648e1",
"email": "theOriginalEmailYouSentUs"
}
}
}

Note: Our external IDs always begin with ok\_.

Important Considerations:

In creating users, we assume that you have communicated Okaya's terms of service and privacy policy to the end user. If you have not, or cannot manage consent in a manner compliant with HIPAA and/or GDPR regulations, please reach out to us. We can ensure that participants are presented with appropriate opt-in options.

Privacy Settings

By default, all participants are anonymized within Okaya. We return only anonymized data to group managers. However, if your participants have consented through your platform, or if you prefer that we manage the consent process, we can enable "share mode" for these users. This mode allows their data to be transferred to a professional account, ensuring both privacy and compliance are maintained.

Handling the Webhook On Your End

When you receive our call, please respond with a 200 so we can update our logs accordingly. We will also record error codes. Here is an example of how you could parse the response and update your user information table in your database.

export default async function handler(req, res) {
if (req.method === "POST") {
const { id, object, type, data } = req.body;

const groupID = data.object.groupID;
const userIdentifier = data.object.userIdentifier;

console.log("Event ID:", id);
console.log("Object:", object);
console.log("Event Type:", type);
console.log("Group ID:", groupID);
console.log("User Identifier:", userIdentifier);

try {
await saveUserIdentifierToDatabase(userIdentifier);
res
.status(200)
.json({ status: "success", message: "User identifier saved" });
} catch (error) {
console.error("Error saving user identifier to database:", error);
res
.status(500)
.json({ status: "error", message: "Failed to save user identifier" });
}
} else {
res.setHeader("Allow", ["POST"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}

async function saveUserIdentifierToDatabase(userIdentifier) {
console.log(`Saving userIdentifier: ${userIdentifier} to the database.`);
}