How to use Affinity's API to create an organization in Affinity
To create an organization in Affinity using the API, you can follow the steps below:
- Create a list, or establish which list you would like to add the organization to (done on the web).
- Using the API, search for the organization first. Use domain if possible for best results and to prevent duplicates.
curl "https://api.affinity.co/organizations?term=affinity.co" -u :<API-KEY>
- Make sure the result is what you are searching for (ex. If you search for "affinity.co", your result could be affinity.co and affinity.com). If you are able to find the organization, skip to Step 6.
- If the search result didn't find the organization you are looking for, create a new organization with the snippet below.
curl "https://api.affinity.co/organizations" \
-u :<API-KEY> \
-d name="Acme Corporation" \
-d domain="acme.co" - After the organization is created, below is what your response would look liked. You will get the same result if an organization is found as well.
{ "id": 120611418, "name": "Acme Corporation", "domain": "acme.co", "crunchbase_uuid": null, "global": false}
- Take the id, and add it to your list.
curl "https://api.affinity.co/lists/450/list-entries" \
-u :<API-KEY> \
-d entity_id=120611418 - After adding it to a list, you can use the code below to create field values.
curl "https://api.affinity.co/field-values" \
-u :<API-KEY> \
-d field_id=1284 \
-d value="Architecture" \
-d entity_id=120611418
Note: You can also use online tools like https://curl.trillworks.com/, to convert CURL to Python, JS, or any other language.