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

# Send records via API

> Send data from external tools and systems via API.

export const ClayLogo = ({size = 24} = {}) => <div style={{
  display: 'flex',
  alignItems: 'center',
  justifyContent: 'center',
  width: size,
  height: size
}}>
    <img src="/images/logos/clay-logo.png" alt="Clay logo" style={{
  maxWidth: '100%',
  maxHeight: '100%',
  objectFit: 'contain',
  display: 'block'
}} />
  </div>;

## Overview

For tools and data sources that can't be connected using an existing
integration, Unify's [Data API](/developers/api/data/overview) can be used
instead. This general-purpose API allows you to programmatically find, create,
update, and delete records in Unify.

## Quickstart

<Steps titleSize="h3">
  <Step title="Generate an API key">
    Navigate to
    [Settings → Developers](https://app.unifygtm.com/dashboard/settings/integrations/api-keys)
    in Unify and select **Generate API Key**.
  </Step>

  <Step title="(Optional) Install the SDK">
    If you are writing Python or TypeScript code, you can install the official
    Unify SDK to simplify interacting with the API.

    <CardGroup cols={2}>
      <Card title="Python library" href="/developers/sdks/python-library" icon="python" horizontal>
        Install and use the official Unify Python library.
      </Card>

      <Card title="TypeScript library" href="/developers/sdks/typescript-library" icon="js" horizontal>
        Install and use the official Unify TypeScript library.
      </Card>
    </CardGroup>
  </Step>

  <Step title="Choose an object">
    You can create records for any object in Unify, including standard objects
    like `company` or `person`. But you can also create custom objects with
    whatever attributes and relationships you need.

    <CardGroup cols={2}>
      <Card title="Manage via API" href="/developers/api/data/overview" horizontal cta="API Reference">
        Create and manage objects, attributes, and records in Unify via API.
      </Card>

      <Card title="Manage via UI" href="/reference/objects/overview" horizontal cta="Objects Reference">
        Create and manage objects, attributes, and records within the Unify app.
      </Card>
    </CardGroup>
  </Step>

  <Step title="Upsert a record">
    Now you can push records into the selected object.

    The recommended API for creating and updating records is [Upsert record](/developers/api/data/records/upsert).
    This allows you to specify a unique attribute to match existing records and
    create or update based on whether a match is found, preventing duplicates.

    <CodeGroup>
      ```python Python theme={null}
      record = client.data.records.upsert(
          object_name="my_object",
          match={
            "email": "jane@example.com",
          },
          create_or_update_if_empty={
              "email": "jane@example.com",
              "login_count": 12,
              "plan_tier": "pro",
          },
      )

      print(f"Record ID: {record.data.id}")
      print(f"Email: {record.data.attributes['email']}")
      ```

      ```typescript TypeScript theme={null}
      const record = await client.data.records.upsert('my_object', {
        match: {
          email: 'jane@example.com',
        },
        create_or_update_if_empty: {
          email: 'jane@example.com',
          login_count: 12,
          plan_tier: 'pro',
        },
      });

      console.log(`Record ID: ${record.data.id}`);
      console.log(`Email: ${record.data.attributes.email}`);
      ```

      ```shell curl theme={null}
      curl -X POST 'https://api.unifygtm.com/data/v1/objects/product_user/records/upsert' \
        -H 'X-Api-Key: ${UNIFY_API_KEY}' \
        -H 'Content-Type: application/json' \
        -d '{
          "match": {
            "email": "jane@example.com"
          },
          "create_or_update_if_empty": {
            "email": "jane@example.com",
            "login_count": 12,
            "plan_tier": "pro"
          }
        }'
      ```
    </CodeGroup>
  </Step>

  <Step title="Verify in Unify">
    The record should now exist in Unify. You can verify this by searching for
    the record in the UI or by retrieving it via API.

    <CodeGroup>
      ```python Python theme={null}
      record = client.data.records.find_unique(
          object_name="my_object",
          match={
            "email": "jane@example.com",
          },
      )

      print(f"Record ID: {record.data.id}")
      print(f"Email: {record.data.attributes['email']}")
      ```

      ```typescript TypeScript theme={null}
      const record = await client.data.records.findUnique('my_object', {
        match: {
          email: 'jane@example.com',
        },
      });

      console.log(`Record ID: ${record.data.id}`);
      console.log(`Email: ${record.data.attributes.email}`);
      ```

      ```shell curl theme={null}
      curl -X POST 'https://api.unifygtm.com/data/v1/objects/product_user/records/find-unique' \
        -H 'X-Api-Key: ${UNIFY_API_KEY}' \
        -H 'Content-Type: application/json' \
        -d '{
          "match": {
            "email": "jane@example.com"
          }
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>

## What's next

<CardGroup cols={2}>
  <Card title="Import data from a CSV" href="/developers/guides/send-data/csv-import" icon="file-csv" horizontal>
    Sync data from a CSV file or spreadsheet into Unify.
  </Card>

  <Card title="Send records from Clay sheet" href="/developers/guides/send-data/clay-webhook" icon={<ClayLogo />} horizontal>
    Send records from a Clay sheet into Unify via webhook.
  </Card>

  <Card title="Data API reference" href="/developers/api/data/overview" icon="book" horizontal>
    Explore the full Data API reference.
  </Card>
</CardGroup>
