Skip to content

Avatar

Retrieving or managing a trainer’s profile avatar within the Glofox platform involves two main operations: fetching the current avatar and uploading a new one. The sections below outline both processes.

GET avatar

Retrieve the image_url for a trainer profile.

  • Endpoint: https://cdn.glofox.com/{ENVIRONMENT}/{NAMESPACE}/branches/{branchId}/trainers/{userId}/default.png
  • Method: GET
  • Content-Type: application/json

Where you have the following variables:

Field Description
ENVIRONMENT Specifies the environment context. Use platform.
NAMESPACE Represents the namespace associated with the branch. For the production branch under test, the namespace can be obtained from the response of https://app.glofox.com/2.0/clients?bundle=_bundle, which is typically called during login or registration.
branchId The unique identifier of the branch to which the trainer is assigned.
userId The unique identifier assigned to the user.

POST upload an avatar

Upload a user's profile avatar.

  • Endpoint: https://app.glofox.com/assets/upload/users/62264815aa26217ba57a43f5/profile
  • Method: POST
  • Content-Type: application/json

Required Headers

{
  "x-glofox-branch-id": "{branch_id}",
  "x-api-key": "{api_key}",
  "x-glofox-api-token": "{api_token}"
}

Request Body

Form data: `Image=@"{local-path-to-image}"`

The base URL for this request differs from other API requests due to a current system limitation. Only this specific request should use the provided base URL.

How to deal with missing images and 403 responses

The image_url field in trainer objects is generated using a fixed URL pattern, which means it may be present even when no actual image has been uploaded for that user. If the referenced object does not exist in storage, attempting to fetch it will result in an HTTP 403 Forbidden response rather than a 404 Not Found.

As an integrator, you should assume that image_url might reference a non-existent image. Treat it as a possible avatar URL, not a guarantee that an image is available.

403 responses

When retrieving the URL, handle 403 Forbidden responses gracefully. Fallback to a local or CDN-hosted placeholder image, and avoid showing technical errors to end users.

If you want greater certainty that the image exists before trying to load it, consider the following approaches (each one with trade-offs):

Option What it Does Trade-off
HEAD request Check whether the image exists by sending an HTTP HEAD request to the avatar URL. Adds extra network overhead and increases latency.
Backfill metadata Reconcile storage data once to determine whether each image actually exists. Requires operational effort and ongoing maintenance.