> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://customerhub.com/api/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://customerhub.com/api/_mcp/server.

# Set Goal

PATCH https://api.customerhub.com/web_api/users/{id}
Content-Type: application/json

Set, replace, or clear the current user's goal. This is **Update User Profile** sending only the `goal` field.

**Authentication:** Required — Bearer token (member). The user is resolved within the current app, so the `id` must belong to a member of this app.

**Path parameters:**
- `id` (required) — The user's ID

**Request body:**
- `goal` (string) — New goal text, trimmed.
  - Same as the current goal → no change.
  - Different value → the previous goal moves to `goal_history` with `status: "replaced"`, then the new goal is set with `goal_updated_at` and `goal_author`.
  - Empty string → the current goal is archived as `replaced` and cleared.

**Side effects:** When a new non-empty goal is set, highlights are extracted in the background into `goal_highlights`.

To mark the goal achieved instead of replacing it, use **Complete Goal**.

**Response:** Updated user profile.

**Errors:**
- `404` — User not found
- `422` — Validation errors

Reference: https://customerhub.com/api/api-reference/goals/set-goal

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `id` (string, required) — User ID

### Body (application/json)

This endpoint expects an object.

- `goal` (string, optional)

## Response

### 200

OK

## Examples

**Request**

```json
{
  "goal": "Launch the new coaching offer by Q4"
}
```

**Response**

```json
{
  "data": {
    "achievements": [],
    "avatar_media_id": null,
    "avatar_url": null,
    "bio": "Community member",
    "cdata": {},
    "cover_image_url": null,
    "created_at": "2026-09-16T15:32:12Z",
    "email": "user@example.com",
    "engagement_score": 0,
    "facebook": null,
    "first_name": "John",
    "goal": "Launch the new coaching offer by Q4",
    "goal_author": {
      "avatar_url": null,
      "first_name": "John",
      "id": "c7358892-5f29-47db-a705-2c53d10da4bd",
      "name": "John Doe"
    },
    "goal_highlights": [],
    "goal_history": [],
    "goal_updated_at": "2026-09-16T15:30:00Z",
    "id": "c7358892-5f29-47db-a705-2c53d10da4bd",
    "initials": "JD",
    "instagram": null,
    "keap_custom_fields": {},
    "last_name": "Doe",
    "last_seen_at": null,
    "linkedin": null,
    "name": "John Doe",
    "otp_enabled": false,
    "permissions": [
      {
        "created_at": "2026-09-16T15:32:13Z",
        "id": "d7f04ad1-48fa-4811-92ac-c37498412cc7",
        "product_id": "276c0669-64b7-4294-a8d3-30e5f1f77b6c",
        "source_segment_id": null,
        "user_id": "c7358892-5f29-47db-a705-2c53d10da4bd"
      }
    ],
    "phone": "+1 555 0100",
    "profile_completion": 55,
    "segment_ids": [],
    "settings": {
      "hidden_identities": [],
      "notify_comment_reply": true,
      "notify_onboarding_reminders": true,
      "notify_post_access": true,
      "notify_product_updates": true
    },
    "stats": {
      "comments": 3,
      "files": 0,
      "likes": 0,
      "onboardings": 1,
      "pages_completed": 0,
      "products": 1
    },
    "status": "active",
    "suspended_until": null,
    "updated_at": "2026-09-16T15:32:12Z",
    "website": "https://example.com",
    "x_twitter": null
  }
}
```

**SDK Code**

```python Goals_setGoal_example
import requests

url = "https://api.customerhub.com/web_api/users/id"

payload = { "goal": "Launch the new coaching offer by Q4" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Goals_setGoal_example
const url = 'https://api.customerhub.com/web_api/users/id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"goal":"Launch the new coaching offer by Q4"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Goals_setGoal_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.customerhub.com/web_api/users/id"

	payload := strings.NewReader("{\n  \"goal\": \"Launch the new coaching offer by Q4\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Goals_setGoal_example
require 'uri'
require 'net/http'

url = URI("https://api.customerhub.com/web_api/users/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"goal\": \"Launch the new coaching offer by Q4\"\n}"

response = http.request(request)
puts response.read_body
```

```java Goals_setGoal_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.customerhub.com/web_api/users/id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"goal\": \"Launch the new coaching offer by Q4\"\n}")
  .asString();
```

```php Goals_setGoal_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.customerhub.com/web_api/users/id', [
  'body' => '{
  "goal": "Launch the new coaching offer by Q4"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Goals_setGoal_example
using RestSharp;

var client = new RestClient("https://api.customerhub.com/web_api/users/id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"goal\": \"Launch the new coaching offer by Q4\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Goals_setGoal_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["goal": "Launch the new coaching offer by Q4"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.customerhub.com/web_api/users/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```