User Registration API

This document is a standard that we recommend our partners to follow. The unique custom information to be provided is below, although we do request that partners also specify their expected payload in their documentation:

  • <test_api_url>: to start the test of the partner API against a sandbox environment
  • <production_auth_api_url>: to use whenever the integration is ready
  • <production_registration_api_url>
  • <partner_api_key>: to request an access token

Environment Configuration

EnvironmentTestingProduction
Hosthttps://<test_api_url>https://<production_api_url>

Registration Process

The registration flow occurs in two phrases:

  • Get an access token using an API Key to authorize the request
  • Register a user with the generated access token

Get an Access Token

First, Wellhub needs to obtain the access_token to be able to call the Partner's User Registration endpoint.

Request

ParamTypeRequiredTypeExampleDescription
x-api-keyHeaderrequiredstringarfjJbfh...Wellhub's API Key
content-type*Headerrequiredstringapplication/jsonSupported content type

* Supported content types: application/json

Example
1GET https:​//<production_auth_api_url>
2HEADER
3X-Api-Key: <partner_api_key>
4Content-Type: application/json

Response

ParamTypeRequiredTypeExampleDescription
access_tokenBodyrequiredstringeyJhbGciO...Access Token to be used in the user registration call
token_type*BodyrequiredstringBearerToken type
expires_atBodyrequiredInt1571536335Expired at timestamp in SECONDS

* Supported token types: Bearer

Example
1200
2HEADER
3 Content-Type: application/json
4BODY
5{
6 "access_token": "eyJhbGciO...",
7 "token_type": "Bearer",
8 "expires_at": 1571536335
9}

Errors

Example
1403 Forbidden. Missing API key or wrong API key
2500 Internal Server Error

Register a User

Using the access_token from the previous step, it is possible to make a request to the User Registration service.

The response time to this request should not exceed 3000ms as this will result in an error for the Wellhub user.

Request

Body paramRequiredTypeExampleDescription
gympass_user_idrequiredstringgpw-29caecdf-2d5e-40b8-82b4-d0a044fa4679Wellhub Wellness User ID that will be used as a reference to link the user in both Partner and Wellness side. Also, this id will be used to send the usage data.
emailnot recommended*stringjohn@doe.comEmail in Wellhub
first_namenot recommended*stringJohnFirst name in Wellhub
last_namenot recommended*stringDoeLast name in Wellhub
originoptionalstringweb,android, iosOS of device used by user
user_statusoptional/required**string1: basic, 2: premium...User status based on Wellhub plan
country_codeoptional/requiredstringGBLocation of the user

* Ideally no PII should be shared via API, only the gympass_user_id (gpw_id). Users should then input their own personal information upon completing registration.

** user_status is an optional param for partners with a single offer, however, it is required for partners with a multi-offer

Important: When configuring the Authorization token it is important that you include " Bearer" before the access_token

Example
1POST https://<production_registration_api_url>
2HEADER
3 Authorization​: Bearer <access_token>
4 Content-Type: application/json
5BODY
6{
7 "gympass_user_id": "gpw-29caecdf-2d5e-40b8-82b4-d0a044fa4679",
8 "email": "user@example.com",
9 "origin": "ios",
10 "user_status": "1",
11 "country_code": "GB"
12}

Response

Example
1200
2HEADER
3 Content-Type: application/json
4BODY
5{
6"redirect_link": "https://<partner_url>/path/to/signup/form"
7}

Note: This redirect_link should allow to pre-fill the user data (email, first name, last name) once the user is redirected to the registration form. The redirect_link should follow the highest level of security practices in its format, for ex. https instead of http in the URL

If the user already exists, return 200 with the login page as redirect_link.

Errors

Example
1401 Unauthorized Request. Missing or wrong access token
2500 Internal Server Error

Attention: Always ensure that the TCP connection idle time is configured with a duration exceeding 300 seconds. Failing to do so may result in unexpected issues, such as one end abruptly closing the connection without notifying the peer, leading to errors characterized by a "connection reset by the peer" nature.