> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trophy.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Goals

> Learn how to tell Trophy about the goals your users are working towards, from deadlines and exams to study plans and metric targets.

## What are goals?

A goal is something one user is working towards: an essay due on Friday, an exam on November 20, or 50 lessons this month. You tell Trophy about each user's goals through the [Application API](https://docs.trophy.so/api-reference/endpoints/users/create-a-goal-for-a-user.md), and [agentic messaging](https://docs.trophy.so/agentic-messaging/overview.md) uses them to remind users before a goal is due, encourage them when they miss one and celebrate the ones they complete.

Goals belong to a single user. Each one has a `key` that you choose, unique for that user, which you use to update or delete it. The user must already exist in Trophy, so [identify the user](https://docs.trophy.so/data-sources/users.md) before creating their goals.

## Key attributes

**key** `string` *required*

The goal's key, unique per user. 1–100 letters, numbers, hyphens or
underscores. `plural` and `singular` are reserved.

**label** `string`

What the goal is, up to 200 characters. Messages name the goal by its label,
so write it the way you'd want it to read in a message, for example "Spanish
B1 exam".

**completion** `string` (default: manual)

How the goal is completed: `manual`, `none` or `metric`. See [completion
types](#completion-types).

**dueAt** `string`

When the goal is due, as an ISO 8601 date and time. A time without an offset,
like `2026-11-20T09:00:00`, is in the user's time zone, so set the user's
[`tz`](https://docs.trophy.so/data-sources/users#optional-attributes). Required for goals with
`completion: none`.

**completed** `boolean` (default: false)

Whether the user has completed the goal. Only for goals with `completion:
    manual`.

**metric** `string`

Goals with `completion: metric` only. The key of the [metric](https://docs.trophy.so/data-sources/metrics.md)
that counts towards the goal.

**target** `number`

Goals with `completion: metric` only. The metric total that completes the
goal. Must be greater than 0.

**start** `string`

Goals with `completion: metric` only. The date, as `YYYY-MM-DD` in the user's
time zone, that the metric total counts from. Defaults to the user's today.

**steps** `array`

The goal's [steps](#steps), in order, up to 100.

## Completion types

A goal's `completion` says how it's completed.

| `completion` | Completed | For example |
| - | - | - |
| `manual` | When you mark it completed | An essay due on Friday |
| `none` | Never. It's a date the user works towards | An exam on November 20 |
| `metric` | Automatically, when a metric's total since `start` reaches `target` | 50 lessons by November 20 |

### Manual goals

Manual goals are for things the user finishes in your app, like submitting an essay. Mark the goal completed with `completed: true` when they do, and set `completed: false` to undo it.

### Dates to work towards

Goals with `completion: none` are dates the user prepares for, like an exam or a race. There's nothing to mark as done, so they need a `dueAt` and are never completed. Messages about them help the user prepare, rather than urging them to finish.

### Metric goals

Metric goals complete themselves. Each goal counts the user's total for its `metric` from `start` onwards, and Trophy marks it completed as soon as an [event](https://docs.trophy.so/data-sources/events.md) brings that total to the `target`.

Changing a metric goal's `metric`, `target` or `start` checks it against its target again, which can complete it or, if the new total falls short, uncomplete it. Metric goals can't be marked completed with `completed`.

## Steps

A goal can have steps, which turns it into a plan. For example, a study plan for an exam might have a step for each unit, each with its own due time.

Steps are one level deep and each one is a goal in its own right. A step has its own `key`, unique among all of the user's goals, and its own `label`, `completion`, `dueAt` and metric. You update, complete and delete a step through its own key, just like any other goal.

A goal with steps also tracks how many of them are completed, which messages use to show the user's progress through the plan.

## Status

Each goal has a `status`, which Trophy works out from the goal whenever you retrieve it:

| `status` | When |
| - | - |
| `active` | The goal isn't completed and isn't due yet, or has no due time |
| `completed` | The goal is completed, even if that was after it was due |
| `missed` | A `manual` or `metric` goal's due time has passed without it being completed |
| `ended` | A `none` goal's due time has passed |

## Managing goals

### Creating goals

Create a goal with the [create goal](https://docs.trophy.so/api-reference/endpoints/users/create-a-goal-for-a-user.md) endpoint. Here's a goal for an exam the user is preparing for:

```bash cURL theme={null}
curl -X POST https://api.trophy.so/v1/users/user-123/goals \
     -H "X-API-KEY: <api-key>" \
     -H "Content-Type: application/json" \
     -d '{
  "key": "spanish-exam",
  "label": "Spanish B1 exam",
  "completion": "none",
  "dueAt": "2026-11-20T09:00:00Z"
}'
```

```typescript Node theme={null}
trophy.users.createGoal("user-123", {
  key: "spanish-exam",
  label: "Spanish B1 exam",
  completion: "none",
  dueAt: "2026-11-20T09:00:00Z",
});
```

```python Python theme={null}
client.users.create_goal(
    id="user-123",
    key="spanish-exam",
    label="Spanish B1 exam",
    completion="none",
    due_at="2026-11-20T09:00:00Z",
)
```

```php PHP theme={null}
$request = new CreateGoalRequest([
    'key' => 'spanish-exam',
    'label' => 'Spanish B1 exam',
    'completion' => GoalCompletion::None->value,
    'dueAt' => '2026-11-20T09:00:00Z'
]);

$trophy->users->createGoal("user-123", $request);
```

```java Java theme={null}
CreateGoalRequest request = CreateGoalRequest.builder()
      .key("spanish-exam")
      .label("Spanish B1 exam")
      .completion(GoalCompletion.NONE)
      .dueAt("2026-11-20T09:00:00Z")
      .build();

GoalResponse response = client.users().createGoal("user-123", request);
```

```go Go theme={null}
response, err := client.Users.CreateGoal(
    context.TODO(),
    "user-123",
    &api.CreateGoalRequest{
        Key:        "spanish-exam",
        Label:      api.String("Spanish B1 exam"),
        Completion: api.GoalCompletionNone.Ptr(),
        DueAt:      api.String("2026-11-20T09:00:00Z"),
    },
)
```

```csharp C# theme={null}
var request = new CreateGoalRequest {
   Key = "spanish-exam",
   Label = "Spanish B1 exam",
   Completion = GoalCompletion.None,
   DueAt = "2026-11-20T09:00:00Z"
};

await trophy.Users.CreateGoalAsync("user-123", request);
```

```ruby Ruby theme={null}
result = client.users.create_goal(
  :id => 'user-123',
  :key => 'spanish-exam',
  :label => 'Spanish B1 exam',
  :completion => 'none',
  :due_at => '2026-11-20T09:00:00Z'
)
```

A request with a key the user already has, for a goal or a step, fails with a `409`.

### Creating a plan

Pass `steps` to create a goal and its steps in one request:

```bash cURL theme={null}
curl -X POST https://api.trophy.so/v1/users/user-123/goals \
     -H "X-API-KEY: <api-key>" \
     -H "Content-Type: application/json" \
     -d '{
  "key": "spanish-exam",
  "label": "Spanish B1 exam",
  "completion": "none",
  "dueAt": "2026-11-20T09:00:00Z",
  "steps": [
    {
      "key": "unit-1",
      "label": "Unit 1 vocabulary",
      "dueAt": "2026-11-10T09:00:00Z"
    },
    {
      "key": "unit-2",
      "label": "Unit 2 grammar",
      "dueAt": "2026-11-14T09:00:00Z"
    }
  ]
}'
```

```typescript Node theme={null}
trophy.users.createGoal("user-123", {
  key: "spanish-exam",
  label: "Spanish B1 exam",
  completion: "none",
  dueAt: "2026-11-20T09:00:00Z",
  steps: [
    {
      key: "unit-1",
      label: "Unit 1 vocabulary",
      dueAt: "2026-11-10T09:00:00Z",
    },
    {
      key: "unit-2",
      label: "Unit 2 grammar",
      dueAt: "2026-11-14T09:00:00Z",
    },
  ],
});
```

```python Python theme={null}
from trophy import GoalStepRequest

client.users.create_goal(
    id="user-123",
    key="spanish-exam",
    label="Spanish B1 exam",
    completion="none",
    due_at="2026-11-20T09:00:00Z",
    steps=[
        GoalStepRequest(
            key="unit-1",
            label="Unit 1 vocabulary",
            due_at="2026-11-10T09:00:00Z",
        ),
        GoalStepRequest(
            key="unit-2",
            label="Unit 2 grammar",
            due_at="2026-11-14T09:00:00Z",
        ),
    ],
)
```

```php PHP theme={null}
$request = new CreateGoalRequest([
    'key' => 'spanish-exam',
    'label' => 'Spanish B1 exam',
    'completion' => GoalCompletion::None->value,
    'dueAt' => '2026-11-20T09:00:00Z',
    'steps' => [
        new GoalStepRequest([
            'key' => 'unit-1',
            'label' => 'Unit 1 vocabulary',
            'dueAt' => '2026-11-10T09:00:00Z'
        ]),
        new GoalStepRequest([
            'key' => 'unit-2',
            'label' => 'Unit 2 grammar',
            'dueAt' => '2026-11-14T09:00:00Z'
        ])
    ]
]);

$trophy->users->createGoal("user-123", $request);
```

```java Java theme={null}
CreateGoalRequest request = CreateGoalRequest.builder()
      .key("spanish-exam")
      .label("Spanish B1 exam")
      .completion(GoalCompletion.NONE)
      .dueAt("2026-11-20T09:00:00Z")
      .steps(List.of(
        GoalStepRequest.builder()
          .key("unit-1")
          .label("Unit 1 vocabulary")
          .dueAt("2026-11-10T09:00:00Z")
          .build(),
        GoalStepRequest.builder()
          .key("unit-2")
          .label("Unit 2 grammar")
          .dueAt("2026-11-14T09:00:00Z")
          .build()
      ))
      .build();

GoalResponse response = client.users().createGoal("user-123", request);
```

```go Go theme={null}
response, err := client.Users.CreateGoal(
    context.TODO(),
    "user-123",
    &api.CreateGoalRequest{
        Key:        "spanish-exam",
        Label:      api.String("Spanish B1 exam"),
        Completion: api.GoalCompletionNone.Ptr(),
        DueAt:      api.String("2026-11-20T09:00:00Z"),
        Steps: []*api.GoalStepRequest{
            {
                Key:   "unit-1",
                Label: api.String("Unit 1 vocabulary"),
                DueAt: api.String("2026-11-10T09:00:00Z"),
            },
            {
                Key:   "unit-2",
                Label: api.String("Unit 2 grammar"),
                DueAt: api.String("2026-11-14T09:00:00Z"),
            },
        },
    },
)
```

```csharp C# theme={null}
var request = new CreateGoalRequest {
   Key = "spanish-exam",
   Label = "Spanish B1 exam",
   Completion = GoalCompletion.None,
   DueAt = "2026-11-20T09:00:00Z",
   Steps = new[] {
      new GoalStepRequest {
         Key = "unit-1",
         Label = "Unit 1 vocabulary",
         DueAt = "2026-11-10T09:00:00Z"
      },
      new GoalStepRequest {
         Key = "unit-2",
         Label = "Unit 2 grammar",
         DueAt = "2026-11-14T09:00:00Z"
      }
   }
};

await trophy.Users.CreateGoalAsync("user-123", request);
```

```ruby Ruby theme={null}
result = client.users.create_goal(
  :id => 'user-123',
  :key => 'spanish-exam',
  :label => 'Spanish B1 exam',
  :completion => 'none',
  :due_at => '2026-11-20T09:00:00Z',
  :steps => [
    {
      :key => 'unit-1',
      :label => 'Unit 1 vocabulary',
      :due_at => '2026-11-10T09:00:00Z'
    },
    {
      :key => 'unit-2',
      :label => 'Unit 2 grammar',
      :due_at => '2026-11-14T09:00:00Z'
    }
  ]
)
```

To add a single step to the end of an existing goal's steps, create it with the goal's key as its `parent`:

```bash cURL theme={null}
curl -X POST https://api.trophy.so/v1/users/user-123/goals \
     -H "X-API-KEY: <api-key>" \
     -H "Content-Type: application/json" \
     -d '{
  "key": "unit-3",
  "parent": "spanish-exam",
  "label": "Unit 3 listening",
  "dueAt": "2026-11-17T09:00:00Z"
}'
```

```typescript Node theme={null}
trophy.users.createGoal("user-123", {
  key: "unit-3",
  parent: "spanish-exam",
  label: "Unit 3 listening",
  dueAt: "2026-11-17T09:00:00Z",
});
```

```python Python theme={null}
client.users.create_goal(
    id="user-123",
    key="unit-3",
    parent="spanish-exam",
    label="Unit 3 listening",
    due_at="2026-11-17T09:00:00Z",
)
```

```php PHP theme={null}
$request = new CreateGoalRequest([
    'key' => 'unit-3',
    'parent' => 'spanish-exam',
    'label' => 'Unit 3 listening',
    'dueAt' => '2026-11-17T09:00:00Z'
]);

$trophy->users->createGoal("user-123", $request);
```

```java Java theme={null}
CreateGoalRequest request = CreateGoalRequest.builder()
      .key("unit-3")
      .parent("spanish-exam")
      .label("Unit 3 listening")
      .dueAt("2026-11-17T09:00:00Z")
      .build();

GoalResponse response = client.users().createGoal("user-123", request);
```

```go Go theme={null}
response, err := client.Users.CreateGoal(
    context.TODO(),
    "user-123",
    &api.CreateGoalRequest{
        Key:    "unit-3",
        Parent: api.String("spanish-exam"),
        Label:  api.String("Unit 3 listening"),
        DueAt:  api.String("2026-11-17T09:00:00Z"),
    },
)
```

```csharp C# theme={null}
var request = new CreateGoalRequest {
   Key = "unit-3",
   Parent = "spanish-exam",
   Label = "Unit 3 listening",
   DueAt = "2026-11-17T09:00:00Z"
};

await trophy.Users.CreateGoalAsync("user-123", request);
```

```ruby Ruby theme={null}
result = client.users.create_goal(
  :id => 'user-123',
  :key => 'unit-3',
  :parent => 'spanish-exam',
  :label => 'Unit 3 listening',
  :due_at => '2026-11-17T09:00:00Z'
)
```

A goal can have up to 100 steps, and steps can't have steps of their own.

### Updating goals

Update a goal or a step with the [update goal](https://docs.trophy.so/api-reference/endpoints/users/update-a-goal-for-a-user.md) endpoint. Fields you leave out stay as they are, and `null` clears a `label` or `dueAt`. Here's a goal being marked completed:

```bash cURL theme={null}
curl -X PATCH https://api.trophy.so/v1/users/user-123/goals/first-essay \
     -H "X-API-KEY: <api-key>" \
     -H "Content-Type: application/json" \
     -d '{
  "completed": true
}'
```

```typescript Node theme={null}
trophy.users.updateGoal("user-123", "first-essay", {
  completed: true,
});
```

```python Python theme={null}
client.users.update_goal(
    id="user-123",
    key="first-essay",
    completed=True,
)
```

```php PHP theme={null}
$request = new UpdateGoalRequest([
    'completed' => true
]);

$trophy->users->updateGoal("user-123", "first-essay", $request);
```

```java Java theme={null}
UpdateGoalRequest request = UpdateGoalRequest.builder()
      .completed(true)
      .build();

GoalResponse response = client.users().updateGoal("user-123", "first-essay", request);
```

```go Go theme={null}
response, err := client.Users.UpdateGoal(
    context.TODO(),
    "user-123",
    "first-essay",
    &api.UpdateGoalRequest{
        Completed: api.Bool(true),
    },
)
```

```csharp C# theme={null}
var request = new UpdateGoalRequest {
   Completed = true
};

await trophy.Users.UpdateGoalAsync("user-123", "first-essay", request);
```

```ruby Ruby theme={null}
result = client.users.update_goal(
  :id => 'user-123',
  :key => 'first-essay',
  :completed => true
)
```

Passing `steps` replaces all of the goal's steps, in the order given: steps whose key the goal already has are updated, new keys are added, and steps you leave out are deleted. Use it to reorder or rebuild a plan, and the `parent` field on [create](#creating-a-plan) to add one step at a time.

```json Replace a goal's steps theme={null}
{
  "steps": [
    { "key": "unit-1" },
    { "key": "unit-2", "dueAt": "2026-11-15T09:00:00Z" },
    { "key": "unit-3", "label": "Unit 3 listening" }
  ]
}
```

### Deleting goals

Delete a goal or a step with the [delete goal](https://docs.trophy.so/api-reference/endpoints/users/delete-a-users-goal.md) endpoint. Deleting a goal deletes its steps too. Once it's deleted, its key is free to use for a new goal.

### Retrieving goals

The [user goals](https://docs.trophy.so/api-reference/endpoints/users/get-a-users-goals.md) endpoint returns all of a user's goals, soonest due first and then those with no due time. Each goal includes its `status` and its steps, a goal with steps adds `done` and `total`, and a metric goal adds its `metric`, `target`, `start` and `current` total:

```json Response [expandable] theme={null}
[
  {
    "key": "first-essay",
    "label": "First essay",
    "completion": "manual",
    "dueAt": "2026-11-12T17:00:00.000Z",
    "completedAt": "2026-11-12T14:21:08.000Z",
    "status": "completed"
  },
  {
    "key": "spanish-exam",
    "label": "Spanish B1 exam",
    "completion": "none",
    "dueAt": "2026-11-20T09:00:00.000Z",
    "completedAt": null,
    "status": "active",
    "steps": [
      {
        "key": "unit-1",
        "label": "Unit 1 vocabulary",
        "completion": "manual",
        "dueAt": "2026-11-10T09:00:00.000Z",
        "completedAt": "2026-11-09T19:12:44.000Z",
        "status": "completed"
      },
      {
        "key": "unit-2",
        "label": "Unit 2 grammar",
        "completion": "manual",
        "dueAt": "2026-11-14T09:00:00.000Z",
        "completedAt": null,
        "status": "active"
      }
    ],
    "done": 1,
    "total": 2
  },
  {
    "key": "lessons",
    "label": "50 lessons",
    "completion": "metric",
    "dueAt": null,
    "completedAt": null,
    "status": "active",
    "metric": "lessons",
    "target": 50,
    "start": "2026-11-01",
    "current": 30
  }
]
```

## How agents use goals

Agents read each user's goals and decide when a message about one is worth sending, the same way they decide about everything else. Every goal gives them three moments to work with:

* **Before it's due**: agents can remind the user about a goal that isn't completed. Reminders come more often as the due date gets closer, and on the due date a reminder can arrive a few hours before the due time. Goals without a due time can be mentioned while the user is active in your app.
* **When it's missed**: once a `manual` or `metric` goal's due time passes without it being completed, agents can encourage the user to get back on track.
* **When it's completed**: agents can celebrate a completed goal, once per goal.

Messages about a goal include the user's progress: how many steps are done and the next ones up, or how far a metric goal is from its target. Emails can also show the goal's time left, a progress bar and its next steps.

Messages about a goal are written for its completion type. A `manual` or `metric` goal is something to finish, while a `none` goal is a date to prepare for.

Before a scheduled message about a goal sends, Trophy checks that it still applies. A reminder is cancelled if the goal has been completed, its due time or completion type has changed, or its due time has passed. See [send-time checks](https://docs.trophy.so/agentic-messaging/guardrails.md#send-time-checks).

Goals created already completed or past due, or moved to a due time that has already passed, don't get a completion or missed message. That means you can import a user's past goals without sending them messages about them. Steps of a completed goal don't get messages either.

## Frequently asked questions

> [accordion] Do I need to set goals up in the dashboard?
>
> No. Goals are created per user through the API. The only setup is for
> metric goals, whose `metric` must be a [metric](https://docs.trophy.so/data-sources/metrics.md) you've
> already created.

> [accordion] What happens when I move a goal's due time?
>
> Reminders already scheduled for the old due time are cancelled, and agents
> plan around the new one.

> [accordion] Can I reuse a key after deleting a goal?
>
> Yes. A goal created with a deleted goal's key is a new goal, so its
> messages are planned from scratch.

> [accordion] How many goals can a user have?
>
> As many as you like. Each goal can have up to 100 steps.

## Get support

Want to get in touch with the Trophy team? Reach out to us via [email](mailto:support@trophy.so). We're here to help!


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.