curl --request POST \
--url https://api.affinity.co/v2/persons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "Jane",
"lastName": "Doe",
"primaryEmailAddress": "jane.doe@northpointvc.com",
"emailAddresses": [
"jane.doe@northpointvc.com",
"janedoe@gmail.com"
],
"fields": [
{
"id": "affinity-data-location",
"value": {
"type": "company-multi",
"data": [
{
"id": 1
},
{
"id": 2
}
]
}
}
]
}
'import requests
url = "https://api.affinity.co/v2/persons"
payload = {
"firstName": "Jane",
"lastName": "Doe",
"primaryEmailAddress": "jane.doe@northpointvc.com",
"emailAddresses": ["jane.doe@northpointvc.com", "janedoe@gmail.com"],
"fields": [
{
"id": "affinity-data-location",
"value": {
"type": "company-multi",
"data": [{ "id": 1 }, { "id": 2 }]
}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: 'Jane',
lastName: 'Doe',
primaryEmailAddress: 'jane.doe@northpointvc.com',
emailAddresses: ['jane.doe@northpointvc.com', 'janedoe@gmail.com'],
fields: [
{
id: 'affinity-data-location',
value: {type: 'company-multi', data: [{id: 1}, {id: 2}]}
}
]
})
};
fetch('https://api.affinity.co/v2/persons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.affinity.co/v2/persons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'firstName' => 'Jane',
'lastName' => 'Doe',
'primaryEmailAddress' => 'jane.doe@northpointvc.com',
'emailAddresses' => [
'jane.doe@northpointvc.com',
'janedoe@gmail.com'
],
'fields' => [
[
'id' => 'affinity-data-location',
'value' => [
'type' => 'company-multi',
'data' => [
[
'id' => 1
],
[
'id' => 2
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.affinity.co/v2/persons"
payload := strings.NewReader("{\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"primaryEmailAddress\": \"jane.doe@northpointvc.com\",\n \"emailAddresses\": [\n \"jane.doe@northpointvc.com\",\n \"janedoe@gmail.com\"\n ],\n \"fields\": [\n {\n \"id\": \"affinity-data-location\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.affinity.co/v2/persons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"primaryEmailAddress\": \"jane.doe@northpointvc.com\",\n \"emailAddresses\": [\n \"jane.doe@northpointvc.com\",\n \"janedoe@gmail.com\"\n ],\n \"fields\": [\n {\n \"id\": \"affinity-data-location\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/persons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"primaryEmailAddress\": \"jane.doe@northpointvc.com\",\n \"emailAddresses\": [\n \"jane.doe@northpointvc.com\",\n \"janedoe@gmail.com\"\n ],\n \"fields\": [\n {\n \"id\": \"affinity-data-location\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"firstName": "Jane",
"lastName": "Doe",
"primaryEmailAddress": "jane.smith@northpointvc.com",
"emailAddresses": [
"jane.smith@northpointvc.com",
"janedoe@gmail.com"
],
"type": "internal",
"fields": [
{
"id": "affinity-data-location",
"name": "Location",
"type": "enriched",
"enrichmentSource": "affinity-data",
"value": {
"type": "company-multi",
"data": [
{
"id": 1,
"name": "Horizon Technologies",
"domain": "horizontech.com"
},
{
"id": 2,
"name": "Crestwood Capital",
"domain": "crestwoodcap.com"
}
]
}
}
]
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Create a Person
This endpoint is currently in BETA.
Creates a new Person. Setting fields values requires the “Edit Global Field Values”
permission and returns a 403 error if the caller lacks it.
curl --request POST \
--url https://api.affinity.co/v2/persons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "Jane",
"lastName": "Doe",
"primaryEmailAddress": "jane.doe@northpointvc.com",
"emailAddresses": [
"jane.doe@northpointvc.com",
"janedoe@gmail.com"
],
"fields": [
{
"id": "affinity-data-location",
"value": {
"type": "company-multi",
"data": [
{
"id": 1
},
{
"id": 2
}
]
}
}
]
}
'import requests
url = "https://api.affinity.co/v2/persons"
payload = {
"firstName": "Jane",
"lastName": "Doe",
"primaryEmailAddress": "jane.doe@northpointvc.com",
"emailAddresses": ["jane.doe@northpointvc.com", "janedoe@gmail.com"],
"fields": [
{
"id": "affinity-data-location",
"value": {
"type": "company-multi",
"data": [{ "id": 1 }, { "id": 2 }]
}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: 'Jane',
lastName: 'Doe',
primaryEmailAddress: 'jane.doe@northpointvc.com',
emailAddresses: ['jane.doe@northpointvc.com', 'janedoe@gmail.com'],
fields: [
{
id: 'affinity-data-location',
value: {type: 'company-multi', data: [{id: 1}, {id: 2}]}
}
]
})
};
fetch('https://api.affinity.co/v2/persons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.affinity.co/v2/persons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'firstName' => 'Jane',
'lastName' => 'Doe',
'primaryEmailAddress' => 'jane.doe@northpointvc.com',
'emailAddresses' => [
'jane.doe@northpointvc.com',
'janedoe@gmail.com'
],
'fields' => [
[
'id' => 'affinity-data-location',
'value' => [
'type' => 'company-multi',
'data' => [
[
'id' => 1
],
[
'id' => 2
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.affinity.co/v2/persons"
payload := strings.NewReader("{\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"primaryEmailAddress\": \"jane.doe@northpointvc.com\",\n \"emailAddresses\": [\n \"jane.doe@northpointvc.com\",\n \"janedoe@gmail.com\"\n ],\n \"fields\": [\n {\n \"id\": \"affinity-data-location\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.affinity.co/v2/persons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"primaryEmailAddress\": \"jane.doe@northpointvc.com\",\n \"emailAddresses\": [\n \"jane.doe@northpointvc.com\",\n \"janedoe@gmail.com\"\n ],\n \"fields\": [\n {\n \"id\": \"affinity-data-location\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/persons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"primaryEmailAddress\": \"jane.doe@northpointvc.com\",\n \"emailAddresses\": [\n \"jane.doe@northpointvc.com\",\n \"janedoe@gmail.com\"\n ],\n \"fields\": [\n {\n \"id\": \"affinity-data-location\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"firstName": "Jane",
"lastName": "Doe",
"primaryEmailAddress": "jane.smith@northpointvc.com",
"emailAddresses": [
"jane.smith@northpointvc.com",
"janedoe@gmail.com"
],
"type": "internal",
"fields": [
{
"id": "affinity-data-location",
"name": "Location",
"type": "enriched",
"enrichmentSource": "affinity-data",
"value": {
"type": "company-multi",
"data": [
{
"id": 1,
"name": "Horizon Technologies",
"domain": "horizontech.com"
},
{
"id": 2,
"name": "Crestwood Capital",
"domain": "crestwoodcap.com"
}
]
}
}
]
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Authorizations
A static Affinity API key, presented as a bearer token.
Body
Request body for creating a Person.
The person's first name.
"Jane"
The person's last name.
"Doe"
The person's primary email address.
"jane.doe@northpointvc.com"
All of the person's email addresses. If not provided, defaults to [{primaryEmailAddress}]
100[
"jane.doe@northpointvc.com",
"janedoe@gmail.com"
]
Field-value updates to apply to the newly created Person.
100Show child attributes
Show child attributes
Response
Created
Person model
The persons's unique identifier
1 <= x <= 90071992547409911
The person's first name
"Jane"
The person's last name
"Doe"
The person's primary email address
"jane.smith@northpointvc.com"
All of the person's email addresses
[
"jane.smith@northpointvc.com",
"janedoe@gmail.com"
]
The person's type. internal - people who are users within your Affinity instance. external - people who are not internal.
internal, external "internal"
The fields associated with the person
Show child attributes
Show child attributes
Was this page helpful?