Set Goal
PUT
/users/{user_id}/goals/{slug}
const url = 'https://example.com/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/goals/example';const options = { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: '{"active":true,"direction":"example","target":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://example.com/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/goals/example \ --header 'Content-Type: application/json' \ --data '{ "active": true, "direction": "example", "target": 1 }'Upsert one metric’s standing daily goal (target + direction + active).
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”user_id
required
User Id
string format: uuid
slug
required
Slug
string
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
MetricGoalUpdate
Upsert one metric’s goal. target must be positive; direction from the fixed set.
object
active
Active
boolean
direction
required
Direction
string
target
required
Target
number
Responses
Section titled “Responses”Successful Response
Media typeapplication/json
GoalMetricRead
One goalable metric as the goals UI needs it. When target is None the metric has no goal
yet (a candidate the editor can offer); otherwise it’s the user’s active/paused goal. The live
actual is read on the client from the day summary (value_field, or metrics[slug] when
that’s null) — never here.
object
Examplegenerated
{ "active": true, "category": "example", "direction": "example", "is_set": true, "label": "example", "slug": "example", "target": 1, "unit": "example", "value_field": "example"}Validation Error
Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ]}