# Quickstart

Three tracks, each a few minutes. They do not depend on each other: take the one you came for.

You need a HeyMySocial account with a confirmed email address. A new account starts a trial of 14 days, and the first-run setup offers to add a demo workspace filled with labelled sample data, which is a safe place to try the first track. [Create an account](https://heymysocial.com/register) if you do not have one.

## Track 1: connect an assistant

At the end your assistant can read your workspace and tell you what to do next.

1. In the app, open [Connect your AI](https://heymysocial.com/connect) and pick your assistant.
2. For an assistant with a connector screen (Claude, ChatGPT, Grok on the web, the Gemini app): add a connector with the address below, then approve the sign-in that HeyMySocial shows you.
3. For a command-line assistant or an editor: press **Create a key** and paste the command the screen gives you. The key starts with `hms_mcp_` and is shown once.

The address is the same for every assistant:

```text
https://heymysocial.com/mcp
```

With Claude Code the whole of step 3 is one command:

```bash
claude mcp add --transport http --scope user heymysocial https://heymysocial.com/mcp \
  --header "Authorization: Bearer hms_mcp_…"
```

4. Ask the assistant: "Call whoami in HeyMySocial and tell me which workspace you are in." The reply names you, your role and your workspaces, and the **Connect your AI** screen turns green.
5. Then ask: "Set up my HeyMySocial workspace with me, one step at a time." The assistant calls [get_started](https://heymysocial.com/docs/assistant/tools/get-started), which lists the setup steps, which are done, and the tool for each.

What you should see: answers that name your real workspace, and links back into the app for everything the assistant makes. If the assistant reports `access_denied`, your role in that workspace does not allow the action. [Connect an assistant](https://heymysocial.com/docs/assistant/connect) has the full steps and a table for when it does not connect.

## Track 2: send your first event with the API

At the end a lead and a sale sent from your own code are in the workspace.

### Create a key

Open [Settings, API keys](https://heymysocial.com/settings/api-keys) and create a key with the scope `events:write`. You need a role that may manage integrations (a manager). The key starts with `hms_live_`, belongs to that one workspace and is shown once. A key can carry these scopes; give it the fewest that do the job:

<div class="table-scroll"><table><thead><tr><th>Scope</th><th>Allows</th></tr></thead><tbody><tr><th scope="row"><code style="white-space:nowrap">events:write</code></th><td>Send events: page views, leads, lead status and sales</td></tr><tr><th scope="row"><code style="white-space:nowrap">leads:read</code></th><td>Read leads</td></tr><tr><th scope="row"><code style="white-space:nowrap">leads:write</code></th><td>Create and update leads</td></tr><tr><th scope="row"><code style="white-space:nowrap">sales:write</code></th><td>Record sales</td></tr><tr><th scope="row"><code style="white-space:nowrap">content:read</code></th><td>Read content</td></tr><tr><th scope="row"><code style="white-space:nowrap">content:write</code></th><td>Create content drafts</td></tr><tr><th scope="row"><code style="white-space:nowrap">reports:read</code></th><td>Read reports</td></tr><tr><th scope="row"><code style="white-space:nowrap">ads:write</code></th><td>Import ad data</td></tr></tbody></table></div>

Put the key in an environment variable named `HMS_API_KEY` in the shell you will use.

### Send a test event

An event with `"test": true` is stored and answered like any other, and creates nothing. Use it to check the key and the address.

```bash
curl -X POST https://heymysocial.com/api/v1/events \
  -H "Authorization: Bearer $HMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event_id": "quickstart-0001",
    "type": "lead_created",
    "occurred_at": "2026-11-25T09:30:00+01:00",
    "consent_state": "not_applicable",
    "test": true,
    "properties": {
      "contact": { "name": "Test Person", "email": "test.person@example.com" }
    }
  }'
```

The answer is `202 Accepted`:

```json
{
  "status": "accepted",
  "event_id": "01m88q65vckr4ek3fw8820n0gh",
  "test": true
}
```

### Send a lead

Now the real thing. `event_id` is your id for this event and `external_id` is your id for the lead; `occurred_at` is when it happened and is kept as you sent it. Use `not_applicable` for `consent_state` when no consent question applies, as for a lead that came from a CRM or a phone call.

```bash
curl -X POST https://heymysocial.com/api/v1/events \
  -H "Authorization: Bearer $HMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event_id": "quickstart-0002",
    "type": "lead_created",
    "occurred_at": "2026-11-25T09:30:00+01:00",
    "external_id": "lead-1001",
    "consent_state": "not_applicable",
    "properties": {
      "contact": { "name": "Test Person", "email": "test.person@example.com" },
      "form": { "message": "Please call me after four" }
    }
  }'
```

```json
{
  "status": "accepted",
  "event_id": "01m88q65vktrstbhhge49h5jas",
  "lead_id": "01m88q65vn0b49n6t27kfca52b"
}
```

The lead is now on the **Leads** screen with the status New. Send the same request again and the answer is `200 OK` with `"status": "duplicate"` and the same ids: an event seen before changes nothing, so a retry is always safe.

<div class="callout callout-note"><p class="callout-title">Two ids, two jobs</p>

An event is recognised as a duplicate by its `event_id`, and also by its `type` together with its `external_id`. Give a test event no `external_id`, or one you will not use again, or the real lead that follows is answered as a duplicate of the test.

</div>


### Send what became of it

Later events name their lead with `lead_external_id` (your id) or `lead_id` (ours). A sale needs an amount: `amount` in major units or `amount_minor` as an integer, with a three-letter `currency`.

```bash
curl -X POST https://heymysocial.com/api/v1/events \
  -H "Authorization: Bearer $HMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event_id": "quickstart-0003",
    "type": "sale_won",
    "occurred_at": "2026-11-25T14:00:00+01:00",
    "external_id": "order-5001",
    "lead_external_id": "lead-1001",
    "consent_state": "not_applicable",
    "properties": { "amount": 12500, "currency": "DKK", "revenue_basis": "booked", "verification_source": "crm" }
  }'
```

```json
{
  "status": "accepted",
  "event_id": "01m88q65y26nwbejskfwq14bt6",
  "lead_id": "01m88q65vn0b49n6t27kfca52b",
  "sale_id": "01m88q65y3v9st3va330rmnphr"
}
```

The lead is now Won and the sale counts in the results.

### When it differs

| Answer | Meaning |
|---|---|
| `401` with code `unauthenticated` | The key is missing, mistyped, revoked or expired. The header is `Authorization: Bearer hms_live_…`. |
| `403` with code `access_denied` | The key lacks the scope `events:write`. |
| `422` with code `validation_failed` | The event is not valid. `details` names each field, and the event is listed under **Funnels**, **Items to review**. |
| `202` with `"warning": "unmatched_lead"` | The event was stored, but the lead it names is not known yet. It is applied when that lead arrives. |
| `429` with code `rate_limited` | More than 120 requests a minute with one key, or more than 600 requests a minute to this endpoint from one address. Wait and send again. |

You can send up to 100 events in one request as `{"events": [...]}`; the answer then carries one result per event. The full schema is under [Send one event, or up to 100 events](https://heymysocial.com/docs/api/operations/ingest-events), and [server events](https://heymysocial.com/docs/tracking/server-events) covers every event type.

## Track 3: install the tracking script

At the end visits and leads from your website arrive in the workspace, tied to the post or ad that brought them.

1. In the app, open **Funnels**. On the tab **Websites and forms**, press **Add a website** and give it a name and your domain. This needs a role that may manage integrations.
2. Press **Install and test** on the new site. Copy the two lines under "1. Put the script on your website" and paste them before `</head>` on every page. Yours carry your site's own key in place of `hms_pk_…`:

```html
<script>window.hms=window.hms||function(){(hms.q=hms.q||[]).push(arguments)};</script>
<script async src="https://heymysocial.com/sdk/v1.js?k=hms_pk_…" data-consent="required"></script>
```

3. Tell the script what the visitor chose. A new site waits for consent: until your cookie banner reports that the visitor agreed, nothing is stored in the browser and no visit is sent.

```js
hms('consent', 'granted');
hms('consent', 'denied');
```

4. Send a lead when your form is submitted. The details travel in the request body, never in an address.

```js
hms('lead', { email: form.email.value, name: form.name.value, phone: form.phone.value });
```

5. Test the installation: open your website with `?hms_test=1` added to the address. The script sends a test event that creates no lead. Back on the site's screen, under "3. Check that it works", the event appears within a few seconds and the label changes to "A test from your website arrived".

What you should see: the test event in the list, marked "Test: created no lead". If nothing arrives, check that the page's origin is in **Allowed origins** on the same screen (for example `https://www.example.com`), and that the snippet is in the page source. The **Send a test event** button on that screen sends an event through the pipeline from inside the app; only a test that came from your website proves the installation.

Or ask your assistant: "Set up website tracking for example.com." It calls [manage_tracking_sites](https://heymysocial.com/docs/assistant/tools/manage-tracking-sites) and hands you the same snippet and steps.

The script, the consent rules and tracked links each have their own page: [the site script](https://heymysocial.com/docs/tracking/script), [consent](https://heymysocial.com/docs/tracking/consent), [tracked links](https://heymysocial.com/docs/tracking/links). The guide [Install and test tracking](https://heymysocial.com/guides/install-and-test-tracking) walks through the same task in more detail.

## Where to go next

- [Concepts](https://heymysocial.com/docs/concepts) for the rules every part of the product follows.
- [How tools behave](https://heymysocial.com/docs/assistant/how-tools-behave) if you are working through an assistant.
- [REST API](https://heymysocial.com/docs/api) and [webhooks](https://heymysocial.com/docs/webhooks) if you are writing code.
