Perform batch operations on a person's fields
curl --request PATCH \
--url https://api.affinity.co/v2/persons/{personId}/fields \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operation": "update-fields",
"updates": [
{
"id": "field-1",
"value": {
"type": "company",
"data": {
"id": 1
}
}
},
{
"id": "field-2",
"value": {
"type": "company-multi",
"data": [
{
"id": 1
},
{
"id": 2
}
]
}
},
{
"id": "field-3",
"value": {
"type": "datetime",
"data": "2023-01-01T00:00:00Z"
}
},
{
"id": "field-4",
"value": {
"type": "dropdown",
"data": {
"dropdownOptionId": 1
}
}
},
{
"id": "field-5",
"value": {
"type": "dropdown-multi",
"data": [
{
"dropdownOptionId": 1
},
{
"dropdownOptionId": 2
}
]
}
},
{
"id": "field-6",
"value": {
"type": "location",
"data": {
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
}
}
},
{
"id": "field-7",
"value": {
"type": "location-multi",
"data": [
{
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
},
{
"streetAddress": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"country": "United States",
"continent": "North America"
}
]
}
},
{
"id": "field-8",
"value": {
"type": "number",
"data": 100
}
},
{
"id": "field-9",
"value": {
"type": "number-multi",
"data": [
100,
200,
300
]
}
},
{
"id": "field-10",
"value": {
"type": "person",
"data": {
"id": 1
}
}
},
{
"id": "field-11",
"value": {
"type": "person-multi",
"data": [
{
"id": 1
},
{
"id": 2
}
]
}
},
{
"id": "field-12",
"value": {
"type": "ranked-dropdown",
"data": {
"dropdownOptionId": 1
}
}
},
{
"id": "field-13",
"value": {
"type": "text",
"data": "Some new text"
}
}
]
}
'import requests
url = "https://api.affinity.co/v2/persons/{personId}/fields"
payload = {
"operation": "update-fields",
"updates": [
{
"id": "field-1",
"value": {
"type": "company",
"data": { "id": 1 }
}
},
{
"id": "field-2",
"value": {
"type": "company-multi",
"data": [{ "id": 1 }, { "id": 2 }]
}
},
{
"id": "field-3",
"value": {
"type": "datetime",
"data": "2023-01-01T00:00:00Z"
}
},
{
"id": "field-4",
"value": {
"type": "dropdown",
"data": { "dropdownOptionId": 1 }
}
},
{
"id": "field-5",
"value": {
"type": "dropdown-multi",
"data": [{ "dropdownOptionId": 1 }, { "dropdownOptionId": 2 }]
}
},
{
"id": "field-6",
"value": {
"type": "location",
"data": {
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
}
}
},
{
"id": "field-7",
"value": {
"type": "location-multi",
"data": [
{
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
},
{
"streetAddress": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"country": "United States",
"continent": "North America"
}
]
}
},
{
"id": "field-8",
"value": {
"type": "number",
"data": 100
}
},
{
"id": "field-9",
"value": {
"type": "number-multi",
"data": [100, 200, 300]
}
},
{
"id": "field-10",
"value": {
"type": "person",
"data": { "id": 1 }
}
},
{
"id": "field-11",
"value": {
"type": "person-multi",
"data": [{ "id": 1 }, { "id": 2 }]
}
},
{
"id": "field-12",
"value": {
"type": "ranked-dropdown",
"data": { "dropdownOptionId": 1 }
}
},
{
"id": "field-13",
"value": {
"type": "text",
"data": "Some new text"
}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operation: 'update-fields',
updates: [
{id: 'field-1', value: {type: 'company', data: {id: 1}}},
{id: 'field-2', value: {type: 'company-multi', data: [{id: 1}, {id: 2}]}},
{id: 'field-3', value: {type: 'datetime', data: '2023-01-01T00:00:00Z'}},
{id: 'field-4', value: {type: 'dropdown', data: {dropdownOptionId: 1}}},
{
id: 'field-5',
value: {type: 'dropdown-multi', data: [{dropdownOptionId: 1}, {dropdownOptionId: 2}]}
},
{
id: 'field-6',
value: {
type: 'location',
data: {
streetAddress: '1 Main Street',
city: 'San Francisco',
state: 'California',
country: 'United States',
continent: 'North America'
}
}
},
{
id: 'field-7',
value: {
type: 'location-multi',
data: [
{
streetAddress: '1 Main Street',
city: 'San Francisco',
state: 'California',
country: 'United States',
continent: 'North America'
},
{
streetAddress: '1600 Pennsylvania Avenue NW',
city: 'Washington',
state: 'DC',
country: 'United States',
continent: 'North America'
}
]
}
},
{id: 'field-8', value: {type: 'number', data: 100}},
{id: 'field-9', value: {type: 'number-multi', data: [100, 200, 300]}},
{id: 'field-10', value: {type: 'person', data: {id: 1}}},
{id: 'field-11', value: {type: 'person-multi', data: [{id: 1}, {id: 2}]}},
{id: 'field-12', value: {type: 'ranked-dropdown', data: {dropdownOptionId: 1}}},
{id: 'field-13', value: {type: 'text', data: 'Some new text'}}
]
})
};
fetch('https://api.affinity.co/v2/persons/{personId}/fields', 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/{personId}/fields",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'operation' => 'update-fields',
'updates' => [
[
'id' => 'field-1',
'value' => [
'type' => 'company',
'data' => [
'id' => 1
]
]
],
[
'id' => 'field-2',
'value' => [
'type' => 'company-multi',
'data' => [
[
'id' => 1
],
[
'id' => 2
]
]
]
],
[
'id' => 'field-3',
'value' => [
'type' => 'datetime',
'data' => '2023-01-01T00:00:00Z'
]
],
[
'id' => 'field-4',
'value' => [
'type' => 'dropdown',
'data' => [
'dropdownOptionId' => 1
]
]
],
[
'id' => 'field-5',
'value' => [
'type' => 'dropdown-multi',
'data' => [
[
'dropdownOptionId' => 1
],
[
'dropdownOptionId' => 2
]
]
]
],
[
'id' => 'field-6',
'value' => [
'type' => 'location',
'data' => [
'streetAddress' => '1 Main Street',
'city' => 'San Francisco',
'state' => 'California',
'country' => 'United States',
'continent' => 'North America'
]
]
],
[
'id' => 'field-7',
'value' => [
'type' => 'location-multi',
'data' => [
[
'streetAddress' => '1 Main Street',
'city' => 'San Francisco',
'state' => 'California',
'country' => 'United States',
'continent' => 'North America'
],
[
'streetAddress' => '1600 Pennsylvania Avenue NW',
'city' => 'Washington',
'state' => 'DC',
'country' => 'United States',
'continent' => 'North America'
]
]
]
],
[
'id' => 'field-8',
'value' => [
'type' => 'number',
'data' => 100
]
],
[
'id' => 'field-9',
'value' => [
'type' => 'number-multi',
'data' => [
100,
200,
300
]
]
],
[
'id' => 'field-10',
'value' => [
'type' => 'person',
'data' => [
'id' => 1
]
]
],
[
'id' => 'field-11',
'value' => [
'type' => 'person-multi',
'data' => [
[
'id' => 1
],
[
'id' => 2
]
]
]
],
[
'id' => 'field-12',
'value' => [
'type' => 'ranked-dropdown',
'data' => [
'dropdownOptionId' => 1
]
]
],
[
'id' => 'field-13',
'value' => [
'type' => 'text',
'data' => 'Some new text'
]
]
]
]),
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/{personId}/fields"
payload := strings.NewReader("{\n \"operation\": \"update-fields\",\n \"updates\": [\n {\n \"id\": \"field-1\",\n \"value\": {\n \"type\": \"company\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-2\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-3\",\n \"value\": {\n \"type\": \"datetime\",\n \"data\": \"2023-01-01T00:00:00Z\"\n }\n },\n {\n \"id\": \"field-4\",\n \"value\": {\n \"type\": \"dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-5\",\n \"value\": {\n \"type\": \"dropdown-multi\",\n \"data\": [\n {\n \"dropdownOptionId\": 1\n },\n {\n \"dropdownOptionId\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-6\",\n \"value\": {\n \"type\": \"location\",\n \"data\": {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n }\n },\n {\n \"id\": \"field-7\",\n \"value\": {\n \"type\": \"location-multi\",\n \"data\": [\n {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n },\n {\n \"streetAddress\": \"1600 Pennsylvania Avenue NW\",\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n ]\n }\n },\n {\n \"id\": \"field-8\",\n \"value\": {\n \"type\": \"number\",\n \"data\": 100\n }\n },\n {\n \"id\": \"field-9\",\n \"value\": {\n \"type\": \"number-multi\",\n \"data\": [\n 100,\n 200,\n 300\n ]\n }\n },\n {\n \"id\": \"field-10\",\n \"value\": {\n \"type\": \"person\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-11\",\n \"value\": {\n \"type\": \"person-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-12\",\n \"value\": {\n \"type\": \"ranked-dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-13\",\n \"value\": {\n \"type\": \"text\",\n \"data\": \"Some new text\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.affinity.co/v2/persons/{personId}/fields")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"operation\": \"update-fields\",\n \"updates\": [\n {\n \"id\": \"field-1\",\n \"value\": {\n \"type\": \"company\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-2\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-3\",\n \"value\": {\n \"type\": \"datetime\",\n \"data\": \"2023-01-01T00:00:00Z\"\n }\n },\n {\n \"id\": \"field-4\",\n \"value\": {\n \"type\": \"dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-5\",\n \"value\": {\n \"type\": \"dropdown-multi\",\n \"data\": [\n {\n \"dropdownOptionId\": 1\n },\n {\n \"dropdownOptionId\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-6\",\n \"value\": {\n \"type\": \"location\",\n \"data\": {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n }\n },\n {\n \"id\": \"field-7\",\n \"value\": {\n \"type\": \"location-multi\",\n \"data\": [\n {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n },\n {\n \"streetAddress\": \"1600 Pennsylvania Avenue NW\",\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n ]\n }\n },\n {\n \"id\": \"field-8\",\n \"value\": {\n \"type\": \"number\",\n \"data\": 100\n }\n },\n {\n \"id\": \"field-9\",\n \"value\": {\n \"type\": \"number-multi\",\n \"data\": [\n 100,\n 200,\n 300\n ]\n }\n },\n {\n \"id\": \"field-10\",\n \"value\": {\n \"type\": \"person\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-11\",\n \"value\": {\n \"type\": \"person-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-12\",\n \"value\": {\n \"type\": \"ranked-dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-13\",\n \"value\": {\n \"type\": \"text\",\n \"data\": \"Some new text\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/persons/{personId}/fields")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operation\": \"update-fields\",\n \"updates\": [\n {\n \"id\": \"field-1\",\n \"value\": {\n \"type\": \"company\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-2\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-3\",\n \"value\": {\n \"type\": \"datetime\",\n \"data\": \"2023-01-01T00:00:00Z\"\n }\n },\n {\n \"id\": \"field-4\",\n \"value\": {\n \"type\": \"dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-5\",\n \"value\": {\n \"type\": \"dropdown-multi\",\n \"data\": [\n {\n \"dropdownOptionId\": 1\n },\n {\n \"dropdownOptionId\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-6\",\n \"value\": {\n \"type\": \"location\",\n \"data\": {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n }\n },\n {\n \"id\": \"field-7\",\n \"value\": {\n \"type\": \"location-multi\",\n \"data\": [\n {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n },\n {\n \"streetAddress\": \"1600 Pennsylvania Avenue NW\",\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n ]\n }\n },\n {\n \"id\": \"field-8\",\n \"value\": {\n \"type\": \"number\",\n \"data\": 100\n }\n },\n {\n \"id\": \"field-9\",\n \"value\": {\n \"type\": \"number-multi\",\n \"data\": [\n 100,\n 200,\n 300\n ]\n }\n },\n {\n \"id\": \"field-10\",\n \"value\": {\n \"type\": \"person\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-11\",\n \"value\": {\n \"type\": \"person-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-12\",\n \"value\": {\n \"type\": \"ranked-dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-13\",\n \"value\": {\n \"type\": \"text\",\n \"data\": \"Some new text\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"operation": "update-fields"
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Persons
Perform batch operations on a person's fields
| ⚠️ This endpoint is currently in BETA |
|---|
Perform batch operations on a person’s fields.
Currently the only operation at the endpoint is update-fields, which allows you to update
multiple field values with a single request. This is equivalent to calling the single field
update endpoint multiple times. You can
update up to 100 fields per request.
PATCH
/
v2
/
persons
/
{personId}
/
fields
Perform batch operations on a person's fields
curl --request PATCH \
--url https://api.affinity.co/v2/persons/{personId}/fields \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operation": "update-fields",
"updates": [
{
"id": "field-1",
"value": {
"type": "company",
"data": {
"id": 1
}
}
},
{
"id": "field-2",
"value": {
"type": "company-multi",
"data": [
{
"id": 1
},
{
"id": 2
}
]
}
},
{
"id": "field-3",
"value": {
"type": "datetime",
"data": "2023-01-01T00:00:00Z"
}
},
{
"id": "field-4",
"value": {
"type": "dropdown",
"data": {
"dropdownOptionId": 1
}
}
},
{
"id": "field-5",
"value": {
"type": "dropdown-multi",
"data": [
{
"dropdownOptionId": 1
},
{
"dropdownOptionId": 2
}
]
}
},
{
"id": "field-6",
"value": {
"type": "location",
"data": {
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
}
}
},
{
"id": "field-7",
"value": {
"type": "location-multi",
"data": [
{
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
},
{
"streetAddress": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"country": "United States",
"continent": "North America"
}
]
}
},
{
"id": "field-8",
"value": {
"type": "number",
"data": 100
}
},
{
"id": "field-9",
"value": {
"type": "number-multi",
"data": [
100,
200,
300
]
}
},
{
"id": "field-10",
"value": {
"type": "person",
"data": {
"id": 1
}
}
},
{
"id": "field-11",
"value": {
"type": "person-multi",
"data": [
{
"id": 1
},
{
"id": 2
}
]
}
},
{
"id": "field-12",
"value": {
"type": "ranked-dropdown",
"data": {
"dropdownOptionId": 1
}
}
},
{
"id": "field-13",
"value": {
"type": "text",
"data": "Some new text"
}
}
]
}
'import requests
url = "https://api.affinity.co/v2/persons/{personId}/fields"
payload = {
"operation": "update-fields",
"updates": [
{
"id": "field-1",
"value": {
"type": "company",
"data": { "id": 1 }
}
},
{
"id": "field-2",
"value": {
"type": "company-multi",
"data": [{ "id": 1 }, { "id": 2 }]
}
},
{
"id": "field-3",
"value": {
"type": "datetime",
"data": "2023-01-01T00:00:00Z"
}
},
{
"id": "field-4",
"value": {
"type": "dropdown",
"data": { "dropdownOptionId": 1 }
}
},
{
"id": "field-5",
"value": {
"type": "dropdown-multi",
"data": [{ "dropdownOptionId": 1 }, { "dropdownOptionId": 2 }]
}
},
{
"id": "field-6",
"value": {
"type": "location",
"data": {
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
}
}
},
{
"id": "field-7",
"value": {
"type": "location-multi",
"data": [
{
"streetAddress": "1 Main Street",
"city": "San Francisco",
"state": "California",
"country": "United States",
"continent": "North America"
},
{
"streetAddress": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"country": "United States",
"continent": "North America"
}
]
}
},
{
"id": "field-8",
"value": {
"type": "number",
"data": 100
}
},
{
"id": "field-9",
"value": {
"type": "number-multi",
"data": [100, 200, 300]
}
},
{
"id": "field-10",
"value": {
"type": "person",
"data": { "id": 1 }
}
},
{
"id": "field-11",
"value": {
"type": "person-multi",
"data": [{ "id": 1 }, { "id": 2 }]
}
},
{
"id": "field-12",
"value": {
"type": "ranked-dropdown",
"data": { "dropdownOptionId": 1 }
}
},
{
"id": "field-13",
"value": {
"type": "text",
"data": "Some new text"
}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operation: 'update-fields',
updates: [
{id: 'field-1', value: {type: 'company', data: {id: 1}}},
{id: 'field-2', value: {type: 'company-multi', data: [{id: 1}, {id: 2}]}},
{id: 'field-3', value: {type: 'datetime', data: '2023-01-01T00:00:00Z'}},
{id: 'field-4', value: {type: 'dropdown', data: {dropdownOptionId: 1}}},
{
id: 'field-5',
value: {type: 'dropdown-multi', data: [{dropdownOptionId: 1}, {dropdownOptionId: 2}]}
},
{
id: 'field-6',
value: {
type: 'location',
data: {
streetAddress: '1 Main Street',
city: 'San Francisco',
state: 'California',
country: 'United States',
continent: 'North America'
}
}
},
{
id: 'field-7',
value: {
type: 'location-multi',
data: [
{
streetAddress: '1 Main Street',
city: 'San Francisco',
state: 'California',
country: 'United States',
continent: 'North America'
},
{
streetAddress: '1600 Pennsylvania Avenue NW',
city: 'Washington',
state: 'DC',
country: 'United States',
continent: 'North America'
}
]
}
},
{id: 'field-8', value: {type: 'number', data: 100}},
{id: 'field-9', value: {type: 'number-multi', data: [100, 200, 300]}},
{id: 'field-10', value: {type: 'person', data: {id: 1}}},
{id: 'field-11', value: {type: 'person-multi', data: [{id: 1}, {id: 2}]}},
{id: 'field-12', value: {type: 'ranked-dropdown', data: {dropdownOptionId: 1}}},
{id: 'field-13', value: {type: 'text', data: 'Some new text'}}
]
})
};
fetch('https://api.affinity.co/v2/persons/{personId}/fields', 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/{personId}/fields",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'operation' => 'update-fields',
'updates' => [
[
'id' => 'field-1',
'value' => [
'type' => 'company',
'data' => [
'id' => 1
]
]
],
[
'id' => 'field-2',
'value' => [
'type' => 'company-multi',
'data' => [
[
'id' => 1
],
[
'id' => 2
]
]
]
],
[
'id' => 'field-3',
'value' => [
'type' => 'datetime',
'data' => '2023-01-01T00:00:00Z'
]
],
[
'id' => 'field-4',
'value' => [
'type' => 'dropdown',
'data' => [
'dropdownOptionId' => 1
]
]
],
[
'id' => 'field-5',
'value' => [
'type' => 'dropdown-multi',
'data' => [
[
'dropdownOptionId' => 1
],
[
'dropdownOptionId' => 2
]
]
]
],
[
'id' => 'field-6',
'value' => [
'type' => 'location',
'data' => [
'streetAddress' => '1 Main Street',
'city' => 'San Francisco',
'state' => 'California',
'country' => 'United States',
'continent' => 'North America'
]
]
],
[
'id' => 'field-7',
'value' => [
'type' => 'location-multi',
'data' => [
[
'streetAddress' => '1 Main Street',
'city' => 'San Francisco',
'state' => 'California',
'country' => 'United States',
'continent' => 'North America'
],
[
'streetAddress' => '1600 Pennsylvania Avenue NW',
'city' => 'Washington',
'state' => 'DC',
'country' => 'United States',
'continent' => 'North America'
]
]
]
],
[
'id' => 'field-8',
'value' => [
'type' => 'number',
'data' => 100
]
],
[
'id' => 'field-9',
'value' => [
'type' => 'number-multi',
'data' => [
100,
200,
300
]
]
],
[
'id' => 'field-10',
'value' => [
'type' => 'person',
'data' => [
'id' => 1
]
]
],
[
'id' => 'field-11',
'value' => [
'type' => 'person-multi',
'data' => [
[
'id' => 1
],
[
'id' => 2
]
]
]
],
[
'id' => 'field-12',
'value' => [
'type' => 'ranked-dropdown',
'data' => [
'dropdownOptionId' => 1
]
]
],
[
'id' => 'field-13',
'value' => [
'type' => 'text',
'data' => 'Some new text'
]
]
]
]),
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/{personId}/fields"
payload := strings.NewReader("{\n \"operation\": \"update-fields\",\n \"updates\": [\n {\n \"id\": \"field-1\",\n \"value\": {\n \"type\": \"company\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-2\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-3\",\n \"value\": {\n \"type\": \"datetime\",\n \"data\": \"2023-01-01T00:00:00Z\"\n }\n },\n {\n \"id\": \"field-4\",\n \"value\": {\n \"type\": \"dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-5\",\n \"value\": {\n \"type\": \"dropdown-multi\",\n \"data\": [\n {\n \"dropdownOptionId\": 1\n },\n {\n \"dropdownOptionId\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-6\",\n \"value\": {\n \"type\": \"location\",\n \"data\": {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n }\n },\n {\n \"id\": \"field-7\",\n \"value\": {\n \"type\": \"location-multi\",\n \"data\": [\n {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n },\n {\n \"streetAddress\": \"1600 Pennsylvania Avenue NW\",\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n ]\n }\n },\n {\n \"id\": \"field-8\",\n \"value\": {\n \"type\": \"number\",\n \"data\": 100\n }\n },\n {\n \"id\": \"field-9\",\n \"value\": {\n \"type\": \"number-multi\",\n \"data\": [\n 100,\n 200,\n 300\n ]\n }\n },\n {\n \"id\": \"field-10\",\n \"value\": {\n \"type\": \"person\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-11\",\n \"value\": {\n \"type\": \"person-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-12\",\n \"value\": {\n \"type\": \"ranked-dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-13\",\n \"value\": {\n \"type\": \"text\",\n \"data\": \"Some new text\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.affinity.co/v2/persons/{personId}/fields")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"operation\": \"update-fields\",\n \"updates\": [\n {\n \"id\": \"field-1\",\n \"value\": {\n \"type\": \"company\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-2\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-3\",\n \"value\": {\n \"type\": \"datetime\",\n \"data\": \"2023-01-01T00:00:00Z\"\n }\n },\n {\n \"id\": \"field-4\",\n \"value\": {\n \"type\": \"dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-5\",\n \"value\": {\n \"type\": \"dropdown-multi\",\n \"data\": [\n {\n \"dropdownOptionId\": 1\n },\n {\n \"dropdownOptionId\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-6\",\n \"value\": {\n \"type\": \"location\",\n \"data\": {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n }\n },\n {\n \"id\": \"field-7\",\n \"value\": {\n \"type\": \"location-multi\",\n \"data\": [\n {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n },\n {\n \"streetAddress\": \"1600 Pennsylvania Avenue NW\",\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n ]\n }\n },\n {\n \"id\": \"field-8\",\n \"value\": {\n \"type\": \"number\",\n \"data\": 100\n }\n },\n {\n \"id\": \"field-9\",\n \"value\": {\n \"type\": \"number-multi\",\n \"data\": [\n 100,\n 200,\n 300\n ]\n }\n },\n {\n \"id\": \"field-10\",\n \"value\": {\n \"type\": \"person\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-11\",\n \"value\": {\n \"type\": \"person-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-12\",\n \"value\": {\n \"type\": \"ranked-dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-13\",\n \"value\": {\n \"type\": \"text\",\n \"data\": \"Some new text\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/persons/{personId}/fields")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operation\": \"update-fields\",\n \"updates\": [\n {\n \"id\": \"field-1\",\n \"value\": {\n \"type\": \"company\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-2\",\n \"value\": {\n \"type\": \"company-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-3\",\n \"value\": {\n \"type\": \"datetime\",\n \"data\": \"2023-01-01T00:00:00Z\"\n }\n },\n {\n \"id\": \"field-4\",\n \"value\": {\n \"type\": \"dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-5\",\n \"value\": {\n \"type\": \"dropdown-multi\",\n \"data\": [\n {\n \"dropdownOptionId\": 1\n },\n {\n \"dropdownOptionId\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-6\",\n \"value\": {\n \"type\": \"location\",\n \"data\": {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n }\n },\n {\n \"id\": \"field-7\",\n \"value\": {\n \"type\": \"location-multi\",\n \"data\": [\n {\n \"streetAddress\": \"1 Main Street\",\n \"city\": \"San Francisco\",\n \"state\": \"California\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n },\n {\n \"streetAddress\": \"1600 Pennsylvania Avenue NW\",\n \"city\": \"Washington\",\n \"state\": \"DC\",\n \"country\": \"United States\",\n \"continent\": \"North America\"\n }\n ]\n }\n },\n {\n \"id\": \"field-8\",\n \"value\": {\n \"type\": \"number\",\n \"data\": 100\n }\n },\n {\n \"id\": \"field-9\",\n \"value\": {\n \"type\": \"number-multi\",\n \"data\": [\n 100,\n 200,\n 300\n ]\n }\n },\n {\n \"id\": \"field-10\",\n \"value\": {\n \"type\": \"person\",\n \"data\": {\n \"id\": 1\n }\n }\n },\n {\n \"id\": \"field-11\",\n \"value\": {\n \"type\": \"person-multi\",\n \"data\": [\n {\n \"id\": 1\n },\n {\n \"id\": 2\n }\n ]\n }\n },\n {\n \"id\": \"field-12\",\n \"value\": {\n \"type\": \"ranked-dropdown\",\n \"data\": {\n \"dropdownOptionId\": 1\n }\n }\n },\n {\n \"id\": \"field-13\",\n \"value\": {\n \"type\": \"text\",\n \"data\": \"Some new text\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"operation": "update-fields"
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Person ID
Required range:
1 <= x <= 9007199254740991Body
application/json
Response
OK
The response body for a single operation within a person batch request.
The type of batch operation that was performed on the person.
Available options:
update-fields Was this page helpful?
⌘I