Skip to content

API Reference

Protocol Buffer

Body2Fit relies on the Protocol buffer format to express the schema of the request and response payloads used in its API. For more information about converting protocol buffers to JSON object, please refer to the official documentation.

Garment Support

Get the support status for a specific garment/product by posting the $REQUEST JSON payload.

curl -X post 'https://fitfinder.body2fit.bodygram.com/v2/CreateSession' \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-d $REQUEST
// Request schema for the CreateSession API.
message CreateSessionRequest {
  // Client key provided by Bodygram.
  string client_key = 1;

  message ProductInfo {
    oneof product_info {
      // Product ID of the garment to recommend size for.
      ProductId product_id = 1;
    }
  }
  ProductInfo product_info = 2;

  // Client's own id for identifying a user.
  string client_session_id = 3;
}

message ProductId {
  // Brand ID. Agreed with the client to be provided.
  string brand_id = 1;

  // Garment ID used by the client to identify the product.
  string garment_sku = 2;
}
{
    "clientKey": "MY_CLIENT_KEY",
    "productInfo": {
        "productId": {
            "brandId": "MY_BRAND",
            "garmentSku": "MY_PRODUCT_SKU"
        },
    },
    "clientSessionId": "MY_CUSTOMER_ID"
}

Successful requests will receive an HTTP 200 status code with an instance of the following response payload.

// Response schema for the CreateSession API.
message CreateSessionResponse {
  // Support describes whether the level of support for the garment.
  message Support {
    // Product ID of the garment.
    ProductId product_id = 1;

    // Level of support for the garment.
    enum SupportStatus {
      SUPPORT_STATUS_UNSPECIFIED = 0;
      UNSUPPORTED = 1;
      SUPPORTED = 2;
    }
    SupportStatus supported = 2;

    // Created session id.
    string session_id = 3;
  }

  message Error {
    // List of potential error types.
    enum ErrorType {
      ERROR_TYPE_UNSPECIFIED = 0;
      INTERNAL_ERROR = 1;
      INVALID_CLIENT_KEY = 2;
      INVALID_PRODUCT_ID = 3;
      MALFORMED_REQUEST = 4;
    }
    ErrorType error_type = 1;

    // Human readable error message. 
    //
    // IMPORTANT: This message is only provided for debugging purposes and
    // should not be considered to be part of the API.
    string message = 2;
  }

  oneof body {
    Support support = 1;
    Error error = 2;
  }
}

message ProductId {
  // Brand ID. Agreed with the client to be provided.
  string brand_id = 1;

  // Garment ID used by the client to identify the product.
  string garment_sku = 2;
}
{
    "support": {
        "productId": {
            "brandId": "MY_BRAND",
            "garmentSku": "MY_PRODUCT_SKU"
        },
        "supported": "SUPPORTED",
        "sessionId": "2to2qt5r3ort438orb38r4t3w8t3wvo4vrtw3"
    }
}
{
    "error": {
        "error_type": "INVALID_PRODUCT_ID",
        "message": "Invalid product ID: missing product SKU."
    }
}

Get the recommended size for a specific garment/product by posting the $REQUEST JSON payload.

curl -X post 'https://fitfinder.body2fit.bodygram.com/v2/GetRecommendedSize' \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-d $REQUEST
// Request schema for the GetRecommendedSize API.
message GetRecommendedSizeRequest {
  // Client key provided by Bodygram.
  string client_key = 1;

  // A token that can be reused for future size recommendations 
  // without the need for providing measurements again.
  EstimationToken estimation_token = 2;

  message ProductInfo {
    oneof product_info {
      // Product ID of the garment to recommend size for.
      ProductId product_id = 1;
    }
  }
  ProductInfo product_info = 3;
}

message EstimationToken {
  // Token obtained from a previous size recommendation.
  string token = 1;
}
{
    "clientKey": "MY_CLIENT_KEY",
    "estimation_token": {
        "token": "USER_ESTIMATION_TOKEN"
    },
    "productInfo": {
        "productId": {
            "brandId": "MY_BRAND",
            "garmentSku": "MY_PRODUCT_SKU"
        },
    }
}

Successful requests will receive an HTTP 200 status code with an instance of the following response payload.

// Response schema for the GetGarmentSupport API.
message GetRecommendedSizeResponse {
  message Recommendation {
    // Recommended size (XXS, S, M etc.).
    string recommended_size = 1;
  }

  message Error {
    // List of potential error types.
    enum ErrorType {
      ERROR_TYPE_UNSPECIFIED = 0;
      INTERNAL_ERROR = 1;
      INVALID_CLIENT_KEY = 2;
      INVALID_ESTIMATION_TOKEN = 3;
      INVALID_PRODUCT_ID = 4;
      PRODUCT_NOT_FOUND = 5;
      MALFORMED_REQUEST = 6;
    }
    ErrorType error_type = 1;

    // Human readable error message.
    //
    // IMPORTANT: This message is only provided for debugging purposes and
    // should not be considered to be part of the API.
    string message = 2;
  }

  oneof body {
    Recommendation recommendation = 1;
    Error error = 2;
  }
}
{
    "recommendation": {
        "recommended_size": "M"
    }
}
{
    "error": {
        "error_type": "INVALID_PRODUCT_ID",
        "message": "Invalid product ID: missing product SKU."
    }
}