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

# Record Your First Custom Event

> Track user actions by pushing custom events to SendX

## Track Your First Custom Event

Custom events allow you to record specific actions your contacts take — like abandoning a cart or making a purchase — and associate those actions with additional metadata.

This guide walks you through sending your first custom event using the SendX REST API.

## 1.  Prerequisites

Before you begin:

* [Create a SendX account](https://app.sendx.io/register)
* [Create a contact](/guides/contacts/create-your-first-contact) (events must be associated with a contact)
* Get your **Team API Key** from\
  **`Settings → API & Webhooks → Team API Key`**

<Tip>
  Your API Key is required for authentication. Keep it private and secure.
</Tip>

## 2. Push a Custom Event

Use the `/events/custom` endpoint to track a user action with optional metadata.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.sendx.io/api/v1/rest/events/custom \
    --header 'Content-Type: application/json' \
    --header 'X-Team-ApiKey: <YOUR_TEAM_API_KEY>' \
    --data '{
      "name": "abandoned_cart",
      "identifier": "john.doe@example.com",
      "data": {
        "price": "29.99",
        "currency": "USD",
        "item_count": "3"
      },
      "time": 1669990400
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.sendx.io/api/v1/rest/events/custom"

  payload = {
      "name": "abandoned_cart",
      "identifier": "john.doe@example.com",
      "data": {
          "price": "29.99",
          "currency": "USD",
          "item_count": "3"
      },
      "time": 1669990400  # Optional: Unix timestamp in seconds
  }

  headers = {
      "X-Team-ApiKey": "<YOUR_TEAM_API_KEY>",
      "Content-Type": "application/json"
  }

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

  print(response.text)
  ```

  ```go Golang theme={null}
  package main

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

  func main() {
  	url := "https://api.sendx.io/api/v1/rest/events/custom"
  	payload := strings.NewReader(`{
  	  "name": "abandoned_cart",
  	  "identifier": "john.doe@example.com",
  	  "data": {
  	    "price": "29.99",
  	    "currency": "USD",
  	    "item_count": "3"
  	  },
  	  "time": 1669990400
  	}`)

  	req, _ := http.NewRequest("POST", url, payload)
  	req.Header.Add("X-Team-ApiKey", "<YOUR_TEAM_API_KEY>")
  	req.Header.Add("Content-Type", "application/json")

  	res, _ := http.DefaultClient.Do(req)
  	defer res.Body.Close()
  	body, _ := ioutil.ReadAll(res.Body)

  	fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.post("https://api.sendx.io/api/v1/rest/events/custom")
    .header("X-Team-ApiKey", "<YOUR_TEAM_API_KEY>")
    .header("Content-Type", "application/json")
    .body("{\n  \"name\": \"abandoned_cart\",\n  \"identifier\": \"john.doe@example.com\",\n  \"data\": {\n    \"price\": \"29.99\",\n    \"currency\": \"USD\",\n    \"item_count\": \"3\"\n  },\n  \"time\": 1669990400\n}")
    .asString();
  ```
</CodeGroup>

### What This Does

This request records an event named `abandoned_cart` for the contact `john.doe@example.com`, along with additional metadata:

* **price:** 29.99
* **currency:** USD
* **item\_count:** 3
* **time:** 1669990400 (optional - if omitted, server will use current time)

<Card title="Custom Events API" icon="code" href="/api-reference/event/push-a-custom-event-associated-with-a-contact" cta="Try it in API Playground">
  Learn more about how to track custom events with additional data.
</Card>

## 3. Next Steps

Once you've recorded events, you can:

* Segment contacts based on event properties
* Trigger automations using event names
* Analyze custom events in your dashboard
* Explore the full API Reference to see what’s possible.
