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

# Klaviyo

> Customer profiles, audience lists, campaigns, flows, and event tracking.

The Klaviyo connector lets your workflows manage customer profiles, audience lists, marketing campaigns, automation flows, and track custom events through Klaviyo's REST API.

<Note>
  For the full API reference, see the [Klaviyo API documentation](https://developers.klaviyo.com/en/reference/api_overview).
</Note>

<Snippet file="connection-note.mdx" />

## Connection setup

<Steps>
  <Step title="Get your private API key">
    Log in to [Klaviyo](https://www.klaviyo.com) and go to **Settings > API Keys**. Create a new **Private API Key** with the scopes your workflows need.
  </Step>

  <Step title="Add the connection in Spojit">
    Go to **Connections** in Spojit, click **Add Connection**, select **Klaviyo**, and enter:

    * **API Key**: Your Klaviyo private API key
  </Step>
</Steps>

## Tools

### Profiles

<AccordionGroup>
  <Accordion title="list-profiles: List customer profiles">
    <ParamField body="filter" type="string">Filter string (e.g., `equals(email,"john@example.com")`).</ParamField>
    <ParamField body="sort" type="string">Sort field (e.g., `-created` for newest first).</ParamField>
    <ParamField body="pageSize" type="number">Results per page (max 100).</ParamField>
    <ParamField body="pageCursor" type="string">Cursor for pagination.</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "filter": "greater-than(created,2024-01-01T00:00:00Z)",
      "sort": "-created",
      "pageSize": 2
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": [
        {
          "type": "profile",
          "id": "01GDDKASAP8TKDDA2GRZDSVP4H",
          "attributes": {
            "email": "sarah.mason@example.com",
            "phone_number": "+15005550006",
            "first_name": "Sarah",
            "last_name": "Mason",
            "created": "2024-03-15T10:30:00+00:00",
            "updated": "2024-06-01T14:22:00+00:00"
          }
        },
        {
          "type": "profile",
          "id": "01GDDKASAP8TKDDA2GRZDSVP4I",
          "attributes": {
            "email": "james.wilson@example.com",
            "first_name": "James",
            "last_name": "Wilson",
            "created": "2024-02-20T08:15:00+00:00",
            "updated": "2024-05-10T09:00:00+00:00"
          }
        }
      ],
      "links": {
        "self": "https://a.klaviyo.com/api/profiles/?page%5Bsize%5D=2",
        "next": "https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dC1wYWdl&page%5Bsize%5D=2"
      }
    }
    ```
  </Accordion>

  <Accordion title="get-profile: Get profile by ID">
    <ParamField body="id" type="string" required>Klaviyo profile ID.</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "id": "01GDDKASAP8TKDDA2GRZDSVP4H"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": {
        "type": "profile",
        "id": "01GDDKASAP8TKDDA2GRZDSVP4H",
        "attributes": {
          "email": "sarah.mason@example.com",
          "phone_number": "+15005550006",
          "first_name": "Sarah",
          "last_name": "Mason",
          "organization": "Acme Corp",
          "title": "Marketing Manager",
          "location": {
            "city": "Boston",
            "region": "MA",
            "country": "US",
            "zip": "02101"
          },
          "properties": {
            "plan": "premium",
            "signup_source": "website"
          },
          "created": "2024-03-15T10:30:00+00:00",
          "updated": "2024-06-01T14:22:00+00:00"
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="create-profile: Create a profile">
    <ParamField body="attributes" type="object" required>Profile attributes: `email`, `phone_number`, `first_name`, `last_name`, `properties`, etc.</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "attributes": {
        "email": "new.customer@example.com",
        "first_name": "Emily",
        "last_name": "Chen",
        "phone_number": "+15005550007",
        "location": {
          "city": "San Francisco",
          "region": "CA",
          "country": "US"
        },
        "properties": {
          "plan": "free",
          "signup_source": "checkout"
        }
      }
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": {
        "type": "profile",
        "id": "01HWKAJ9RPYXMZ4NVBQ2NQXG5A",
        "attributes": {
          "email": "new.customer@example.com",
          "first_name": "Emily",
          "last_name": "Chen",
          "phone_number": "+15005550007",
          "created": "2024-06-15T12:00:00+00:00",
          "updated": "2024-06-15T12:00:00+00:00"
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="update-profile: Update a profile">
    <ParamField body="id" type="string" required>Klaviyo profile ID.</ParamField>
    <ParamField body="attributes" type="object" required>Attributes to update.</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "id": "01GDDKASAP8TKDDA2GRZDSVP4H",
      "attributes": {
        "first_name": "Sarah",
        "last_name": "Mason-Smith",
        "properties": {
          "plan": "enterprise"
        }
      }
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": {
        "type": "profile",
        "id": "01GDDKASAP8TKDDA2GRZDSVP4H",
        "attributes": {
          "email": "sarah.mason@example.com",
          "first_name": "Sarah",
          "last_name": "Mason-Smith",
          "properties": {
            "plan": "enterprise",
            "signup_source": "website"
          },
          "updated": "2024-06-15T14:30:00+00:00"
        }
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### Lists

<AccordionGroup>
  <Accordion title="list-lists: List audience lists">
    No parameters required.

    **Example response:**

    ```json theme={null}
    {
      "data": [
        {
          "type": "list",
          "id": "Y6nRLr",
          "attributes": {
            "name": "Newsletter Subscribers",
            "created": "2024-01-10T08:00:00+00:00",
            "updated": "2024-06-01T12:00:00+00:00"
          }
        },
        {
          "type": "list",
          "id": "X5mQKs",
          "attributes": {
            "name": "VIP Customers",
            "created": "2024-02-15T10:00:00+00:00",
            "updated": "2024-05-20T09:30:00+00:00"
          }
        }
      ]
    }
    ```
  </Accordion>

  <Accordion title="add-profiles-to-list: Add profiles to a list">
    <ParamField body="listId" type="string" required>Klaviyo list ID.</ParamField>
    <ParamField body="profileIds" type="string[]" required>Array of profile IDs to add.</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "listId": "Y6nRLr",
      "profileIds": [
        "01GDDKASAP8TKDDA2GRZDSVP4H",
        "01HWKAJ9RPYXMZ4NVBQ2NQXG5A"
      ]
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true
    }
    ```
  </Accordion>
</AccordionGroup>

### Campaigns & Flows

<AccordionGroup>
  <Accordion title="list-campaigns: List campaigns">
    <ParamField body="filter" type="string">Filter string (e.g., `equals(messages.channel,"email")`).</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "filter": "equals(messages.channel,\"email\")"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": [
        {
          "type": "campaign",
          "id": "01HWKAJ9RPYXMZ4NVBQ2CAMP1",
          "attributes": {
            "name": "Summer Sale Announcement",
            "status": "sent",
            "audiences": {
              "included": ["Y6nRLr"]
            },
            "send_strategy": {
              "method": "immediate"
            },
            "created_at": "2024-06-01T08:00:00+00:00",
            "sent_at": "2024-06-01T10:00:00+00:00"
          }
        }
      ]
    }
    ```
  </Accordion>

  <Accordion title="list-flows: List automation flows">
    <ParamField body="filter" type="string">Filter string (e.g., `equals(status,"live")`).</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "filter": "equals(status,\"live\")"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": [
        {
          "type": "flow",
          "id": "VJxwRK",
          "attributes": {
            "name": "Welcome Series",
            "status": "live",
            "trigger_type": "Added to List",
            "created": "2024-01-05T09:00:00+00:00",
            "updated": "2024-05-15T11:00:00+00:00"
          }
        },
        {
          "type": "flow",
          "id": "WKyxSL",
          "attributes": {
            "name": "Abandoned Cart",
            "status": "live",
            "trigger_type": "Metric",
            "created": "2024-02-10T14:00:00+00:00",
            "updated": "2024-06-01T08:00:00+00:00"
          }
        }
      ]
    }
    ```
  </Accordion>
</AccordionGroup>

### Events

<AccordionGroup>
  <Accordion title="list-events: List tracked events">
    <ParamField body="filter" type="string">Filter string.</ParamField>
    <ParamField body="sort" type="string">Sort field (e.g., `-datetime`).</ParamField>
    <ParamField body="pageSize" type="number">Results per page (max 100).</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "sort": "-datetime",
      "pageSize": 2
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": [
        {
          "type": "event",
          "id": "4vRpBQ16wa",
          "attributes": {
            "metric_id": "UMTlbk",
            "profile_id": "01GDDKASAP8TKDDA2GRZDSVP4H",
            "timestamp": 1718460000,
            "event_properties": {
              "OrderId": "ORD-5678",
              "Items": ["Blue T-Shirt", "Running Shoes"],
              "Value": 129.99
            },
            "datetime": "2024-06-15T14:00:00+00:00"
          }
        }
      ]
    }
    ```
  </Accordion>

  <Accordion title="create-event: Track a custom event">
    <ParamField body="attributes" type="object" required>Event attributes including `metric` (name), `profile` (email/id), `properties`, `time`, `value`.</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "attributes": {
        "metric": {
          "data": {
            "type": "metric",
            "attributes": {
              "name": "Placed Order"
            }
          }
        },
        "profile": {
          "data": {
            "type": "profile",
            "attributes": {
              "email": "sarah.mason@example.com"
            }
          }
        },
        "properties": {
          "OrderId": "ORD-9012",
          "Categories": ["Apparel", "Accessories"],
          "ItemCount": 3
        },
        "value": 199.99,
        "time": "2024-06-15T16:30:00+00:00"
      }
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true
    }
    ```
  </Accordion>
</AccordionGroup>

### Advanced

<AccordionGroup>
  <Accordion title="raw-api-request: Make an arbitrary API request">
    Send a request to any Klaviyo API endpoint.
    <ParamField body="method" type="string" required>HTTP method: `GET`, `POST`, `PATCH`, `PUT`, or `DELETE`.</ParamField>
    <ParamField body="path" type="string" required>API path (e.g., `/segments` or `/metrics`).</ParamField>
    <ParamField body="body" type="object">Request body (JSON:API format for POST/PATCH).</ParamField>

    **Example request:**

    ```json theme={null}
    {
      "method": "GET",
      "path": "/metrics"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "data": [
        {
          "type": "metric",
          "id": "UMTlbk",
          "attributes": {
            "name": "Placed Order",
            "created": "2024-01-01T00:00:00+00:00",
            "updated": "2024-06-15T00:00:00+00:00",
            "integration": {
              "object": "integration",
              "id": "0rPhKs",
              "name": "API"
            }
          }
        }
      ]
    }
    ```
  </Accordion>
</AccordionGroup>
