Set the nutrition goal

Set or clear the diner's nutrition goal per meal; the AI waiter checks dishes against it using the restaurant's own figures.

PUT/api/v1/goalClient API

Per meal: kcal is a ceiling when cutting or maintaining and a floor when bulking; proteinGrams is always a floor. A mode with no number checks nothing until the diner gives one. null clears the goal. A guest's or a test key's session answers identity_required.

Per meal: kcal is a ceiling when cutting or maintaining and a floor when bulking, proteinGrams always a floor. A mode with no number checks nothing until the diner gives one. null clears it. A guest's session gets identity_required.

Authentication

Client API. Send your publishable key in x-tamr-key and the diner's session in x-tamr-session, from Start a session. For a guest's session, also send its device id in x-tamr-device. A browser may call it only from an origin listed on the key.

Headers

NameTypeRequiredDescription
x-tamr-devicestringNoGuest sessions only: the device id the session was exchanged with. Matches ^[A-Za-z0-9_-]{8,128}$.
x-tamr-appstringNoNative apps only: the app's iOS bundle id or Android package name. A key used from an app it doesn't list is logged, never refused. Matches ^[A-Za-z][A-Za-z0-9_-]*(\.[A-Za-z0-9_-]+)+$.

Request body

FieldTypeRequiredDescription
goalobject or nullYes
goal.modestringYesOne of cutting, maintain, bulking.
goal.kcalintegerNoCalories for one meal: a ceiling when cutting or maintaining, a floor when bulking. 100 to 3,000.
goal.proteinGramsintegerNoGrams of protein for one meal, always a floor. 5 to 300.

Response

FieldTypeDescription
goalobject or null
goal.modestringOne of cutting, maintain, bulking, other. An open list: read a value you don't know as other.
goal.kcalintegerMay be absent. Calories for one meal: a ceiling when cutting or maintaining, a floor when bulking. 100 to 3,000.
goal.proteinGramsintegerMay be absent. Grams of protein for one meal, always a floor. 5 to 300.
canSetboolean

Example

curl -X PUT https://tamr.link/api/v1/goal \
  -H "x-tamr-key: $TAMR_APP_KEY" \
  -H "x-tamr-session: $TAMR_SESSION" \
  -H "content-type: application/json" \
  -d '{
  "goal": {
    "mode": "maintain",
    "kcal": 900
  }
}'

Example response

{
  "goal": {
    "mode": "cutting",
    "kcal": 600
  },
  "canSet": true
}

Errors

Every error has the same body; switch on data.code. See Errors and rate limits.

data.codeStatusWhat to do
app_key_invalid401The key is wrong, revoked or of another kind. Check it in the dashboard.
sdk_disabled403The SDK isn't switched on for this restaurant. Ask Tamr.
origin_not_allowed403A browser called from an origin the key doesn't list. Add the origin to the key.
session_expired401Start a new session with a fresh token or code, then send the call again once.
invalid_request400A field doesn't match the spec. The message says which.
rate_limited429Wait retryAfter seconds (also in the Retry-After header), then try again.
identity_required401Only a signed-in diner's goal is kept. A guest's or a test key's session can't set one. Don't renew the session for it.