Create Food
chevron down
 

Create Food

Creates a new private food for a user.

Scope: nutrition


Request

POST /1/user/[user-id]/foods.json

URI Arguments
user-id required The encoded ID of the user. Use "-" (dash) for current logged-in user.

Query Parameters
name required Name of the food being created.
defaultFoodMeasurementUnitId required ID representing the default measurement unit used. A full list of units can be retrieved using the Get Food Units endpoints.
defaultServingSize required Size of the default serving. Nutritional values should be provided for this serving size.
calories required Number of calories for the default serving size.
formType required The texture of the food.
Supported: LIQUID | DRY
description required Description of the food.

Additional Nutritional Information

Here's a list of additional nutritional query parameter names that can be used with the Create Food endpoint.

Common Vitamins Dietary Minerals
caloriesFromFat, totalFat(g), transFat(g), saturatedFat(g), cholesterol(mg), sodium(mg), potassium(mg), totalCarbohydrate(g), dietaryFiber(g), sugars(g), protein(g) vitaminA(IU), vitaminB6, vitaminB12, vitaminC(mg), vitaminD(IU), vitaminE(IU), biotin(mg), folicAcid(mg), niacin(mg), pantothenicAcid(mg), riboflavin(mg), thiamin(mg) calcium(g), copper(g), iron(mg), magnesium(mg), phosphorus(g), iodine(mcg), zinc(mg)

Note: To track nutritional information not listed here, put the key and value into the additional nutrition section.
Request Headers
authorization required Specify the token type and Fitbit user’s access token.
Token type: Bearer
accept optional The media type of the response content the client is expecting.
Supported: application/json
accept-language optional The measurement unit system to use for response values. See Localization.
accept-locale optional The locale to use for response values. See Localization.
content-length required According to RFC 7230, section 3.3.2, this HTTP request requires the Content-Length header field containing the anticipated size of the payload body.

Examples
POST https://api.fitbit.com/1/user/-/foods.json?name=Lasagna&defaultFoodMeasurementUnitId=309&defaultServingSize=1&calories=200&formType=dry&description=dehydrated%20lasagna
POST https://api.fitbit.com/1/user/GGNJL9/foods.json?name=Lasagna&defaultFoodMeasurementUnitId=309&defaultServingSize=1&calories=200&formType=dry&description=dehydrated%20lasagna
curl -X POST "https://api.fitbit.com/1/user/-/foods.json?name=Lasagna&defaultFoodMeasurementUnitId=309&defaultServingSize=1&calories=200&formType=dry&description=dehydrated%20lasagna" \
-H "accept: application/json" \
-H "authorization: Bearer <access_token>" \
-H "content-length: <message_body_size>"


Response

Element Name Description
food : accessLevel
food : brand
food : calories
food : creatorEncodedId
food : defaultServingSize
food : defaultUnit : id
food : defaultUnit : name
food : defaultUnit : plural
food : foodId
food : isGeneric
food : name
food : nutritionalValues Available nutritional values for the food consumed.
food : servings : multiplier
food : servings : servingSize
food : servings : unit : id
food : servings : unit : name
food : servings : unit : plural
food : servings : unitId
food : units
{
  "food": {
    "accessLevel": "PRIVATE",
    "brand": "",
    "calories": 200,
    "creatorEncodedId": "GGNJL9",
    "defaultServingSize": 1,
    "defaultUnit": {
      "id": 304,
      "name": "serving",
      "plural": "servings"
    },
    "foodId": 753871120,
    "isGeneric": false,
    "name": "Lasagna",
    "nutritionalValues": {
      "biotin": 0,
      "calcium": 0,
      "calories": 200,
      "caloriesFromFat": 0,
      "cholesterol": 0,
      "copper": 0,
      "dietaryFiber": 0,
      "folicAcid": 0,
      "iodine": 0,
      "iron": 0,
      "magnesium": 0,
      "niacin": 0,
      "pantothenicAcid": 0,
      "phosphorus": 0,
      "potassium": 0,
      "protein": 0,
      "riboflavin": 0,
      "saturatedFat": 0,
      "sodium": 0,
      "sugars": 0,
      "thiamin": 0,
      "totalCarbohydrate": 0,
      "totalFat": 0,
      "transFat": 0,
      "vitaminA": 0,
      "vitaminB12": 0,
      "vitaminB6": 0,
      "vitaminC": 0,
      "vitaminD": 0,
      "vitaminE": 0,
      "zinc": 0
    },
    "servings": [
      {
        "multiplier": 1,
        "servingSize": 1,
        "unit": {
          "id": 304,
          "name": "serving",
          "plural": "servings"
        },
        "unitId": 304
      }
    ],
    "units": [
      304
    ]
  }
}
      

Response Headers
content-type The media type of the response content being sent to the client.
Supported: application/json
fitbit-rate-limit-limit The quota number of calls.
fitbit-rate-limit-remaining The number of calls remaining before hitting the rate limit.
fitbit-rate-limit-reset The number of seconds until the rate limit resets.

Note: The rate limit headers are approximate and asynchronously updated. This means that there may be a minor delay in the decrementing of remaining requests. This could result in your application receiving an unexpected 429 response if you don't track the total number of requests you make yourself.

Response Type

HTTP Status Code HTTP response code. List of codes are found in the Troubleshooting Guide.
Status Message Description of the status code.
Response Body Contains the JSON response to the API call. When errors are returned by the API call, the errorType, fieldName and message text will provide more information to the cause of the failure.

Response Codes
201 A successful request.
400 The request had bad syntax or was inherently impossible to be satisfied.
401 The request requires user authentication.

Note: For a complete list of response codes, please refer to the Troubleshooting Guide.

Additional Information

Access Levels

There are 2 access level types for food log entries that an authorized user can view via API requests. Each food is annotated with an accessLevel field with one of the following values:

  • PUBLIC - Foods that are in Fitbit's public food database and are visible to any Fitbit users. Only Fitbit populates this database to avoid spam and duplicate entries.
  • PRIVATE - Foods created by a user either on the website or via the Create Food endpoint.