Overview
This tutorial walks through the process of creating Company records via API. We’ll assume the starting point is a CSV of company data to upload, but in general the approach here can be used for any data source. The Company object is one of the standard objects provided by default in Unify. Along with Person, it powers many of the core capabilities in Unify. The unique identifier of a company is its website domain.Prerequisites
Before you begin, be sure to generate an API key if you don’t already have one. You’ll pass it as an HTTP header on each request:Steps
1
Prepare a CSV of companies
Construct a CSV file that includes the companies you want to send into
Unify. The columns don’t need to match the attribute names in Unify since
we’ll map them over in the script.Here’s an example CSV for the sake of this tutorial:The only required column is a website or domain for the company. That’s
because Unify uses a company’s domain as its unique identifier. Everything
else is optional.
example_companies.csv
2
Install dependencies
You’ll just need Python 3.10+ and the
requests
library.3
Understand the request payload
We’ll use the upsert method to create
companies if they don’t exist and update them if they do. The upsert method
is the recommended way of sending data into Unify since it gives you the
most control and never fails if a record already exists.The upsert requests we send will have two properties:Here’s what a single request looks like for one company row:
match
— This contains the value(s) used to match existing records. In this case, the only value we will use for matching is thedomain
.defaults
— This contains the values used when creating or updating the record.
The
defaults
property never overwrites values if the record already
exists, which is a nice property. For full control over updating existing
records, you can specify create
and update
properties instead, but we’ll
skip that for now.4
Assemble the script
The script needs to perform a few steps:
- Read the CSV
- Construct an upsert request payload for each row
- Send the requests
5
Run the script
Set your API key as an environment variable and then run the script:You should see output like this:
bash
Output
6
Verify records exist (optional)
You can verify a specific company with the Find Unique Record
API. Simply send a request with a
match
property containing the domain of
one of the companies the script ran on: